@@ -6,40 +6,53 @@ Whether you want to showcase a constant list of options or dynamically adapt to
6
6
7
7
## Features
8
8
9
- - Dynamic suggestions list
9
+ - Custom suggestions list
10
10
11
11
- Responsive
12
12
13
+ - Multi Themes
14
+
13
15
- Clear button
14
16
15
17
- ` Rtl ` support
16
18
17
19
- Flexible style
18
20
21
+ - Lightweight
22
+
19
23
## Installation
20
24
21
- > $ npm install react-custom-search-list --save
25
+ > $ npm install react-custom-search-list @ popperjs/core --save
22
26
23
27
or
24
28
25
- > $ yarn add react-custom-search-list
29
+ > $ yarn add react-custom-search-list @ popperjs/core
26
30
27
31
If you need to directly include script in your html, use the following links :
28
32
29
33
``` js
30
34
< script src= " https://unpkg.com/react-custom-search-list@latest/dist/react-custom-search-list.umd.min.js" >< / script>
31
35
```
32
36
37
+ #### NOTE:
38
+
39
+ > Please note that ` @popperjs/core ` is peer dependency, meaning you should ensure it is installed before installing ` react-custom-search-list ` .
40
+
33
41
## Minimal Usage
34
42
35
43
``` js
36
44
import {useState } from ' react' ;
45
+ import ' react-custom-search-list/style/react-custom-search-list.min.css' ;
37
46
import ReactCustomSearchList from ' react-custom-search-list' ;
38
47
function App () {
39
- const [searchValue , setSearchValue ] = useState (' ' );
48
+ const [value , setValue ] = useState (' ' );
40
49
return (
41
- < ReactCustomSearchList fullWidth value= {searchValue} setValue= {setSearchValue}>
42
- /** Render your suggestions list here */
50
+ < ReactCustomSearchList
51
+ fullWidth
52
+ value= {value}
53
+ onChange= {(e ) => setValue (e .target .value )}
54
+ onClear= {() => setValue (' ' )}>
55
+ {/** Render your suggestions list here*/ }
43
56
< ul>
44
57
< li> Option A < / li>
45
58
< li> Option B < / li>
@@ -52,49 +65,60 @@ function App() {
52
65
53
66
## Props
54
67
55
- - value
68
+ - ** value**
56
69
- type : ` String `
57
70
- description : input value
58
- - setValue
71
+ - ** onChange **
59
72
- type : ` Func `
60
- - description : setState function for input value
61
- - children
73
+ - description : onChange Handler for the input value
74
+ - ** children**
62
75
- type : ` ReactNode `
63
76
- description : suggestions list
64
- - rootStyle?
77
+ - ** rootStyle?**
65
78
- type : ` Object `
66
79
- description : style object of the ` root ` element
67
- - inputStyle?
80
+ - ** inputContainerStyle?**
81
+ - type: ` Object `
82
+ - description : style object of the parent element of text input
83
+ - ** inputStyle?**
68
84
- type : ` Object `
69
85
- description : style object of the ` input ` element
70
- - placeholder?
86
+ - ** placeholder?**
71
87
- type : ` String `
72
88
- default : ` "search" `
73
- - iconsColor?
74
- - type : ` String `
75
- - description : svg icon's color
76
- - default : ` "gray" `
77
- - searchIconStyle?
78
- - type : ` Object `
79
- - description : style object of the magnifying icon
80
- - clearIconStyle?
81
- - type : ` Object `
82
- - description : style object of the clear icon
83
- - popperStyle?
89
+ - ** popperStyle?**
84
90
- type : ` Object `
85
91
- description : style object of the popper container
86
- - onKeyDown?
92
+ - ** onKeyDown?**
87
93
- type : ` Func `
88
94
- description : keydown event for input
89
- - onBlur?
95
+ - ** onFocus?**
96
+ - type : ` Func `
97
+ - description : focus event for input
98
+ - ** onBlur?**
90
99
- type : ` Func `
91
100
- description : blur event for input
92
- - fullWidth?
101
+ - ** fullWidth?**
93
102
- type : ` Boolean `
94
- - description : set popper width same as input
95
- - placement?
103
+ - description : set popper width same as input ( if the ` theme ` option is equal to ` "panel" ` then ` fullWidth ` option will not work )
104
+ - default: ` true `
105
+ - ** placement?**
96
106
- type : ` 'auto'| 'auto-start'| 'auto-end'| 'top'| 'top-start'| 'top-end'| 'bottom'| 'bottom-start'| 'bottom-end'| 'right'| 'right-start'| 'right-end'| 'left'| 'left-start'| 'left-end' `
97
107
- description : popper's placement
108
+ - default : ` bottom-start `
109
+ - ** ClearIconComponent?**
110
+ - type : ` React function component `
111
+ - description : custom Clear icon
112
+ - ** MagnifierIconComponent?**
113
+ - type : ` React function component `
114
+ - description : custom Magnifier icon
115
+ - ** onClear?**
116
+ - type : ` Func `
117
+ - description : triggered when the user clicks on the Clear icon
118
+ - ** theme?**
119
+ - type : ` "outline"|"underline"|"panel" `
120
+ - description : searchbox theme
121
+ - default : ` "outline" `
98
122
99
123
## Test
100
124
0 commit comments