Forms
Combobox
A text input with a filtered list of suggestions. Client-side filtering by default; server-side with filter=; free text with allowsCustomValue.
import { Combobox } from '@reactloom/ui';Examples
Client-side filtering
Locale-aware “contains” matching.
Selected: —
import { Combobox, Stack, Text } from '@reactloom/ui';
import { useState } from 'react';
const customers = [
{ value: 'acme', label: 'Acme Corporation' },
{ value: 'globex', label: 'Globex' },
{ value: 'initech', label: 'Initech' },
{ value: 'umbrella', label: 'Umbrella Health' },
{ value: 'wayne', label: 'Wayne Enterprises' },
];
export default function Example() {
const [value, setValue] = useState<string | null>(null);
return (
<Stack gap="2" style={{ width: '100%', maxWidth: 320 }}>
<Combobox label="Customer" options={customers} value={value} onValueChange={setValue} placeholder="Type to search" />
<Text size="sm" tone="muted">Selected: {value ?? '—'}</Text>
</Stack>
);
}Server-side results
Show a loading state and filter on the server.
import { Combobox } from '@reactloom/ui';
import { useEffect, useState } from 'react';
const all = ['Amsterdam', 'Bangalore', 'Berlin', 'Boston', 'Chennai', 'Dublin', 'Lisbon', 'London', 'Mumbai', 'Toronto'];
export default function Example() {
const [query, setQuery] = useState('');
const [loading, setLoading] = useState(false);
const [results, setResults] = useState(all);
useEffect(() => {
// Stand-in for a server request; filter={false} tells Combobox not to filter again.
setLoading(true);
const id = setTimeout(() => {
setResults(all.filter((c) => c.toLowerCase().includes(query.toLowerCase())));
setLoading(false);
}, 400);
return () => clearTimeout(id);
}, [query]);
return (
<div style={{ width: '100%', maxWidth: 320 }}>
<Combobox
label="Office"
options={results.map((c) => ({ value: c.toLowerCase(), label: c }))}
filter={false}
loading={loading}
onInputChange={setQuery}
emptyMessage="No offices match"
/>
</div>
);
}API reference
| Prop | Type | Default |
|---|---|---|
optionsrequired | SelectItems | — |
value / defaultValueSelected option. | string | null | — |
onValueChange | (value: string | null) => void | — |
inputValue / defaultInputValue / onInputChangeThe typed text. | string | — |
filterfalse = you filter (e.g. server). | boolean | true |
allowsCustomValueAccept text matching no option. | boolean | false |
loading | boolean | false |
emptyMessage | ReactNode | 'No results' |
menuTrigger | 'input' | 'focus' | 'manual' | 'input' |
Customization
Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.
State attributes
Target these in your CSS to style states without depending on class names.
| Attribute | Values |
|---|---|
[data-disabled] | present when on |
[data-invalid] | present when on |
[data-open] | present when on |
[data-size] | sm · md · lg |
Theme tokens it reads
--pl-color-bg-subtle --pl-color-bg-surface --pl-color-border-default --pl-color-border-focus --pl-color-border-input --pl-color-danger-border --pl-color-fg-default --pl-color-fg-disabled --pl-color-fg-muted --pl-color-fg-subtle --pl-control-height-lg --pl-control-height-md --pl-control-height-sm --pl-focus-ring-color --pl-focus-ring-width --pl-font-size-lg --pl-font-size-md --pl-font-size-sm --pl-radius-md --pl-radius-sm --pl-shadow-xs
Accessibility
- Focus stays in the input; the active option is announced via aria-activedescendant.
- Result counts are announced politely as you type.
- While open, content outside the combobox is hidden from screen readers.
| Key | Action |
|---|---|
| Type | Filter |
| ↓ / ↑ | Open and move |
| Enter | Choose |
| Escape | Close, then clear |
Usage guidelines
Do
- Use for long lists people search by name.
Don’t
- Don’t require exact typing — matching is case- and accent-insensitive.