Forms
SearchInput
A type="search" field with a search icon and an accessible clear button. Escape clears without closing a surrounding dialog.
import { SearchInput } from '@reactloom/ui';Examples
Basic
Wrap in <search> to expose a search landmark.
import { SearchInput } from '@reactloom/ui';
export default function Example() {
return (
<search style={{ width: '100%', maxWidth: 360 }}>
<SearchInput aria-label="Search customers" placeholder="Search customers" defaultValue="Acme" />
</search>
);
}Live filtering
Announce the result count in a status region.
5 of 5 customers
- Acme Corporation
- Globex
- Initech
- Umbrella Health
- Wayne Enterprises
import { List, SearchInput, Stack, Text } from '@reactloom/ui';
import { useState } from 'react';
const customers = ['Acme Corporation', 'Globex', 'Initech', 'Umbrella Health', 'Wayne Enterprises'];
export default function Example() {
const [query, setQuery] = useState('');
const results = customers.filter((c) => c.toLowerCase().includes(query.toLowerCase()));
return (
<Stack gap="3" style={{ width: '100%', maxWidth: 360 }}>
<SearchInput aria-label="Filter customers" placeholder="Filter customers" value={query} onValueChange={setQuery} />
<Text size="sm" tone="muted" role="status">
{results.length} of {customers.length} customers
</Text>
<List marker="none" spacing="sm">
{results.map((c) => (
<li key={c}>{c}</li>
))}
</List>
</Stack>
);
}API reference
| Prop | Type | Default |
|---|---|---|
onValueChangeCalled on typing and on clear. | (value: string) => void | — |
onClear | () => void | — |
clearLabel | string | 'Clear search' |
…Everything Input accepts (without sections). | InputProps | — |
Customization
Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.
Renders Input, so its hooks apply too.
Slot class names
Add classes to inner parts with classNames (className is shorthand for root): root, label, description, control, input, section, error.
CSS variables
| Variable | Default |
|---|---|
--pl-input-radius | var(--pl-radius-md |
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-radius] | none · sm · md · lg · full |
[data-readonly] | 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-full --pl-radius-lg --pl-radius-md --pl-radius-none --pl-radius-sm --pl-shadow-xs
Accessibility
- The browser’s own clear button is hidden in favour of a labelled one.
- Escape clears the value and stops propagation; a second Escape reaches the dialog.
| Key | Action |
|---|---|
| Escape | Clear the query |
| Tab | Reach the clear button |
Usage guidelines
Do
- Announce result counts politely.
Don’t
- Don’t trigger expensive searches on every keystroke without debouncing.