Forms
Select
One choice out of a short list.
Installation
pnpm add @elsikora/keystone-ui-kitUsage
import { SelectContent, Select, SelectValue, SelectItem } from "@elsikora/keystone-ui-kit";import { Field, Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@elsikora/keystone-ui-kit";
export default function SelectDefaultExample() { return ( <Field label="Currency"> <Select defaultValue="eur"> <SelectTrigger> <SelectValue /> </SelectTrigger> <SelectContent> <SelectItem value="eur">Euro</SelectItem> <SelectItem value="usd">US dollar</SelectItem> <SelectItem value="gbp">Pound sterling</SelectItem> </SelectContent> </Select> </Field> );}Examples
Default
With a placeholder
Groups
Groups with a heading each; the heading is read with its items.
API reference
SelectContent
| Prop | Type | Default | Description |
|---|---|---|---|
container | Element | DocumentFragment | null | - | Where it opens; by default the nearest PortalRoot's element, else the body. |
Select
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | - | The choice, when the caller holds the state. |
defaultValue | string | - | The first choice, when the component holds it. |
onValueChange | (value: string) => void | - | Called on a new choice. |
disabled | boolean | false | Unavailable. |
SelectValue
| Prop | Type | Default | Description |
|---|---|---|---|
placeholder | ReactNode | - | Shown before a choice. |
SelectItem
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | - | The value it chooses. |
Notes
- Arrow keys move, Enter or Space chooses, Escape closes, typing jumps to an item.