ComboBox
A single-line text control paired with a native list of suggested values.
CEST · UTC+2
BST · UTC+1
EDT · UTC−4
BRT · UTC−3
JST · UTC+9
IST · UTC+5:30
AEST · UTC+10
WAT · UTC+1
Meeting invitations are sent in this zone. Submitted value: none yet
View code
let committed: string | null = null;
<combobox.Context name="timezone">
<ComboBox
mix={[
is("100%"),
maxIs("24rem"),
combobox.onComboboxChange<HTMLDivElement>((event) => {
committed = event.value;
void handle.update();
}),
]}
>
<Label htmlFor="preview-timezone">Time zone</Label>
<ComboBox.Group>
<ComboBox.Input
id="preview-timezone"
placeholder="Search a city, country or offset"
mix={[comboboxFilter()]}
/>
<ComboBox.Button aria-label="Show every time zone" />
</ComboBox.Group>
<div mix={[floatingSurface(), combobox.popover(), p(1), maxBs("13rem"), overflowY("auto")]}>
<div mix={[vstack({ gap: 0, align: "stretch" }), combobox.list()]}>
{ZONES.map((zone) => (
<Item
key={zone.value}
mix={[
rounded("md"),
cursor("pointer"),
combobox.option({
label: zone.label,
value: zone.value,
searchValue: zone.search,
}),
]}
>
<Item.Content>
<Item.Title>{zone.label}</Item.Title>
<Item.Description>{zone.detail}</Item.Description>
</Item.Content>
</Item>
))}
</div>
</div>
<input type="hidden" mix={[combobox.hiddenInput()]} />
<Description id="preview-timezone-hint">
Meeting invitations are sent in this zone. Submitted value: {committed ?? "none yet"}
</Description>
</ComboBox>
</combobox.Context>Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/uiimport "@sdxc/ui/theme.css";Usage
import { ComboBox } from "@sdxc/ui";Renders a plain host stacking this control's compound parts — a caption,
the ComboBox.Group row, a <datalist> of suggested values, and
supporting copy — in a single column with a small gap between them.
Composition
The parts the component publishes, each a static property of the host.
ComboBoxComboBox.GroupRenders ComboBox's control row: a plain flex host laying ComboBox.Input and ComboBox.Button side by side, the button pulled back over the input's padding so they read as one field.ComboBox.InputRenders ComboBox's text control: an Input that grows to fill its row, reserves inline-end padding for ComboBox.Button's glyph, and carries every Input interaction state unchanged.ComboBox.ButtonRenders ComboBox's trailing disclosure glyph: a native<button>pulled back over ComboBox.Input's padding so it reads as part of the same field, its chevron markedaria-hiddensince it carries no text.
Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
Also accepts everything in TagProps<"div">.
ComboBox.Group
Also accepts everything in TagProps<"div">.
ComboBox.Input
ComboBox.Button
Also accepts everything in Omit<TagProps<"button">, "children">.