Examples

Client-side filtering

Locale-aware “contains” matching.

Preview

Selected: —

Example.tsx
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.

Preview
Example.tsx
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

Combobox props
PropTypeDefault
optionsrequired
SelectItems—
value / defaultValue
Selected option.
string | null—
onValueChange
(value: string | null) => void—
inputValue / defaultInputValue / onInputChange
The typed text.
string—
filter
false = you filter (e.g. server).
booleantrue
allowsCustomValue
Accept text matching no option.
booleanfalse
loading
booleanfalse
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.

AttributeValues
[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.
Keyboard interactions
KeyAction
TypeFilter
↓ / ↑Open and move
EnterChoose
EscapeClose, 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.