Select
One value from a list of options, in a compact field.
For visual choices, set the option's icon to a React node or a function that
receives the option state and returns a node.
Options retain their labels for keyboard navigation and assistive technology. iconOnly hides
the chosen text when an icon exists; give the trigger a meaningful label
or accessibilityLabel. renderOption replaces the visual row content,
while renderValue(option) replaces the chosen value in the trigger.
Render decorative, non-interactive content in these callbacks.
Use Select for a choice with more options than a SegmentedControl has room for: a filter type, a waveform, an oversampling factor, a routing mode. The field shows the chosen option and opens its list below it, or above when there is more room there.
import { Select } from '@soundor/components';
import { View } from '@soundor/react';
import { useState } from 'react';
import { parameters } from 'soundor:parameters';
import { FilterIcon } from '../filter-icon';
type Oversampling = '1' | '2' | '4' | '8' | '16';
export default function Demo() {
const [oversampling, setOversampling] = useState<Oversampling>('2');
return (
<View style={{ flexDirection: 'row', gap: 16, alignItems: 'flex-start' }}>
{/* Bound: the options, the label and the value are the parameter's. */}
<Select
parameter={parameters.filterType}
hideCheckmark
width={128}
options={parameters.filterType.info.options.map(({ value }) => ({
value,
icon: ({ color }) => <FilterIcon shape={value} color={color} />,
}))}
/>
<Select
label="Oversampling"
description="Higher costs more CPU"
width={120}
value={oversampling}
onChange={setOversampling}
options={[
{ value: '1', label: 'Off' },
{ value: '2', label: '2×' },
{ value: '4', label: '4×' },
{ value: '8', label: '8×' },
{ value: '16', label: '16×', disabled: true, hint: 'Offline only' },
]}
/>
</View>
);
}select.tsx, running in the web runtime.SourceBind it to a parameter
A choice parameter supplies the options, their labels, the label and the value. Choosing an option writes it with undo history, as a SegmentedControl does, and choosing the option already chosen writes nothing. Host automation moves the field like any other change. A parameter with access: 'readOnly' makes the field read-only.
import { Select } from '@soundor/components';
import { parameters } from 'soundor:parameters';
<Select parameter={parameters.filterType} />;For a parameter-bound Select, options can attach icons by value, for example
options={[{ value: 'lowpass', icon: <FilterIcon /> }]}. The parameter still
supplies the choices, labels, and order. value, defaultValue, and onChange
can't be passed with a parameter; use parameter.subscribe to observe changes.
Controlled and uncontrolled
Without a parameter, pass options and either value with onChange, or a defaultValue. The value type is inferred from the options.
const [filter, setFilter] = useState<'lowpass' | 'highpass' | 'bandpass'>(
'lowpass',
);
<Select
label="Filter Type"
value={filter}
onChange={setFilter}
options={[
{ value: 'lowpass', label: 'Low Pass' },
{ value: 'highpass', label: 'High Pass' },
{ value: 'bandpass', label: 'Band Pass' },
]}
/>;With a placeholder and no value, the field shows the placeholder until something is chosen; without one, it starts on the first enabled option. open, defaultOpen and onOpenChange control the list itself.
Disabled options, states and custom rows
Pass state.color to @soundor/icons to use the same foreground as the label.
That color adapts to hovered or keyboard-focused, selected, and disabled rows.
The icon renderer also runs for the chosen value in the trigger and receives the
appropriate color there. For a fixed-color icon, pass a React node as option.icon.
import { Select } from '@soundor/components';
import { WaveSine, WaveSquare } from '@soundor/icons/phosphor';
<Select
label="Waveform"
hideCheckmark
options={[
{
value: 'sine',
label: 'Sine',
icon: ({ color }) => <WaveSine size={16} color={color} />,
},
{
value: 'square',
label: 'Square',
icon: ({ color }) => <WaveSquare size={16} color={color} />,
},
]}
/>;Set hideCheckmark to hide the checkmark and its reserved space. The selected option is still highlighted and announced as checked.
An option with disabled is shown dimmed and skipped by the keyboard, and its hint says why. A disabled field can't be focused; a readOnly one can, and shows its value without opening. size matches the other controls, and renderOption draws a row of your own, such as an icon beside the label. Keep custom rows one line high.
import { Select, type SelectOption } from '@soundor/components';
import {
WaveSawtooth,
WaveSine,
WaveSquare,
WaveTriangle,
Waveform,
} from '@soundor/icons/phosphor';
import { View } from '@soundor/react';
type Wave = 'sine' | 'triangle' | 'saw' | 'square' | 'noise';
const waves: SelectOption<Wave>[] = [
{ value: 'sine', label: 'Sine' },
{ value: 'triangle', label: 'Triangle' },
{ value: 'saw', label: 'Saw' },
{ value: 'square', label: 'Square' },
{
value: 'noise',
label: 'Noise',
disabled: true,
hint: 'In the full version',
},
];
const icons = {
sine: WaveSine,
triangle: WaveTriangle,
saw: WaveSawtooth,
square: WaveSquare,
noise: Waveform,
} satisfies Record<Wave, typeof WaveSine>;
const visualWaves: SelectOption<Wave>[] = waves.map((option) => {
const Icon = icons[option.value];
return { ...option, icon: ({ color }) => <Icon size={16} color={color} /> };
});
export default function Demo() {
return (
<View style={{ gap: 16 }}>
<View style={{ flexDirection: 'row', gap: 16, alignItems: 'flex-start' }}>
<Select
label="Routing"
placeholder="Choose a routing…"
width={150}
options={[
{ value: 'serial', label: 'Serial' },
{ value: 'parallel', label: 'Parallel' },
{ value: 'split', label: 'Mid/Side split' },
]}
/>
{/* Each option drawn with an icon of its own. */}
<Select
label="Waveform"
options={visualWaves}
hideCheckmark
defaultValue="saw"
width={140}
/>
</View>
<View style={{ flexDirection: 'row', gap: 16, alignItems: 'flex-end' }}>
<Select
label="Small"
size="sm"
width={90}
options={waves}
defaultValue="sine"
/>
<Select
label="Read-only"
readOnly
width={110}
options={waves}
defaultValue="square"
/>
<Select
label="Disabled"
disabled
width={110}
options={waves}
defaultValue="triangle"
/>
<Select
label="Large"
size="lg"
width={120}
options={waves}
defaultValue="saw"
/>
</View>
</View>
);
}select-states.tsx, running in the web runtime.SourceIn the dark palette of an application's theme:
import { Select, type SelectOption } from '@soundor/components';
import {
WaveSawtooth,
WaveSine,
WaveSquare,
WaveTriangle,
Waveform,
} from '@soundor/icons/phosphor';
import { View } from '@soundor/react';
type Wave = 'sine' | 'triangle' | 'saw' | 'square' | 'noise';
const waves: SelectOption<Wave>[] = [
{ value: 'sine', label: 'Sine' },
{ value: 'triangle', label: 'Triangle' },
{ value: 'saw', label: 'Saw' },
{ value: 'square', label: 'Square' },
{
value: 'noise',
label: 'Noise',
disabled: true,
hint: 'In the full version',
},
];
const icons = {
sine: WaveSine,
triangle: WaveTriangle,
saw: WaveSawtooth,
square: WaveSquare,
noise: Waveform,
} satisfies Record<Wave, typeof WaveSine>;
const visualWaves: SelectOption<Wave>[] = waves.map((option) => {
const Icon = icons[option.value];
return { ...option, icon: ({ color }) => <Icon size={16} color={color} /> };
});
export default function Demo() {
return (
<View style={{ gap: 16 }}>
<View style={{ flexDirection: 'row', gap: 16, alignItems: 'flex-start' }}>
<Select
label="Routing"
placeholder="Choose a routing…"
width={150}
options={[
{ value: 'serial', label: 'Serial' },
{ value: 'parallel', label: 'Parallel' },
{ value: 'split', label: 'Mid/Side split' },
]}
/>
{/* Each option drawn with an icon of its own. */}
<Select
label="Waveform"
options={visualWaves}
hideCheckmark
defaultValue="saw"
width={140}
/>
</View>
<View style={{ flexDirection: 'row', gap: 16, alignItems: 'flex-end' }}>
<Select
label="Small"
size="sm"
width={90}
options={waves}
defaultValue="sine"
/>
<Select
label="Read-only"
readOnly
width={110}
options={waves}
defaultValue="square"
/>
<Select
label="Disabled"
disabled
width={110}
options={waves}
defaultValue="triangle"
/>
<Select
label="Large"
size="lg"
width={120}
options={waves}
defaultValue="saw"
/>
</View>
</View>
);
}select-states.tsx, running in the web runtime.SourceKeyboard and accessibility
| Input | Does |
|---|---|
Click, Enter, Space, ↓ or ↑ | Open the list, with focus on the chosen option |
↑ / ↓ | Previous / next option, skipping disabled ones; wraps around |
Home / End, Page Up / Page Down | First / last option, or eight at a time |
| A letter | The next option whose label starts with it |
Enter, Space or a click on an option | Choose it and close |
Esc, Tab or a click outside | Close without a change |
Closing always gives focus back to the field. The field is a combobox with its label, its chosen option as its value and whether it is expanded. The list is a menu of menuitems with the chosen one checked: Soundor's accessibility roles have no listbox or option, so the list is presented as a native popup button's menu is. A long list scrolls, and the focused option is kept in view.
Props
See Mixed values for editing multiple items.
Parameter-bound Select
Prop
Type
Standalone Select
Pass options with either value and onChange for a controlled field, or defaultValue to set an uncontrolled field's initial choice.
Prop
Type
SelectOption
Prop
Type
SelectOptionState
The state passed to renderOption and option icon renderers:
Prop
Type