Skip to content

Commit c6bea23

Browse files
📝 added docs for valueRenderer and ItemRenderer
1 parent 9133a52 commit c6bea23

File tree

2 files changed

+39
-19
lines changed

2 files changed

+39
-19
lines changed

README.md

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,26 @@ export default Example;
5656

5757
## 👀 Props
5858

59-
| Prop | Description | Type | Default |
60-
| --------------------- | ----------------------------------- | ---------------------------- | -------------- |
61-
| `labelledBy` | value for `aria-labelledby` | `string` | |
62-
| `options` | options for dropdown | `[{label, value, disabled}]` | |
63-
| `value` | pre-selected rows | `[{label, value}]` | `[]` |
64-
| `focusSearchOnOpen` | focus on search input when opening | `boolean` | `true` |
65-
| `hasSelectAll` | toggle 'Select All' option | `boolean` | `true` |
66-
| `isLoading` | show spinner on select | `boolean` | `false` |
67-
| `shouldToggleOnHover` | toggle dropdown on hover option | `boolean` | `false` |
68-
| `overrideStrings` | i18n [docs](#-internationalization) | `object` | |
69-
| `onChange` | onChange callback | `function` | |
70-
| `disabled` | disable dropdown | `boolean` | `false` |
71-
| `selectAllLabel` | _select all_ label | `string` | |
72-
| `disableSearch` | hide search textbox | `boolean` | `false` |
73-
| `filterOptions` | custom filter options | `function` | Fuzzy Search |
74-
| `className` | class name for parent component | `string` | `multi-select` |
75-
76-
### 🔍 Custom filter logic
59+
| Prop | Description | Type | Default |
60+
| --------------------- | ------------------------------------------------------ | ---------------------------- | -------------- |
61+
| `labelledBy` | value for `aria-labelledby` | `string` | |
62+
| `options` | options for dropdown | `[{label, value, disabled}]` | |
63+
| `value` | pre-selected rows | `[{label, value}]` | `[]` |
64+
| `focusSearchOnOpen` | focus on search input when opening | `boolean` | `true` |
65+
| `hasSelectAll` | toggle 'Select All' option | `boolean` | `true` |
66+
| `isLoading` | show spinner on select | `boolean` | `false` |
67+
| `shouldToggleOnHover` | toggle dropdown on hover option | `boolean` | `false` |
68+
| `overrideStrings` | i18n [docs](#-internationalization) | `object` | |
69+
| `onChange` | onChange callback | `function` | |
70+
| `disabled` | disable dropdown | `boolean` | `false` |
71+
| `selectAllLabel` | _select all_ label | `string` | |
72+
| `disableSearch` | hide search textbox | `boolean` | `false` |
73+
| `filterOptions` | custom filter options | `function` | Fuzzy Search |
74+
| `className` | class name for parent component | `string` | `multi-select` |
75+
| `valueRenderer` | custom dropdown header [docs](#-custom-value-renderer) | `function` | |
76+
| `ItemRenderer` | custom dropdown option [docs](#-custom-item-renderer) | `function` | |
77+
78+
## 🔍 Custom filter logic
7779

7880
By default this component uses a fuzzy search algorithm to filter options but also allows you to opt-out and use your custom logic if you want to below is the example doing just case insensitive search
7981

@@ -102,6 +104,24 @@ default values for `overrideStrings` are as below
102104
}
103105
```
104106

107+
## 🎛 Custom Value Renderer
108+
109+
Optionally customise value renderer view by passing `valueRenderer` prop
110+
111+
```js
112+
const customValueRenderer = (selected, _options) => {
113+
return selected.length
114+
? selected.map(({ label }) => "✔️ " + label)
115+
: "😶 No Items Selected";
116+
};
117+
```
118+
119+
## 🎛 Custom Item Renderer
120+
121+
Optionally customise dropdown item by passing `ItemRenderer` prop
122+
123+
[Default Item Renderer](https://github.com/harshzalavadiya/react-multi-select-component/blob/master/src/select-panel/default-item.tsx#L27-L47)
124+
105125
## 💅 Themeing
106126

107127
You can override CSS variables to customize the appearance

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-multi-select-component",
3-
"version": "2.0.10",
3+
"version": "2.0.11",
44
"description": "Simple and lightweight multiple selection dropdown component with checkboxes, search and select-all",
55
"author": "Harsh Zalavadiya",
66
"license": "MIT",

0 commit comments

Comments
 (0)