Search field
A search input with a keyboard-reachable clear button and an optional shortcut hint.
Live preview
Source
The exact file rendered in the preview above.
components/demos/search-field.tsx
components/ui/search-field.tsx
Demo source — adapt to your project. Foundry is not published as a package.
Usage
For filtering a visible list. When the interaction should navigate somewhere instead, use the Command menu — a search box that only filters and a search box that navigates are different components.
- Clearing returns focus to the input, so a keyboard user is not dropped at the top of the document.
- The native clear button is suppressed because it is not reachable by keyboard in every engine.
- Show the shortcut hint only where the shortcut actually exists.
Variants and states
Every entry below is a genuine difference in behaviour or layout, and every one of them is visible in the preview above.
- With shortcut hint
- With clear button
- Three sizes
- Disabled
Accessibility
- Naming
- The field needs an `aria-label` or a Field label; a magnifier icon is not a name.
- Clear control
- The clear button is a real button with a visually hidden label.
- Results
- Announce result counts in a polite live region — see the Search page for a working example.
Foundry implements published ARIA patterns and is tested against them. No WCAG certification is claimed — see the accessibility documentation for what is and is not covered.
Related
All componentsCommand menu
A modal command palette: fuzzy-ranked results, grouped output, active-descendant browsing and a keyboard-first footer.
advancedFeatured4 variantsInput
Single-line text entry with leading and trailing slots, three sizes and a shared control surface used by every other text control.
starter7 variantsEmpty state
The three-part empty state — what is missing, why, and the single most likely next action.
starter4 variants