Select
Composable select primitives for custom option rows.
Demo
Usage
import { useState } from 'react'
import { Select, Token } from 'regen-ui'
const assetItems = [
{
label: 'pathUSD',
prefix: (
<Token
address="0x20c0000000000000000000000000000000000000"
chainId={4217}
size="small"
/>
),
suffix: '1,240.50',
value: 'pathusd',
},
{
label: 'USDC.e',
prefix: (
<Token
address="0x20c000000000000000000000b9537d11c60e8b50"
chainId={4217}
size="small"
/>
),
suffix: '845.00',
value: 'usdce',
},
]
export function AssetSelect() {
const [value, setValue] = useState('pathusd')
return <Select items={assetItems} onChange={setValue} value={value} />
}API Reference
Select.Props
| Name | Type | Default | Description |
|---|---|---|---|
error | boolean | None | Error state for the trigger border. |
items | readonly Item[] | None | Selectable items. |
onChange | (value: string) => void | None | Called with the selected item value. |
placeholder | ReactNode | 'Select an option' | Placeholder shown when no item is selected. |
value | string | None | Current selected item value. |
Inherits React.ButtonHTMLAttributes<HTMLButtonElement>, except onChange, prefix. | |||
errorType
booleanDefaultNone
Error state for the trigger border.itemsType
readonly Item[]DefaultNone
Selectable items.onChangeType
(value: string) => voidDefaultNone
Called with the selected item value.placeholderType
ReactNodeDefault
Placeholder shown when no item is selected.'Select an option'valueType
stringDefaultNone
Current selected item value.Inherits
React.ButtonHTMLAttributes<HTMLButtonElement>, except onChange, prefix.Select.Item
A selectable item.
| Name | Type | Default | Description |
|---|---|---|---|
disabled | boolean | None | Whether this item is disabled. |
label | ReactNode | None | Main item label. |
prefix | ReactNode | None | Element before the label. |
suffix | ReactNode | None | Element after the label, shown in the popup only. |
textValue | string | None | Plain text label for keyboard search. |
value | string | None | Stable item value. |
disabledType
booleanDefaultNone
Whether this item is disabled.labelType
ReactNodeDefaultNone
Main item label.prefixType
ReactNodeDefaultNone
Element before the label.suffixType
ReactNodeDefaultNone
Element after the label, shown in the popup only.textValueType
stringDefaultNone
Plain text label for keyboard search.valueType
stringDefaultNone
Stable item value.