Select
A button that shows the current choice and opens a list of options, for one value or several from a set the application already knows.
New orders ship from this warehouse.
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue,} from '@slotted/react/select';const WAREHOUSES = [ { value: 'RNO', label: 'Reno, NV' }, { value: 'CMH', label: 'Columbus, OH' }, { value: 'SAV', label: 'Savannah, GA' },];export default function SelectBasic() { return ( <Field> <FieldLabel>Fulfilment warehouse</FieldLabel> <Select> <SelectTrigger> <SelectValue placeholder="Choose a warehouse" /> </SelectTrigger> <SelectContent> {WAREHOUSES.map((warehouse) => ( <SelectItem key={warehouse.value} value={warehouse.value}> {warehouse.label} </SelectItem> ))} </SelectContent> </Select> <FieldDescription>New orders ship from this warehouse.</FieldDescription> </Field> );}Installation
The packages are a 0.x beta on npm, and their public API changes between beta releases without deprecation. One line installs the binding and the default theme.
pnpm add @slotted/react @slotted/theme @slotted/themesimport { Select, SelectContent, SelectGroup, SelectItem, SelectSeparator, SelectTrigger, SelectValue } from '@slotted/react';Placeholder and initial value
The placeholder fills the control while nothing is chosen. A select that starts with a value needs items, the list of values and labels: the options are built only when the list first opens, so without items the closed control shows the raw value, such as net-30, instead of its label.
import { Field, FieldLabel } from '@slotted/react/field';import { Select, SelectContent, SelectItem, type SelectOption, SelectTrigger, SelectValue,} from '@slotted/react/select';import { Stack } from '@slotted/react/stack';const REASONS: SelectOption[] = [ { value: 'damaged', label: 'Arrived damaged' }, { value: 'wrong-item', label: 'Wrong item shipped' }, { value: 'not-needed', label: 'No longer needed' },];const TERMS: SelectOption[] = [ { value: 'prepaid', label: 'Prepaid' }, { value: 'net-30', label: 'Net 30' }, { value: 'net-45', label: 'Net 45' },];export default function SelectPlaceholder() { return ( <Stack gap={5}> <Field> <FieldLabel>Return reason</FieldLabel> <Select> <SelectTrigger> <SelectValue placeholder="Choose a reason" /> </SelectTrigger> <SelectContent> {REASONS.map((reason) => ( <SelectItem key={reason.value} value={reason.value}> {reason.label} </SelectItem> ))} </SelectContent> </Select> </Field> <Field> <FieldLabel>Payment terms</FieldLabel> <Select defaultValue="net-30" items={TERMS}> <SelectTrigger> <SelectValue placeholder="Choose terms" /> </SelectTrigger> <SelectContent> {TERMS.map((term) => ( <SelectItem key={term.value} value={term.value}> {term.label} </SelectItem> ))} </SelectContent> </Select> </Field> </Stack> );}Sizes
size sets the control to one step of the control scale: sm for toolbars and dense tables, md for most forms, lg for sparse forms. A select is the same height as a text field of the same size. Inside a field, an unset size follows the field.
import { Field, FieldLabel } from '@slotted/react/field';import { Select, SelectContent, SelectItem, type SelectOption, type SelectSize, SelectTrigger, SelectValue,} from '@slotted/react/select';import { Stack } from '@slotted/react/stack';const SIZES: { size: SelectSize; label: string }[] = [ { size: 'sm', label: 'Small' }, { size: 'md', label: 'Medium' }, { size: 'lg', label: 'Large' },];const WAREHOUSES: SelectOption[] = [ { value: 'RNO', label: 'Reno, NV' }, { value: 'CMH', label: 'Columbus, OH' }, { value: 'SAV', label: 'Savannah, GA' },];export default function SelectSizes() { return ( <Stack gap={5}> {SIZES.map((step) => ( <Field key={step.size}> <FieldLabel>{step.label}</FieldLabel> <Select size={step.size} defaultValue="RNO" items={WAREHOUSES}> <SelectTrigger> <SelectValue /> </SelectTrigger> <SelectContent> {WAREHOUSES.map((warehouse) => ( <SelectItem key={warehouse.value} value={warehouse.value}> {warehouse.label} </SelectItem> ))} </SelectContent> </Select> </Field> ))} </Stack> );}Variants
outline is the default frame. subtle fills the control, for a form on a tinted surface. plain draws no frame at rest, for a table cell or a toolbar, and still shows hover and focus.
import { Field, FieldLabel } from '@slotted/react/field';import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, type SelectVariant,} from '@slotted/react/select';import { Stack } from '@slotted/react/stack';const VARIANTS: { variant: SelectVariant; label: string }[] = [ { variant: 'outline', label: 'Outline' }, { variant: 'subtle', label: 'Subtle' }, { variant: 'plain', label: 'Plain' },];const WAREHOUSES = [ { value: 'RNO', label: 'Reno, NV' }, { value: 'CMH', label: 'Columbus, OH' }, { value: 'SAV', label: 'Savannah, GA' },];export default function SelectVariants() { return ( <Stack gap={5}> {VARIANTS.map((step) => ( <Field key={step.variant}> <FieldLabel>{step.label}</FieldLabel> <Select variant={step.variant}> <SelectTrigger> <SelectValue placeholder="Choose a warehouse" /> </SelectTrigger> <SelectContent> {WAREHOUSES.map((warehouse) => ( <SelectItem key={warehouse.value} value={warehouse.value}> {warehouse.label} </SelectItem> ))} </SelectContent> </Select> </Field> ))} </Stack> );}Groups
SelectGroup in React and sl-select-group in Angular put a run of options under a heading, which assistive technology reads with each option. SelectSeparator and sl-select-separator draw a line between runs.
import { Fragment } from 'react';import { Field, FieldLabel } from '@slotted/react/field';import { Select, SelectContent, SelectGroup, SelectItem, type SelectOptionGroup, SelectSeparator, SelectTrigger, SelectValue,} from '@slotted/react/select';const METHODS: SelectOptionGroup[] = [ { label: 'Ground', options: [ { value: 'ups-ground', label: 'UPS Ground' }, { value: 'fedex-ground', label: 'FedEx Ground' }, ], }, { label: 'Express', options: [ { value: 'ups-2day', label: 'UPS 2nd Day Air' }, { value: 'fedex-overnight', label: 'FedEx Priority Overnight' }, ], }, { label: 'Freight', options: [{ value: 'ltl', label: 'LTL freight, palletised' }], },];export default function SelectGroups() { return ( <Field> <FieldLabel>Shipping method</FieldLabel> <Select> <SelectTrigger> <SelectValue placeholder="Choose a method" /> </SelectTrigger> <SelectContent> {METHODS.map((group, index) => ( <Fragment key={group.label}> {index > 0 ? <SelectSeparator /> : null} <SelectGroup label={group.label}> {group.options.map((method) => ( <SelectItem key={method.value} value={method.value}> {method.label} </SelectItem> ))} </SelectGroup> </Fragment> ))} </SelectContent> </Select> </Field> );}Icons and descriptions
icon fills the first column of an option and description writes a second line under its label. In React icon takes any element; in Angular it names a glyph. Every label starts on the same edge whether or not its option has an icon.
import { Field, FieldLabel } from '@slotted/react/field';import { Glyph, type GlyphName, Icon } from '@slotted/react/icon';import { Select, SelectContent, SelectItem, type SelectOption, SelectTrigger, SelectValue,} from '@slotted/react/select';const FORMATS: (SelectOption & { icon: GlyphName; description: string })[] = [ { value: 'csv', label: 'CSV', icon: 'file-spreadsheet', description: 'Opens in Excel and Google Sheets.', }, { value: 'pdf', label: 'PDF', icon: 'file-text', description: 'Paginated, with the company letterhead.', }, { value: 'json', label: 'JSON', icon: 'file', description: 'For an import into another system.', },];export default function SelectDescriptions() { return ( <Field> <FieldLabel>Export format</FieldLabel> <Select defaultValue="csv" items={FORMATS}> <SelectTrigger> <SelectValue /> </SelectTrigger> <SelectContent> {FORMATS.map((format) => ( <SelectItem key={format.value} value={format.value} description={format.description} icon={ <Icon> <Glyph name={format.icon} /> </Icon> } > {format.label} </SelectItem> ))} </SelectContent> </Select> </Field> );}Disabled options
A disabled option stays in the list, is announced as unavailable and is skipped by the arrow keys and by typeahead. Put the reason in its description, so the reader knows why it cannot be chosen.
import { Field, FieldLabel } from '@slotted/react/field';import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue,} from '@slotted/react/select';const CARRIERS: { value: string; label: string; disabled?: boolean; description?: string }[] = [ { value: 'ups', label: 'UPS Ground' }, { value: 'fedex', label: 'FedEx Ground' }, { value: 'dhl', label: 'DHL Express', disabled: true, description: 'Account on hold until invoice INV-21462 is paid.', }, { value: 'usps', label: 'USPS Priority Mail' },];export default function SelectDisabledOptions() { return ( <Field> <FieldLabel>Carrier</FieldLabel> <Select> <SelectTrigger> <SelectValue placeholder="Choose a carrier" /> </SelectTrigger> <SelectContent> {CARRIERS.map((carrier) => ( <SelectItem key={carrier.value} value={carrier.value} disabled={carrier.disabled ?? false} description={carrier.description} > {carrier.label} </SelectItem> ))} </SelectContent> </Select> </Field> );}States
Set invalid, readOnly and disabled on the field, which passes them to the select; each can also be set on the select itself. Invalid draws the border and the focus ring in the danger tone and sets aria-invalid. Read-only keeps the value legible and focusable and never opens. Disabled takes the control out of the tab order.
Error:Savannah does not accept returns. Choose Reno or Columbus.
Set when the order was picked.
Transfers open once the order is invoiced.
import { Field, FieldDescription, FieldError, FieldLabel } from '@slotted/react/field';import { Select, SelectContent, SelectItem, type SelectOption, SelectTrigger, SelectValue,} from '@slotted/react/select';import { Stack } from '@slotted/react/stack';const WAREHOUSES: SelectOption[] = [ { value: 'RNO', label: 'Reno, NV' }, { value: 'CMH', label: 'Columbus, OH' }, { value: 'SAV', label: 'Savannah, GA' },];export default function SelectStates() { return ( <Stack gap={5}> <Field invalid required> <FieldLabel>Return warehouse</FieldLabel> <Select defaultValue="SAV" items={WAREHOUSES}> <SelectTrigger> <SelectValue /> </SelectTrigger> <SelectContent> {WAREHOUSES.map((warehouse) => ( <SelectItem key={warehouse.value} value={warehouse.value}> {warehouse.label} </SelectItem> ))} </SelectContent> </Select> <FieldError>Savannah does not accept returns. Choose Reno or Columbus.</FieldError> </Field> <Field readOnly> <FieldLabel>Origin warehouse</FieldLabel> <Select defaultValue="RNO" items={WAREHOUSES}> <SelectTrigger> <SelectValue /> </SelectTrigger> <SelectContent> {WAREHOUSES.map((warehouse) => ( <SelectItem key={warehouse.value} value={warehouse.value}> {warehouse.label} </SelectItem> ))} </SelectContent> </Select> <FieldDescription>Set when the order was picked.</FieldDescription> </Field> <Field disabled> <FieldLabel>Transfer warehouse</FieldLabel> <Select defaultValue="CMH" items={WAREHOUSES}> <SelectTrigger> <SelectValue /> </SelectTrigger> <SelectContent> {WAREHOUSES.map((warehouse) => ( <SelectItem key={warehouse.value} value={warehouse.value}> {warehouse.label} </SelectItem> ))} </SelectContent> </Select> <FieldDescription>Transfers open once the order is invoiced.</FieldDescription> </Field> </Stack> );}Controlled
Pass value and update it from onValueChange when other parts of the screen depend on the choice; in Angular, bind [(value)] to a signal. The handler receives a string for a single select, an array for a multiple one, and null once the value is cleared.
import { useState } from 'react';import { Field, FieldLabel } from '@slotted/react/field';import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue,} from '@slotted/react/select';import { Stack } from '@slotted/react/stack';const SPEEDS = [ { value: 'ground', label: 'Ground', transit: '3–5 business days', price: '$8.40' }, { value: 'two-day', label: 'Two-day', transit: '2 business days', price: '$18.90' }, { value: 'overnight', label: 'Overnight', transit: 'Next business day', price: '$42.75' },];export default function SelectControlled() { const [speed, setSpeed] = useState('ground'); const chosen = SPEEDS.find((option) => option.value === speed); return ( <Stack gap={4}> <Field> <FieldLabel>Delivery speed</FieldLabel> <Select value={speed} items={SPEEDS} onValueChange={(next) => { if (typeof next === 'string') setSpeed(next); }} > <SelectTrigger> <SelectValue /> </SelectTrigger> <SelectContent> {SPEEDS.map((option) => ( <SelectItem key={option.value} value={option.value}> {option.label} </SelectItem> ))} </SelectContent> </Select> </Field> <span> Arrives in {chosen?.transit}. Shipping: {chosen?.price} </span> </Stack> );}Clearing
clearable adds a clear button once something is chosen. The button sets the value to null, the control shows its placeholder again, and focus returns to the control.
Clear the assignee to return the ticket to the queue.
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { Select, SelectContent, SelectItem, type SelectOption, SelectTrigger, SelectValue,} from '@slotted/react/select';const OWNERS: SelectOption[] = [ { value: 'avery', label: 'Avery Collins' }, { value: 'kenji', label: 'Kenji Watanabe' }, { value: 'lucia', label: 'Lucía Fernández' }, { value: 'ruth', label: 'Ruth Adeyemi' },];export default function SelectClearable() { return ( <Field> <FieldLabel>Assignee</FieldLabel> <Select clearable defaultValue="kenji" items={OWNERS}> <SelectTrigger> <SelectValue placeholder="Unassigned" /> </SelectTrigger> <SelectContent> {OWNERS.map((owner) => ( <SelectItem key={owner.value} value={owner.value}> {owner.label} </SelectItem> ))} </SelectContent> </Select> <FieldDescription>Clear the assignee to return the ticket to the queue.</FieldDescription> </Field> );}Multiple selection
multiple keeps the list open as options are chosen, and Space toggles the highlighted option without closing it. Each chosen value appears in the control as a tag with its own remove button; values that do not fit collapse into a +N tag, and the top of the open list shows all of them. The value is an array.
Each team gets an email when the order is delayed.
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { Select, SelectContent, SelectItem, type SelectOption, SelectTrigger, SelectValue,} from '@slotted/react/select';const TEAMS: SelectOption[] = [ { value: 'fulfilment', label: 'Fulfilment' }, { value: 'finance', label: 'Finance' }, { value: 'customer-care', label: 'Customer care' }, { value: 'purchasing', label: 'Purchasing' }, { value: 'returns', label: 'Returns desk' },];export default function SelectMultiple() { return ( <Field> <FieldLabel>Notify teams</FieldLabel> <Select multiple clearable defaultValue={['fulfilment', 'finance']} items={TEAMS}> <SelectTrigger> <SelectValue placeholder="No one is notified" /> </SelectTrigger> <SelectContent> {TEAMS.map((team) => ( <SelectItem key={team.value} value={team.value}> {team.label} </SelectItem> ))} </SelectContent> </Select> <FieldDescription>Each team gets an email when the order is delayed.</FieldDescription> </Field> );}Searching long lists
search puts a filter field at the top of the list. The query matches labels with a locale-sensitive comparison that ignores case and accents, so cote finds Côte d’Ivoire, and the matched span is marked. The query is never a value: it is emptied when an option is chosen or the list closes. Without search, typing on the closed or open control jumps to the first option that starts with the typed letters.
import { Field, FieldLabel } from '@slotted/react/field';import { Select, SelectContent, SelectItem, type SelectOption, SelectTrigger, SelectValue,} from '@slotted/react/select';const COUNTRIES: SelectOption[] = [ { value: 'AR', label: 'Argentina' }, { value: 'AU', label: 'Australia' }, { value: 'AT', label: 'Austria' }, { value: 'BE', label: 'Belgium' }, { value: 'BR', label: 'Brazil' }, { value: 'CA', label: 'Canada' }, { value: 'CL', label: 'Chile' }, { value: 'CO', label: 'Colombia' }, { value: 'CI', label: 'Côte d’Ivoire' }, { value: 'DK', label: 'Denmark' }, { value: 'FI', label: 'Finland' }, { value: 'FR', label: 'France' }, { value: 'DE', label: 'Germany' }, { value: 'IE', label: 'Ireland' }, { value: 'IT', label: 'Italy' }, { value: 'JP', label: 'Japan' }, { value: 'MX', label: 'Mexico' }, { value: 'NL', label: 'Netherlands' }, { value: 'NZ', label: 'New Zealand' }, { value: 'NO', label: 'Norway' }, { value: 'PL', label: 'Poland' }, { value: 'PT', label: 'Portugal' }, { value: 'ES', label: 'Spain' }, { value: 'SE', label: 'Sweden' }, { value: 'CH', label: 'Switzerland' }, { value: 'TR', label: 'Türkiye' }, { value: 'GB', label: 'United Kingdom' }, { value: 'US', label: 'United States' }, { value: 'UY', label: 'Uruguay' }, { value: 'VN', label: 'Vietnam' },];export default function SelectSearch() { return ( <Field> <FieldLabel>Ship-to country</FieldLabel> <Select search defaultValue="US" items={COUNTRIES} messages={{ searchPlaceholder: 'Filter countries' }} > <SelectTrigger> <SelectValue placeholder="Choose a country" /> </SelectTrigger> <SelectContent> {COUNTRIES.map((country) => ( <SelectItem key={country.value} value={country.value}> {country.label} </SelectItem> ))} </SelectContent> </Select> </Field> );}Long labels
An option label wraps to two lines and then truncates, with the whole text still in the DOM. An unbroken identifier breaks inside the option instead of widening the list. The closed control keeps to one line.
import { Field, FieldLabel } from '@slotted/react/field';import { Select, SelectContent, SelectItem, type SelectOption, SelectTrigger, SelectValue,} from '@slotted/react/select';const LISTINGS: SelectOption[] = [ { value: 'mug-sage', label: 'Stoneware mug, 12 oz, sage glaze, case of 24, for the autumn wholesale catalogue', }, { value: 'mug-sku', label: 'SKU-NW-STONEWARE-MUG-12OZ-SAGE-GLAZE-CASE24-WHOLESALE' }, { value: 'tumbler', label: 'Glass tumbler, 8 oz' },];export default function SelectLongLabels() { return ( <Field> <FieldLabel>Catalogue listing</FieldLabel> <Select defaultValue="mug-sage" items={LISTINGS}> <SelectTrigger> <SelectValue /> </SelectTrigger> <SelectContent> {LISTINGS.map((listing) => ( <SelectItem key={listing.value} value={listing.value}> {listing.label} </SelectItem> ))} </SelectContent> </Select> </Field> );}Loading options
Set loading while options are on their way. The chevron becomes a spinner, the list shows three placeholder rows, and a status row announces the loading message. Here the options are requested the first time the list opens, from onOpenChange in React and (openChange) in Angular.
Slots load from the carrier when the list opens.
import { useState } from 'react';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { Select, SelectContent, SelectItem, type SelectOption, SelectTrigger, SelectValue,} from '@slotted/react/select';const SLOTS: SelectOption[] = [ { value: 'thu-am', label: 'Thursday, 8:00–12:00' }, { value: 'thu-pm', label: 'Thursday, 13:00–17:00' }, { value: 'fri-am', label: 'Friday, 8:00–12:00' },];/** Stands in for a request to the carrier's pickup API. */const fetchSlots = () => new Promise<SelectOption[]>((resolve) => setTimeout(() => resolve(SLOTS), 1500));export default function SelectLoading() { const [slots, setSlots] = useState<SelectOption[]>([]); const [loading, setLoading] = useState(false); const [loaded, setLoaded] = useState(false); const load = async (open: boolean) => { if (!open || loaded || loading) return; setLoading(true); setSlots(await fetchSlots()); setLoading(false); setLoaded(true); }; return ( <Field> <FieldLabel>Pickup slot</FieldLabel> <Select loading={loading} items={slots} messages={{ loading: 'Fetching pickup slots…' }} onOpenChange={(open) => void load(open)} > <SelectTrigger> <SelectValue placeholder="Choose a slot" /> </SelectTrigger> <SelectContent> {slots.map((slot) => ( <SelectItem key={slot.value} value={slot.value}> {slot.label} </SelectItem> ))} </SelectContent> </Select> <FieldDescription>Slots load from the carrier when the list opens.</FieldDescription> </Field> );}Empty list
A select with no options opens onto the empty message instead of an empty box. Write a message that says why the list is empty.
Only orders awaiting receipt are listed.
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { Select, SelectContent, SelectTrigger, SelectValue } from '@slotted/react/select';export default function SelectEmpty() { return ( <Field> <FieldLabel>Purchase order to receive</FieldLabel> <Select messages={{ empty: 'No open purchase orders for Kiln & Co.' }}> <SelectTrigger> <SelectValue placeholder="Choose a purchase order" /> </SelectTrigger> <SelectContent /> </Select> <FieldDescription>Only orders awaiting receipt are listed.</FieldDescription> </Field> );}In a form
In React, name renders a hidden native select, so FormData reads the value and a native reset restores defaultValue. In Angular, the select is a form control: formControlName, formControl and ngModel bind the value, and Validators.required applies to it. Submit without a warehouse to see the error, then reset.
import { useState } from 'react';import type { SubmitEvent } from 'react';import { Button } from '@slotted/react/button';import { Field, FieldError, FieldLabel } from '@slotted/react/field';import { Inline } from '@slotted/react/inline';import { Select, SelectContent, SelectItem, type SelectOption, SelectTrigger, SelectValue,} from '@slotted/react/select';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';const WAREHOUSES: SelectOption[] = [ { value: 'RNO', label: 'Reno, NV' }, { value: 'CMH', label: 'Columbus, OH' }, { value: 'SAV', label: 'Savannah, GA' },];const CARRIERS: SelectOption[] = [ { value: 'ups', label: 'UPS Ground' }, { value: 'fedex', label: 'FedEx Ground' }, { value: 'usps', label: 'USPS Priority Mail' },];const labelOf = (options: SelectOption[], value: FormDataEntryValue | null) => options.find((option) => option.value === value)?.label;export default function SelectForm() { const [missing, setMissing] = useState(false); const [saved, setSaved] = useState<string | null>(null); const submit = (event: SubmitEvent<HTMLFormElement>) => { event.preventDefault(); const data = new FormData(event.currentTarget); const warehouse = labelOf(WAREHOUSES, data.get('warehouse')); const carrier = labelOf(CARRIERS, data.get('carrier')); setMissing(warehouse === undefined); setSaved(warehouse === undefined ? null : `Ships from ${warehouse} by ${carrier}.`); }; const reset = () => { setMissing(false); setSaved(null); }; return ( <form noValidate onSubmit={submit} onReset={reset}> <Stack gap={5}> <Field required invalid={missing ? true : undefined}> <FieldLabel>Fulfilment warehouse</FieldLabel> <Select name="warehouse" items={WAREHOUSES} onValueChange={() => setMissing(false)}> <SelectTrigger> <SelectValue placeholder="Choose a warehouse" /> </SelectTrigger> <SelectContent> {WAREHOUSES.map((warehouse) => ( <SelectItem key={warehouse.value} value={warehouse.value}> {warehouse.label} </SelectItem> ))} </SelectContent> </Select> <FieldError live="polite" reserve> {missing ? 'Choose the warehouse that ships this order.' : ''} </FieldError> </Field> <Field> <FieldLabel>Carrier</FieldLabel> <Select name="carrier" defaultValue="ups" items={CARRIERS}> <SelectTrigger> <SelectValue /> </SelectTrigger> <SelectContent> {CARRIERS.map((carrier) => ( <SelectItem key={carrier.value} value={carrier.value}> {carrier.label} </SelectItem> ))} </SelectContent> </Select> </Field> <Inline gap={3} align="center"> <Button type="submit">Save</Button> <Button type="reset" tone="secondary" variant="outline"> Reset </Button> {saved && ( <Text size="sm" tone="muted"> {saved} </Text> )} </Inline> </Stack> </form> );}Placement and width
The list opens below the control, aligned to its start edge, never narrower than the control and wider when an option needs the room, up to a maximum measure. side="top" opens it above, for a control at the bottom of a screen; align="end" aligns it to the end edge; width="anchor" pins it to the control’s width. fullWidth={false} lets the control keep the width of its widest value instead of filling its container.
import { Inline } from '@slotted/react/inline';import { Select, SelectContent, SelectItem, type SelectOption, SelectTrigger, SelectValue,} from '@slotted/react/select';const PAGE_SIZES: SelectOption[] = [ { value: '25', label: '25 rows' }, { value: '50', label: '50 rows' }, { value: '100', label: '100 rows' },];const SORTS: (SelectOption & { description: string })[] = [ { value: 'newest', label: 'Newest', description: 'Most recent order date first.' }, { value: 'total', label: 'Total', description: 'Largest order total first.' }, { value: 'ship-date', label: 'Ship date', description: 'Earliest promised ship date first.' },];export default function SelectPlacement() { return ( <Inline gap={3} justify="between" align="center"> <Select side="top" fullWidth={false} defaultValue="25" items={PAGE_SIZES}> <SelectTrigger aria-label="Rows per page"> <SelectValue /> </SelectTrigger> <SelectContent> {PAGE_SIZES.map((size) => ( <SelectItem key={size.value} value={size.value}> {size.label} </SelectItem> ))} </SelectContent> </Select> <Select align="end" width="content" fullWidth={false} defaultValue="newest" items={SORTS}> <SelectTrigger aria-label="Sort orders"> <SelectValue /> </SelectTrigger> <SelectContent> {SORTS.map((sort) => ( <SelectItem key={sort.value} value={sort.value} description={sort.description}> {sort.label} </SelectItem> ))} </SelectContent> </Select> </Inline> );}Narrow controls
Under 120 pixels a multiple select shows a count such as 3 selected instead of tags; the list still grows past the narrow control, so labels keep their length.
import { Field, FieldLabel } from '@slotted/react/field';import { Select, SelectContent, SelectItem, type SelectOption, SelectTrigger, SelectValue,} from '@slotted/react/select';import { Stack } from '@slotted/react/stack';const STATUSES: SelectOption[] = [ { value: 'open', label: 'Open' }, { value: 'on-hold', label: 'On hold' }, { value: 'shipped', label: 'Shipped' },];const CHANNELS: SelectOption[] = [ { value: 'web', label: 'Web store' }, { value: 'marketplace', label: 'Marketplace' }, { value: 'wholesale', label: 'Wholesale' }, { value: 'phone', label: 'Phone orders' },];const WAREHOUSES: SelectOption[] = [ { value: 'RNO', label: 'Reno, NV' }, { value: 'CMH', label: 'Columbus, OH' }, { value: 'SAV', label: 'Savannah, GA' },];export default function SelectNarrow() { return ( <Stack gap={4} style={{ inlineSize: '7rem' }}> <Field> <FieldLabel>Status</FieldLabel> <Select size="sm" defaultValue="on-hold" items={STATUSES}> <SelectTrigger> <SelectValue /> </SelectTrigger> <SelectContent> {STATUSES.map((status) => ( <SelectItem key={status.value} value={status.value}> {status.label} </SelectItem> ))} </SelectContent> </Select> </Field> <Field> <FieldLabel>Channels</FieldLabel> <Select size="sm" multiple defaultValue={['web', 'marketplace', 'wholesale']} items={CHANNELS} > <SelectTrigger> <SelectValue /> </SelectTrigger> <SelectContent> {CHANNELS.map((channel) => ( <SelectItem key={channel.value} value={channel.value}> {channel.label} </SelectItem> ))} </SelectContent> </Select> </Field> <Field> <FieldLabel>Warehouse</FieldLabel> <Select size="sm" width="content" defaultValue="CMH" items={WAREHOUSES}> <SelectTrigger> <SelectValue /> </SelectTrigger> <SelectContent> {WAREHOUSES.map((warehouse) => ( <SelectItem key={warehouse.value} value={warehouse.value}> {warehouse.label} </SelectItem> ))} </SelectContent> </Select> </Field> </Stack> );}Defaults for a section
SelectDefaultsProvider in React and provideSelectDefaults in Angular set any axis once for every select under them, such as size, variant and clearable for a filter panel. A value set on one select still wins.
import { Field, FieldLabel } from '@slotted/react/field';import { Select, SelectContent, SelectDefaultsProvider, SelectItem, type SelectOption, SelectTrigger, SelectValue,} from '@slotted/react/select';import { Stack } from '@slotted/react/stack';const OWNERS: SelectOption[] = [ { value: 'avery', label: 'Avery Collins' }, { value: 'kenji', label: 'Kenji Watanabe' }, { value: 'lucia', label: 'Lucía Fernández' },];const SEGMENTS: SelectOption[] = [ { value: 'enterprise', label: 'Enterprise' }, { value: 'wholesale', label: 'Wholesale' }, { value: 'retail', label: 'Retail' },];export default function SelectDefaults() { return ( <SelectDefaultsProvider size="sm" variant="subtle" clearable> <Stack gap={4}> <Field> <FieldLabel>Account owner</FieldLabel> <Select defaultValue="lucia" items={OWNERS}> <SelectTrigger> <SelectValue placeholder="Any owner" /> </SelectTrigger> <SelectContent> {OWNERS.map((owner) => ( <SelectItem key={owner.value} value={owner.value}> {owner.label} </SelectItem> ))} </SelectContent> </Select> </Field> <Field> <FieldLabel>Segment</FieldLabel> <Select defaultValue="wholesale" items={SEGMENTS}> <SelectTrigger> <SelectValue placeholder="Any segment" /> </SelectTrigger> <SelectContent> {SEGMENTS.map((segment) => ( <SelectItem key={segment.value} value={segment.value}> {segment.label} </SelectItem> ))} </SelectContent> </Select> </Field> </Stack> </SelectDefaultsProvider> );}Status filter in a table toolbar
A compact select above a table filters its rows by status. fullWidth={false} keeps the control at the width of its value, align="end" keeps the list inside the edge of the table, and a separator sets the “all” option apart from the statuses.
| Order | Customer | Status | Total |
|---|---|---|---|
| SO-10482 | Harbor & Pine | Open | $1,240.00 |
| SO-10483 | Brightline Studio | On hold | $318.50 |
| SO-10484 | Northgate Labs | Shipped | $2,906.10 |
| SO-10485 | Verde Kitchen | Delayed | $86.00 |
| SO-10486 | Quill & Co. | Shipped | $540.25 |
| SO-10487 | Atlas Freight | Open | $1,912.00 |
import { useState } from 'react';import { Glyph, type GlyphName, Icon } from '@slotted/react/icon';import { Inline } from '@slotted/react/inline';import { Select, SelectContent, SelectItem, type SelectOption, SelectSeparator, SelectTrigger, SelectValue,} from '@slotted/react/select';import { Stack } from '@slotted/react/stack';import { Table, TableBody, TableCell, TableColumnHeader, TableContent, TableHead, TableRow, TableRowHeader,} from '@slotted/react/table';import { Text } from '@slotted/react/typography';const ORDERS = [ { id: 'SO-10482', customer: 'Harbor & Pine', status: 'open', total: '$1,240.00' }, { id: 'SO-10483', customer: 'Brightline Studio', status: 'on-hold', total: '$318.50' }, { id: 'SO-10484', customer: 'Northgate Labs', status: 'shipped', total: '$2,906.10' }, { id: 'SO-10485', customer: 'Verde Kitchen', status: 'delayed', total: '$86.00' }, { id: 'SO-10486', customer: 'Quill & Co.', status: 'shipped', total: '$540.25' }, { id: 'SO-10487', customer: 'Atlas Freight', status: 'open', total: '$1,912.00' },];const STATUSES: (SelectOption & { icon: GlyphName })[] = [ { value: 'open', label: 'Open', icon: 'circle' }, { value: 'on-hold', label: 'On hold', icon: 'clock' }, { value: 'delayed', label: 'Delayed', icon: 'triangle-alert' }, { value: 'shipped', label: 'Shipped', icon: 'circle-check' },];const ALL: SelectOption = { value: 'all', label: 'All statuses' };const OPTIONS = [ALL, ...STATUSES];const labelOf = (status: string) => STATUSES.find((option) => option.value === status)?.label;export default function SelectStatusFilter() { const [status, setStatus] = useState('all'); const rows = status === 'all' ? ORDERS : ORDERS.filter((order) => order.status === status); return ( <Stack gap={3}> <Inline gap={3} justify="between" align="center"> <Text size="sm" tone="muted"> {rows.length} of {ORDERS.length} orders </Text> <Select size="sm" align="end" fullWidth={false} value={status} items={OPTIONS} onValueChange={(next) => setStatus(typeof next === 'string' ? next : 'all')} > <SelectTrigger aria-label="Filter by status"> <SelectValue /> </SelectTrigger> <SelectContent> <SelectItem value={ALL.value}>{ALL.label}</SelectItem> <SelectSeparator /> {STATUSES.map((option) => ( <SelectItem key={option.value} value={option.value} icon={ <Icon> <Glyph name={option.icon} /> </Icon> } > {option.label} </SelectItem> ))} </SelectContent> </Select> </Inline> <Table columns={4}> <TableContent aria-label="Orders"> <TableHead> <TableRow> <TableColumnHeader>Order</TableColumnHeader> <TableColumnHeader>Customer</TableColumnHeader> <TableColumnHeader>Status</TableColumnHeader> <TableColumnHeader numeric>Total</TableColumnHeader> </TableRow> </TableHead> <TableBody> {rows.map((order) => ( <TableRow key={order.id} value={order.id}> <TableRowHeader>{order.id}</TableRowHeader> <TableCell>{order.customer}</TableCell> <TableCell>{labelOf(order.status)}</TableCell> <TableCell numeric>{order.total}</TableCell> </TableRow> ))} </TableBody> </TableContent> </Table> </Stack> );}Accessibility
| Key | Effect | Focus |
|---|---|---|
| ArrowDown | closed, opens the popup onto the selected option or the first; open, moves the highlight to the next option, wrapping only when loop is true | stays on the trigger; the highlight moves and aria-activedescendant follows it |
| ArrowUp | closed, opens the popup onto the last option; open, moves the highlight to the previous option. The example opens onto the first; the last is the mirror of ArrowDown and what every surveyed implementation does, and the departure is recorded in the design. | the trigger |
| Alt+ArrowDown | opens the popup without moving the highlight | the trigger |
| Alt+ArrowUp | commits the highlighted option and closes | the trigger |
| Enter | closed, opens; open, commits the highlighted option and closes | the trigger |
| Space | closed, opens; open and single, commits and closes; open and multiple, toggles the highlighted option and keeps the popup open, which is the listbox pattern's recommended multiple-selection model | the trigger |
| Home | opens if closed, and highlights the first option | the trigger |
| End | opens if closed, and highlights the last option | the trigger |
| PageDown | moves the highlight ten options on, or to the last, and never wraps | the trigger |
| PageUp | moves the highlight ten options back, or to the first, and never wraps | the trigger |
| Printable character | opens if closed, and highlights the first option whose label begins with the sequence typed; the same character repeated cycles through the options beginning with it | the trigger |
| Escape | closes without committing anything | the trigger |
| Tab | commits the highlighted option, closes, and moves on. The example states this and notes it differs from a native select, which closes and does not move. | the next element in the page |
- The trigger is a button with role="combobox", aria-haspopup="listbox" and aria-expanded. The list is a listbox with an option for each row.
- DOM focus stays on the trigger. aria-activedescendant names the highlighted option, which also carries data-current; chosen options carry aria-selected and data-selected. The highlight is where the keyboard is; the selection is what was chosen.
- A disabled option carries aria-disabled, keeps its place in the list, and is skipped by every movement key, typeahead included.
- Inside a field, the trigger carries the field’s control id, so a press on the label focuses it without opening the list. The trigger also takes the label through aria-labelledby, because the name a label gives a button does not reliably reach a button with role="combobox". Outside a field, give SelectTrigger an aria-label.
- With search, the list is a dialog that holds a search field and a listbox, the trigger sets aria-haspopup="dialog", and focus moves into the search field while the list is open.
- Tab chooses the highlighted option and moves focus on, as the APG select-only example specifies; a native select only closes. Escape closes without choosing.
API
Select
Props
searchbooleanDefaultfalse- Puts a search field at the top of the list. The list becomes a dialog, DOM focus moves into the search field, and typeahead turns off.
searchValuestring- The search query. Passing it makes the query controlled. It is never the selection.
defaultSearchValuestringDefault''- The query an uncontrolled search field starts with. Read once.
filter((label: string, query: string) => boolean) | nullDefaultcreateFilter- Decides whether an option matches the query. Unset uses a locale-sensitive contains that ignores case and accents. null turns filtering off, for a list a server has already filtered. A function replaces the comparison.
highlightMatchbooleanDefaulttrue- Whether the span of a label that matched the query is marked.
localestring- The BCP 47 language the default filter compares in. Defaults to the language in force.
searchPropsSelectSearchProps- On SelectContentProps for the search field: every native input attribute, icon, and render to replace the row around the field.
valuestring | string[] | null- The chosen value, or values when multiple is set. Passing it makes the selection controlled.
defaultValuestring | string[] | null- The value an uncontrolled select starts with, and the value a form reset restores. Read once.
openboolean- Whether the list is open. Passing it makes the open state controlled.
defaultOpenbooleanDefaultfalse- Whether an uncontrolled select starts open.
highlightedValuestring | null- The highlighted option. Passing it makes the highlight controlled. The highlight is where the keyboard is, not what is chosen.
defaultHighlightedValuestring | null- The option an uncontrolled highlight starts on.
itemsSelectItems- Values with their labels, read before any option renders. Without it, a held value takes its label from its SelectItem: while the list is closed and a held value has no label, the options render once outside the document and register theirs. Pass items when the options are not rendered until the list opens, such as options fetched on open.
namestring- The name the value is submitted under. It renders a hidden native select, which FormData reads and a form reset restores.
formstring- The id of the form the control belongs to, when it is not the enclosing form.
totalnumber- The size of the whole collection when only part of it is rendered. Options with position then carry aria-setsize and aria-posinset.
size'sm' | 'md' | 'lg'Defaultmd- The step of the control scale. When unset, the select takes the size of its field.
variant'outline' | 'subtle' | 'plain'Defaultoutline- How much frame the control draws: an outline, a filled subtle frame, or plain, with no frame at rest.
side'bottom' | 'top' | 'inline-start' | 'inline-end' | 'left' | 'right'Defaultbottom- The edge of the control the list opens from.
align'start' | 'center' | 'end'Defaultstart- Where the list aligns along that edge.
width'anchor' | 'content'Defaultcontent- content keeps the list at least as wide as the control and widens it to its longest option; anchor pins it to the width of the control.
mount'active' | 'lazy' | 'eager'Defaultactive- When the list exists in the DOM: active while it is open, lazy from the first open on, eager from the start.
strategy'absolute' | 'fixed'Defaultabsolute- The CSS position the positioner gives the list.
multiplebooleanDefaultfalse- Allows several values. The value becomes an array, and the list stays open as options are chosen.
clearablebooleanDefaultfalse- Draws a clear button once something is chosen.
loopbooleanDefaultfalse- Whether the arrow keys wrap from the last option to the first.
typeaheadbooleanDefaulttrue- Whether typing the first letters of a label highlights the matching option. Off while search is set.
typeaheadTimeoutnumberDefault500- How long typed letters keep building one search, in milliseconds.
closeOnSelectbooleanDefaulttrue- Whether choosing an option closes the list. A multiple select stays open regardless.
closeOnEscapebooleanDefaulttrue- Whether Escape closes the list.
closeOnOutsidePressbooleanDefaulttrue- Whether a press outside the list closes it.
flipbooleanDefaulttrue- Whether the list may open on the opposite side when it does not fit.
shiftbooleanDefaulttrue- Whether the list may slide along its edge to stay in view.
hideWhenDetachedbooleanDefaulttrue- Whether the list hides while its control is scrolled out of view.
portalbooleanDefaulttrue- Whether the list renders at the end of the document instead of inside the control.
presentation'popover' | 'auto'Defaultpopover- On Select, SelectDefaultsProviderauto draws the listbox in a bottom sheet under (max-width: 480px) and (pointer: coarse): modal, headed by the field’s label, every option at least --slotted-target-min tall, dismissed by its grip, its scrim, Escape and the platform’s way back, with focus given back to the trigger. A select with search keeps its anchored list, because the on-screen keyboard covers the bottom of the screen.
fullWidthbooleanDefaulttrue- Whether the control fills its container. false sizes it to its widest value.
disabledbooleanDefaultfalse- Disables the control and takes it out of the tab order. When unset, the select takes the state of its field.
readOnlybooleanDefaultfalse- Keeps the value visible and focusable and never opens the list. When unset, the select takes the state of its field.
requiredbooleanDefaultfalse- Sets aria-required, and the required attribute of the hidden native select. When unset, the select takes the state of its field.
invalidbooleanDefaultfalse- Sets aria-invalid and draws the border and the focus ring in the danger tone. When unset, the select takes the state of its field.
loadingbooleanDefaultfalse- Shows the spinner, three placeholder rows and the loading message, and sets aria-busy on the listbox.
sideOffsetnumberDefault4- The gap between the control and the list, in pixels.
alignOffsetnumberDefault0- How far the list shifts along its edge, in pixels.
collisionPaddingnumberDefault8- The distance the list keeps from the edges of the viewport, in pixels.
messagesPartial<SelectMessages>- Replaces any of the phrases the select writes: clear, remove ({label}), summary ({count}), search, searchPlaceholder, count ({count}), empty and loading. Phrases left out come from the language in force.
placeholderReactNode- On SelectValueWhat the control shows while nothing is chosen.
children(values, labels) => ReactNode- On SelectValueA function of the chosen values and their labels that returns what the control shows, in place of the built-in summary.
emptyReactNode- On SelectContentReplaces the empty message for this list.
statusReactNode- On SelectContentReplaces the loading message for this list.
valuestring- On SelectItemThe option’s value: what is submitted and what a change request carries.
disabledbooleanDefaultfalse- On SelectItemAnnounces the option as unavailable, keeps it in the list, and skips it with every movement key.
descriptionReactNode- On SelectItemA second line under the label.
iconReactNode- On SelectItemAn element for the first column, such as an Icon holding a Glyph.
textValuestring- On SelectItemThe text typeahead and the filter match on, when the label is not plain text.
positionnumber- On SelectItemThe option’s one-based place in the whole collection, written as aria-posinset.
labelReactNode- On SelectGroupThe group’s heading, which names the group through aria-labelledby.
Events
| Name | Payload | When |
|---|---|---|
onValueChange | (value: string | string[] | null, request: ChangeRequest) | Before the selection changes. request.reason is pointer, keyboard, clear, select or programmatic, and request.cancel() refuses the change. A form reset reports programmatic. |
onOpenChange | (open: boolean, request: ChangeRequest) | Before the list opens or closes. request.reason tells a choice from a dismissal: select, escape, outsidePress, pointer, keyboard, dismiss, blur or programmatic. |
onHighlightedValueChange | (value: string | null, request: ChangeRequest) | Before the highlight moves. request.reason is pointer, keyboard or programmatic. |
onSearchValueChange | (value: string, request: ChangeRequest) | Before the query changes. request.reason is keyboard for typing, select when an option is chosen while the list stays open, and clear when Escape empties the field or the list empties it as it opens and closes. |
Composition
SelectDefaultsProvidercomponent- On ApplicationSets any axis once for every select below it. The words come from the language in force, set by SlottedProvider. A prop set on one select still wins.
render(props) => ReactNode- On SelectTrigger, SelectContentReplaces the frame of SelectTrigger or the layer of SelectContent. The button and the listbox carry the role and the wiring, so they cannot be replaced.
refRef<SelectHandle>- A handle with focus(), open(), close(), focusSearch() and scrollToKey(value).
refRef<HTMLButtonElement>- On SelectTriggerThe button element.
native propsComponentPropsWithRef<…>- On every partEach part accepts the props of its own element. Your onClick, onKeyDown or aria-label reaches that element, and the select’s own handler runs alongside yours instead of replacing it.
Parts
| Part | Element | Required | Purpose |
|---|---|---|---|
root | div, rendered by SelectTrigger | Yes | The frame, carrying data-ui="select". It draws the border, the shadow, the focus ring and every state, as the text field frame does: a focus ring can only be drawn by an ancestor of the focused element. |
trigger | button with role="combobox" | Yes | The button with role="combobox". It fills the frame, keeps DOM focus for the whole interaction, and carries aria-expanded, aria-controls and aria-activedescendant. Inside a field it carries the field’s control id, so a press on the label focuses it. |
value | span, rendered by SelectValue | Yes | What the control shows: the chosen label, a summary of several, or the placeholder. It carries data-placeholder while nothing is chosen, and data-unmatched when a value has no known label. |
arrow | span | Yes | The chevron, a Glyph inside an Icon box, turned over while the list is open. It sits against the end of the frame and takes no pointer events, so a press on it reaches the trigger. |
busy | span | No | The spinner, drawn in place of the chevron while loading is set. It carries data-ui="spinner", so its ring comes from the spinner stylesheet. |
tags | span | No | The chosen values of a multiple select, one tag each, laid over the trigger rather than inside it: a remove button inside a button would be a control inside a control. Tags that do not fit collapse into one +N tag. |
summary | span | No | The text a multiple select shows under 120 pixels instead of tags, such as ‘3 selected’. It sits inside the value, so it names the trigger whichever of the two is drawn, and it is visually hidden rather than removed while the tags are shown. |
clear | button | No | The clear button. It is drawn while clearable is set and something is chosen, as a sibling of the trigger rather than a child: a focusable element inside a combobox would be a widget inside a widget. |
positioner | div, rendered by SelectContent | Yes | The layer, portalled to the end of the document. It carries data-ui="select" again, because a stylesheet cannot reach the portalled list through the root. The positioner writes its position on this element, and this element scales and fades. |
backdrop | div | No | The scrim over the page while the listbox is a sheet (presentation="auto" on a phone), aria-hidden. A press on it closes the sheet. |
content | div with role="listbox", or role="dialog" under search and in the sheet | Yes | The list surface. It defines the three columns every option uses, is bounded by the height the positioner reports, and scrolls inside it. With search it becomes a dialog that holds the search field and the list, because a listbox may hold only options and groups. |
grip | span | No | The bar at the top of the sheet, aria-hidden. A pull down on it dismisses the sheet; Escape, the scrim and the platform’s way back are the other ways out. |
header | div | No | The row above the list of the sheet, holding its title. |
title | div | No | The heading of the sheet: the label of the control, as a reader hears it. It names the dialog the sheet is. |
search | div, drawn only under search | No | The search row, fixed at the top of the list so it stays in view while the results scroll. The control itself never takes typed text; a value the reader types belongs in a combobox. |
search-icon | span, aria-hidden | No | The magnifier, a Glyph inside an Icon box. searchProps.icon replaces it, and null removes it. |
search-input | input with role="combobox" | No | The search field. It carries aria-controls naming the list, aria-autocomplete="list" and aria-activedescendant, and holds DOM focus while the list is open, because a dialog popup does not support aria-activedescendant on the trigger. |
list | div with role="listbox", drawn only under search | No | The listbox inside the dialog when search is set. It scrolls under the fixed search row and defines the option columns in place of the surface. |
chosen | div, aria-hidden, drawn while several values are chosen | No | Every chosen value of a multiple select, as tags at the top of the list. The control holds one line, so it may show three tags and a count; this band shows them all, wraps, and scrolls after two rows. It is aria-hidden and holds no buttons: without search focus never reaches the list, and with search Tab leaves the control, so a remove button here would answer only the pointer. A value is removed from its option or from its tag in the control. |
match | mark, the match part of the highlight family, whose root sits inside label | No | The span of a label that the query matched, found with the same comparison the filter used. The mark comes from the highlight stylesheet and changes no metric of the surrounding text. |
group | div with role="group" | No | A run of options under a heading. It spans every column and inherits them, so its options align with the options outside it. |
group-label | div | No | The group’s heading. The group references it with aria-labelledby, as the listbox pattern requires of every option group. |
item | div with role="option" | Yes | One option, not a button: an option is not separately focusable, and a button would add a tab stop. data-current marks the highlight and data-selected the chosen option. |
indicator | span | Yes | The check mark in the last column. Its box is reserved whether or not the mark is drawn, so rows do not shift as the highlight moves. |
icon | span | No | The artwork in the first column: an Icon holding a Glyph, or any element. It is separate from the check mark, which says whether the option is chosen. |
label | span | Yes | The option’s text, and the only column that shrinks. It wraps to two lines and then truncates, with the whole text still in the DOM. |
description | span | No | A second line under the label, for detail the label has no room for. |
separator | div with role="separator" | No | A line between two runs of options. It is not focusable and not interactive. |
empty | div | No | The text the list shows when it holds no options: the empty message, or the empty prop of SelectContent. |
status | div with role="status" | No | The live region that announces the loading message, and the number of results while searching. It keeps the width of the list, so nothing shifts when the options arrive. |
placeholder | div | No | Three rows the height of an option, drawn with the skeleton stylesheet while loading is set. They are hidden from assistive technology, because the status row announces the wait. |
Theming
Each token is a CSS custom property: set it in a theme, or on any element to retune every select inside it.
Select tokens
| Token | Default |
|---|---|
--slotted-select-action-active-background | var(--slotted-tone-secondary-subtle-active) |
--slotted-select-action-color | var(--slotted-text-muted, GrayText) |
--slotted-select-action-hover-background | var(--slotted-tone-secondary-subtle-hover) |
--slotted-select-action-size | min(calc(var(--_icon-size) + 2 * var(--slotted-space-2, 0.25rem)), var(--_inner-size)) |
--slotted-select-arrow-color | var(--slotted-text-muted, GrayText) |
--slotted-select-background | var(--slotted-control-surface, Field) |
--slotted-select-border-color | var(--slotted-control-border-color, ButtonBorder) |
--slotted-select-color | var(--slotted-text, CanvasText) |
--slotted-select-content-backdrop-filter | none |
--slotted-select-content-border-color | var(--slotted-border-subtle, #e2e8f0) |
--slotted-select-content-padding-block | var(--slotted-space-2, 0.25rem) |
--slotted-select-content-padding-inline | var(--slotted-space-2, 0.25rem) |
--slotted-select-content-radius | var(--slotted-radius-lg, 8px) |
--slotted-select-content-shadow | var(--slotted-shadow-md) |
--slotted-select-content-text | var(--slotted-text, #0f172a) |
--slotted-select-content-text-muted | var(--slotted-text-muted, #5b6b7f) |
--slotted-select-disabled-background | var(--slotted-disabled-background) |
--slotted-select-disabled-border-color | var(--slotted-disabled-border) |
--slotted-select-disabled-color | var(--slotted-disabled-foreground) |
--slotted-select-group-label-height | calc( var(--_secondary-font-size) * var(--slotted-line-height-sm, 1.45) + 2 * var(--slotted-space-2, 0.25rem) ) |
--slotted-select-highlight | var(--slotted-tone-secondary-subtle-active) |
--slotted-select-highlight-active | var(--slotted-tone-accent-surface) |
--slotted-select-highlight-ring | var(--slotted-tone-accent-border) |
--slotted-select-hover-border-color | var(--slotted-tone-accent-border) |
--slotted-select-icon-size-min | 14px |
--slotted-select-invalid-border-color | var(--slotted-tone-danger-border) |
--slotted-select-invalid-edge-width | var(--slotted-control-invalid-edge-width, 1px) |
--slotted-select-invalid-focus-ring-color | var(--slotted-focus-ring-color-invalid, Highlight) |
--slotted-select-item-radius | max(0px, calc(var(--_radius) - var(--_inset-inline))) |
--slotted-select-measure | 24rem |
--slotted-select-open-border-color | var(--slotted-tone-accent-border) |
--slotted-select-placeholder-color | var(--slotted-text-muted, GrayText) |
--slotted-select-plain-hover-background | var(--slotted-tone-secondary-subtle-hover) |
--slotted-select-radius | var(--slotted-control-radius, 4px) |
--slotted-select-readonly-background | var(--slotted-tone-secondary-subtle-hover) |
--slotted-select-search-icon-color | var(--_muted) |
--slotted-select-selected-color | var(--slotted-tone-accent-text) |
--slotted-select-separator-color | var(--_border-color) |
--slotted-select-shadow | var(--slotted-control-shadow, none) |
--slotted-select-subtle-background | var(--slotted-surface-sunken, Canvas) |
--slotted-select-subtle-border-color | var(--slotted-border-subtle, ButtonBorder) |
--slotted-select-subtle-hover-background | var(--slotted-tone-secondary-subtle-hover) |
--slotted-select-surface | var(--slotted-surface-raised, #ffffff) |
Theme tokens it reads
| Token | Default |
|---|---|
--slotted-border-strong | Set per scheme by the theme |
--slotted-border-subtle | Set per scheme by the theme |
--slotted-border-width-thin | 1px |
--slotted-control-border-color | Set per scheme by the theme |
--slotted-control-border-width | var(--slotted-border-width-thin) |
--slotted-control-focus-ring-offset | var(--slotted-focus-ring-offset) |
--slotted-control-font-family | var(--slotted-font-family-sans) |
--slotted-control-font-size-lg | comfortable 14px · compact 13px · dense 12px |
--slotted-control-font-size-md | comfortable 13px · compact 12px · dense 12px |
--slotted-control-font-size-sm | comfortable 12px · compact 12px · dense 12px |
--slotted-control-gap-lg | comfortable 8px · compact 6px · dense 6px |
--slotted-control-gap-md | comfortable 8px · compact 6px · dense 4px |
--slotted-control-gap-sm | comfortable 6px · compact 4px · dense 4px |
--slotted-control-height-lg | comfortable 38px · compact 32px · dense 30px |
--slotted-control-height-md | comfortable 34px · compact 28px · dense 26px |
--slotted-control-height-sm | comfortable 30px · compact 26px · dense 24px |
--slotted-control-icon-size-lg | comfortable 18px · compact 16px · dense 14px |
--slotted-control-icon-size-md | comfortable 16px · compact 14px · dense 13px |
--slotted-control-icon-size-sm | comfortable 14px · compact 13px · dense 12px |
--slotted-control-inner-size-lg | comfortable 28px · compact 24px · dense 22px |
--slotted-control-inner-size-md | comfortable 24px · compact 20px · dense 18px |
--slotted-control-inner-size-sm | comfortable 22px · compact 18px · dense 16px |
--slotted-control-invalid-edge-width | var(--slotted-border-width-thin) |
--slotted-control-padding-inline-lg | comfortable 16px · compact 12px · dense 10px |
--slotted-control-padding-inline-md | comfortable 13px · compact 10px · dense 8px |
--slotted-control-padding-inline-sm | comfortable 10px · compact 8px · dense 6px |
--slotted-control-radius | var(--slotted-radius-sm) |
--slotted-control-shadow | Set per scheme by the theme |
--slotted-control-shadow-focus-geometry | 0 1px 4px -1px |
--slotted-control-surface | Set per scheme by the theme |
--slotted-control-transition-duration | var(--slotted-duration-short) |
--slotted-control-transition-easing | var(--slotted-easing-standard) |
--slotted-disabled-background | Set per scheme by the theme |
--slotted-disabled-border | Set per scheme by the theme |
--slotted-disabled-foreground | Set per scheme by the theme |
--slotted-drawer-border-color | var(--_border-color) |
--slotted-drawer-radius | var(--_radius) |
--slotted-drawer-resizer-line-color | var(--slotted-border-strong, ButtonBorder) |
--slotted-drawer-scrim | var(--slotted-scrim, Canvas) |
--slotted-drawer-scrim-backdrop-filter | none |
--slotted-drawer-slide-duration | var(--slotted-duration-short) |
--slotted-drawer-slide-easing | var(--slotted-easing-standard) |
--slotted-drawer-slide-exit-duration | var(--slotted-drawer-slide-duration, var(--slotted-duration-short)) |
--slotted-drawer-slide-exit-easing | var(--slotted-easing-exit) |
--slotted-drawer-surface | var(--_surface) |
--slotted-duration-long | 320ms |
--slotted-duration-medium | 200ms |
--slotted-duration-short | 120ms |
--slotted-easing-enter | cubic-bezier(0.05, 0.7, 0.1, 1) |
--slotted-easing-exit | cubic-bezier(0.3, 0, 0.8, 0.15) |
--slotted-easing-standard | cubic-bezier(0.2, 0, 0, 1) |
--slotted-focus-ring-color | Set per scheme by the theme |
--slotted-focus-ring-color-invalid | Set per scheme by the theme |
--slotted-focus-ring-offset | var(--slotted-border-width-thick) |
--slotted-focus-ring-width | var(--slotted-border-width-thick) |
--slotted-font-family-heading | var(--slotted-font-family-sans) |
--slotted-font-family-sans | 'Geist Variable', ui-sans-serif, system-ui, sans-serif |
--slotted-font-size-md | 0.875rem |
--slotted-font-size-xs | 0.75rem |
--slotted-font-weight-medium | 500 |
--slotted-font-weight-semibold | 600 |
--slotted-line-height-md | 1.5 |
--slotted-line-height-sm | 1.45 |
--slotted-overlay-max-block-size | 100vh |
--slotted-radius-lg | 8px |
--slotted-radius-none | 0px |
--slotted-scrim | Set per scheme by the theme |
--slotted-shadow-lg | Set per scheme by the theme |
--slotted-shadow-md | Set per scheme by the theme |
--slotted-space-1 | 0.125rem |
--slotted-space-11 | 3rem |
--slotted-space-2 | 0.25rem |
--slotted-space-3 | 0.375rem |
--slotted-space-5 | 0.75rem |
--slotted-surface-raised | Set per scheme by the theme |
--slotted-surface-sunken | Set per scheme by the theme |
--slotted-target-comfortable | 44px |
--slotted-target-min | 24px |
--slotted-text | Set per scheme by the theme |
--slotted-text-muted | Set per scheme by the theme |
--slotted-tone-accent-border | Set per scheme by the theme |
--slotted-tone-accent-surface | Set per scheme by the theme |
--slotted-tone-accent-text | Set per scheme by the theme |
--slotted-tone-danger-border | Set per scheme by the theme |
--slotted-tone-secondary-subtle-active | Set per scheme by the theme |
--slotted-tone-secondary-subtle-hover | Set per scheme by the theme |
--slotted-z-index-popover | 1100 |