import { Select } from "@senvenli/react/selection";
export default function Example() {
return (
<div className="max-w-80">
<Select
label="Status"
placeholder="Choose a status"
defaultSelectedKey="in-progress"
items={[
{ id: "draft", label: "Draft" },
{ id: "in-progress", label: "In progress" },
{ id: "in-review", label: "In review" },
{ id: "done", label: "Done" },
]}
/>
</div>
);
}import { Select } from "@senvenli/react/selection";Examples
Groups, descriptions and details
Options under headers, with a second line and a right-aligned detail.import { Select } from "@senvenli/react/selection";
export default function Example() {
return (
<div className="max-w-80">
<Select
label="Assign to"
placeholder="Choose a team"
description="The team is notified by email."
items={[
{ id: "support-1", label: "Tier 1", description: "First response", meta: "8 people", group: "Support" },
{ id: "support-2", label: "Tier 2", description: "Escalations", meta: "3 people", group: "Support" },
{ id: "billing", label: "Billing", description: "Invoices and refunds", meta: "4 people", group: "Finance" },
{ id: "fraud", label: "Fraud review", description: "Paused until Monday", meta: "2 people", group: "Finance", isDisabled: true },
]}
/>
</div>
);
}Compact
The 32px size for table filters and toolbars, named by aria-label.import { Stack } from "@senvenli/react/layout";
import { Select } from "@senvenli/react/selection";
import { useState } from "react";
export default function Example() {
const [period, setPeriod] = useState<string | number | null>("30");
return (
<Stack direction="horizontal" space="space-100">
<Select
aria-label="Period"
size="small"
selectedKey={period}
onSelectionChange={setPeriod}
items={[
{ id: "7", label: "Last 7 days" },
{ id: "30", label: "Last 30 days" },
{ id: "90", label: "Last 90 days" },
]}
/>
<Select
aria-label="Channel"
size="small"
placeholder="All channels"
items={[
{ id: "online", label: "Online" },
{ id: "retail", label: "Retail" },
]}
/>
</Stack>
);
}Invalid and disabled
An error under the field, and a field that cannot change.import { Stack } from "@senvenli/react/layout";
import { Select } from "@senvenli/react/selection";
const CURRENCIES = [
{ id: "usd", label: "US dollar" },
{ id: "eur", label: "Euro" },
{ id: "gbp", label: "Pound sterling" },
];
export default function Example() {
return (
<div className="max-w-80">
<Stack space="space-300">
<Select label="Invoice currency" isRequired isInvalid errorMessage="Choose the currency this customer pays in." items={CURRENCIES} />
<Select label="Account currency" description="Set when the account was created." isDisabled defaultSelectedKey="usd" items={CURRENCIES} />
</Stack>
</div>
);
}Several: A few options
Each choice shows as a tag that can be removed.import { Select } from "@senvenli/react/selection";
export default function Example() {
return (
<div className="max-w-80">
<Select selectionMode="multiple"
label="Notify by"
placeholder="Add channel"
defaultSelectedKeys={["email"]}
items={[
{ id: "email", label: "Email" },
{ id: "sms", label: "Text message" },
{ id: "push", label: "Push notification" },
{ id: "slack", label: "Slack", description: "Posts to #orders" },
]}
/>
</div>
);
}Several: Select all, with collapsed tags
A footer selects everything; tags past the limit fold into a count.import { Select } from "@senvenli/react/selection";
const REGIONS = [
{ id: "na", label: "North America" },
{ id: "sa", label: "South America" },
{ id: "eu", label: "Europe" },
{ id: "me", label: "Middle East" },
{ id: "af", label: "Africa" },
{ id: "apac", label: "Asia Pacific" },
];
export default function Example() {
return (
<div className="max-w-80">
<Select selectionMode="multiple"
label="Regions"
description="Orders from these regions appear in the report."
allowsSelectAll
maxVisibleTags={2}
defaultSelectedKeys={["na", "eu", "apac", "me"]}
items={REGIONS}
/>
</div>
);
}Several: Invalid and disabled
The app's own error under the field, and a field that cannot change.import { Stack } from "@senvenli/react/layout";
import { Select } from "@senvenli/react/selection";
import { useState } from "react";
const ROLES = [
{ id: "admin", label: "Admin" },
{ id: "billing", label: "Billing" },
{ id: "support", label: "Support" },
];
export default function Example() {
const [roles, setRoles] = useState<(string | number)[]>([]);
return (
<div className="max-w-80">
<Stack space="space-300">
<Select selectionMode="multiple"
label="Roles"
isRequired
requiredValidation="app"
isInvalid={roles.length === 0}
errorMessage="Choose at least one role."
selectedKeys={roles}
onSelectionChange={setRoles}
items={ROLES}
/>
<Select selectionMode="multiple" label="Inherited roles" isDisabled defaultSelectedKeys={["support"]} items={ROLES} />
</Stack>
</div>
);
}Guidelines
When to use it
- One choice from about 5 to 15 options.
- Several choices from a medium list.
Use something else when
- Fewer than 5 options should all stay visible. Radio group
- The list is long and people type to find. Combo box
- A few options should all stay visible. Checkbox
- The options should stay visible on the page, not in a dropdown. List box
Accessibility
Keyboard
| Keys | What happens |
|---|---|
| Space, Enter, Arrow down | Opens the list. |
| Arrow keys, typing | Moves to an option. |
Built in
- Announced as a button that opens a listbox.
- Required fields show "Fill in this field." after a blur or a submit; your own
errorMessagereplaces it. - Each tag has a remove button named after its option.
You provide
- A visible label.
API reference
Select
| Prop | Type | Default | Description |
|---|---|---|---|
label | React.ReactNode | – | The label sits above the field. |
itemsRequired | readonly SelectItem[] | – | Up to ~15 options; more, or options people know by name → ComboBox. |
selectedKey | Key | – | Controlled value; |
defaultSelectedKey | Key | – | |
onSelectionChange | (key: Key | null) => void | (keys: Key[]) => void | – | |
placeholder | string | – | Defaults to "Select" in the provider locale. |
description | React.ReactNode | – | |
errorMessage | React.ReactNode | – | |
isInvalid | boolean | – | |
aria-invalid | boolean | "true" | "false" | – | Set by a form row that owns the error text (the shared |
isRequired | boolean | – | |
requiredValidation | RequiredValidation | – | Who says an empty required Select is missing: |
isDisabled | boolean | – | |
size | FieldSize | – |
|
name | string | – | |
selectionMode | "single" | "multiple" | – |
|
radius | ComponentRadius | – | Corner radius: |
aria-label | string | – | Names the field for assistive technology when no visible label is shown. |
selectedKeys | readonly Key[] | – | Controlled; may start undefined and become set later (never flips control). |
defaultSelectedKeys | readonly Key[] | – | |
maxVisibleTags | number | – | Tags shown before the rest collapse into "+3". |
allowsSelectAll | boolean | – | Adds the "Select all" footer with the selected count. |
labelReact.ReactNodeThe label sits above the field.
itemsRequiredreadonly SelectItem[]Up to ~15 options; more, or options people know by name → ComboBox.
selectedKeyKeyControlled value;
nullis "nothing chosen". It may start undefined and become set later.defaultSelectedKeyKeyonSelectionChange(key: Key | null) => void | (keys: Key[]) => voidplaceholderstringDefaults to "Select" in the provider locale.
descriptionReact.ReactNodeerrorMessageReact.ReactNodeisInvalidbooleanaria-invalidboolean | "true" | "false"Set by a form row that owns the error text (the shared
Fieldhands its controlaria-invalid): the field shows its invalid state as withisInvalid, and without anerrorMessageof its own draws no error row, so the row's message is the only one. The trigger is a button, on which React Aria sets noaria-invalid: the forwarded invalid state shows asdata-invalidon the field (its danger border) and through the row's own error text, not asaria-invalidon the trigger. It marks the field invalid for styling and assistive tech only: unlikeisInvalidit never becomes the field's native validity (React Aria's default outside a DS Form), so it never blocks a form's submit.isRequiredbooleanrequiredValidationRequiredValidationWho says an empty required Select is missing:
field(default) shows "Fill in this field." on blur and on a DS Form submit, which it then blocks;apponly marks the field (*,aria-required) and the app shows its own error. See {@link RequiredValidation}. The app'sisInvalid(truewith itserrorMessage, orfalse) overrides the check, as on TextField. Disabled, empty and required, it still blocks a DS Form's submit and cannot take focus (as TextField).isDisabledbooleansizeFieldSizecompact(32px) for table filters and toolbars.namestringselectionMode"single" | "multiple"single(default): one choice from a known list.radiusComponentRadiusCorner radius:
none,small,medium(the design),largeorfull. The provider's default otherwise.aria-labelstringNames the field for assistive technology when no visible label is shown.
selectedKeysreadonly Key[]Controlled; may start undefined and become set later (never flips control).
defaultSelectedKeysreadonly Key[]maxVisibleTagsnumberTags shown before the rest collapse into "+3".
allowsSelectAllbooleanAdds the "Select all" footer with the selected count.