Usage
Examples#
Single item#
In the following example you can select only one item.
Multiple items#
In the following example you can select multiple items.
Class Components#
The following example shows how you can use the package in class components.
Props#
items#
State variable that holds the items.
| Type | Required |
|---|---|
| ItemType[] | true |
- See: Item Schema and List and items
value#
State variable that specifies the value of the selected item. It's an array of values for multiple item pickers.
| Type | Required |
|---|---|
| ValueType | ValueType[] | true |
open#
State variable that specifies whether the picker is open.
| Type | Required |
|---|---|
| boolean | true |
props#
Adds native props for the container TouchableOpacity.
itemProps#
Adds native props for the TouchableOpacity of each item.
containerProps#
Adds native props for the container.
| Type |
|---|
| ViewProps |
labelProps#
Adds native props for the Text element of the selected item.
| Type |
|---|
| TextProps |
min#
Specifies the minimum number of items.
note
This only works with multiple item pickers.
| Type | Default |
|---|---|
| number | null |
max#
Specifies the maximum number of items.
note
This only works with multiple item pickers.
| Type | Default |
|---|---|
| number | null |
disabled#
Disables the picker.
| Type | Default |
|---|---|
| boolean | false |
maxHeight#
Max height of the drop-down box.
| Type | Default |
|---|---|
| number | 200 |
disableBorderRadius#
Disables changing the border radius when opening.
| Type | Default |
|---|---|
| boolean | false |
stickyHeader#
Makes categories stick to the top of the screen until the next one pushes it off.
| Type |
|---|
| boolean |
autoScroll#
Automatically scrolls to the first selected item.
| Type |
|---|
| boolean |
zIndex#
Specifies the stack order.
| Type | Default |
|---|---|
| number | 5000 |
- See: Multiple Pickers
zIndexInverse#
Specifies the inverse stack order.
| Type | Default |
|---|---|
| number | 6000 |
- See: Multiple Pickers
Callbacks#
setOpen#
State callback that is called when the user presses the picker.
| Type | Required |
|---|---|
| (open: boolean) => void | true |
setItems#
State callback that is called to modify or add new items.
| Type |
|---|
| (callback: SetStateAction[]) => void |
setValue#
State callback that is called when the value changes.
- See: Class Components
| Type | Required |
|---|---|
| (callback: SetStateAction) => void | true |
onChangeValue#
Callback that returns the current value.
| Type |
|---|
| (value: ValueType) => void | (value: ValueType[]) => void | null |
onPress#
Callback that is called as soon as the user presses the picker.
| Type |
|---|
| (open: boolean) => void |
onOpen#
Callback that is called when the user opens the picker.
| Type |
|---|
| () => void |
onClose#
Callback that is called when the user closes the picker.
| Type |
|---|
| () => void |