Select
A custom single or multiple selection control with a popup listbox.
SelectView sourceExample
The preview is interactive. The code below it is the docs demo source; demo-only layout classes can be omitted in application code.
import { Cell, For } from "retend";
import { Field, Select } from "innate-ui";
import classes from "../docs.module.css";
type ReleaseChannel = "" | "stable" | "beta" | "canary";
type Platform = "web" | "ios" | "android";
const releaseChannels = ["stable", "beta", "canary"] as const;
const platforms = ["web", "ios", "android"] as const;
export function SelectDemo() {
const releaseChannel = Cell.source<ReleaseChannel>("");
const selectedPlatforms = Cell.source<ReadonlyArray<Platform>>(["web"]);
return (
<div class={classes.selectDemo}>
<Field id="release-channel-field" class={classes.selectExample}>
<Field.Label>Release channel</Field.Label>
<Select
id="release-channel-select"
value={releaseChannel}
onChange={(value) => releaseChannel.set(value)}
placeholder="Select channel"
>
{For(releaseChannels, (channel) => (
<Select.Option value={channel}>{channel}</Select.Option>
))}
</Select>
</Field>
<Field id="platform-field" class={classes.selectExample}>
<Field.Label>Target platforms</Field.Label>
<Select
id="platform-select"
multiple
value={selectedPlatforms}
onChange={(value) => selectedPlatforms.set(value)}
placeholder="Select platforms"
>
{For(platforms, (platform) => (
<Select.Option value={platform}>{platform}</Select.Option>
))}
</Select>
</Field>
</div>
);
}API reference
This table is generated from Innate UI's exported TypeScript declarations and JSDoc. Native element attributes inherited by a prop type are not repeated here.
SelectProps
| Prop | Type | Default |
|---|---|---|
valuerequiredSelected option value. Selected option values. | JSX.ValueOrCell<Value> | JSX.ValueOrCell<ReadonlyArray<Value>> | — |
multipleEnables multiple selection when `true`. Enables multiple selection. | false | true | false |
onChangeCalled when a different option is selected. Called with the next selected-value array. | (value: Value) => void | (value: ReadonlyArray<Value>) => void | — |
idrequiredStable id used to connect the trigger and listbox. | string | — |
childrenrequired`Select.Option` children. | JSX.Children | — |
openWhether the listbox is open. | JSX.ValueOrCell<boolean> | — |
placeholderTrigger placeholder shown when no value is selected. | JSX.ValueOrCell<string> | "Select an option" |
disabledWhether the select is disabled. | JSX.ValueOrCell<boolean> | false |
invalidWhether the select is in an invalid state. | JSX.ValueOrCell<boolean> | false |
ariaDescribedByIds of elements that describe the trigger. | JSX.ValueOrCell<string | undefined> | — |
onOpenChangeCalled when the listbox requests an open-state change. | (open: boolean, reason?: PopoverCloseReason) => void | — |
SelectOptionProps
| Prop | Type | Default |
|---|---|---|
valuerequiredValue represented by this option. | Value | — |
childrenrequiredOption content. | JSX.Children | — |
textValueDisplay/typeahead text when it cannot be inferred from `children`. | JSX.ValueOrCell<string> | — |
disabledWhether the option is disabled. | JSX.ValueOrCell<boolean> | false |
refReceives the option button element. | SourceCell<HTMLButtonElement | null> | — |
onClickClick handler called before selection. | EventHandlerProp<HTMLButtonElement, MouseEvent> | — |
onPointerMovePointer-move handler called before active-option tracking. | EventHandlerProp<HTMLButtonElement, PointerEvent> | — |