warning_amberDeprecated
This Select component is deprecated and will no longer be supported.
You can use the newer Select instead.
Usage
Import
import { Select } from '@passfort/castle'
Single Select
function Example() {
const items = [
{
label: 'Alex W.',
id: 'rmc',
},
{
label: 'Stephen N.',
id: 'uxd',
},
{
label: 'David K.',
id: 'hux',
},
]
return <Select initialValue={items[0]} items={items} />
}
live example
Controlled Single Select
function Example() {
const [value, setValue] = React.useState()
React.useEffect(() => {
console.log('value', value)
}, [value])
return <Select value={value} onSelect={setValue} items={selectUsers} />
}
live example
Search Select
<Select
showSearch
items={selectUsers}
onSelect={(item) => console.log('item', item)}
/>
live example
Controlled
function Example() {
const [value, setValue] = React.useState()
React.useEffect(() => {
console.log('value', value)
}, [value])
return (
<Select showSearch value={value} onSelect={setValue} items={selectUsers} />
)
}
live example
FormControl
<FormControls>
<FormControl isDisabled>
<FormLabel>Search</FormLabel>
<Select showSearch items={selectUsers} />
</FormControl>
<FormControl isDisabled>
<FormLabel>Single</FormLabel>
<Select items={selectUsers} />
</FormControl>
</FormControls>
live example