Search Field
Search Field is a text input for finding things, with a search icon, a clear button and optional shortcut hint. Use it to search or filter a library, a list of spaces or a command menu.
Beta until design confirms the 48px height (Figma's search is 52), the Sub-300 border (Figma Soft-200) and the clear button's focus ring.
Preview
Type, then press Enter to search or Escape to clear. The code follows the controls.
const [query, setQuery] = useState("")
<SearchField
aria-label="Search your library"
placeholder="Search your library"
shape="pill"
value={query}
onValueChange={setQuery}
onSearch={runSearch}
/>Installation
Availability
@nuton/ui and @nuton/tokens are private workspace packages and aren't published yet (D4, D12). Inside the Nuton monorepo, add them as workspace dependencies.
pnpm add @nuton/ui @nuton/tokens @remixicon/reactnpm install @nuton/ui @nuton/tokens @remixicon/reactyarn add @nuton/ui @nuton/tokens @remixicon/reactimport '@nuton/tokens/tokens.css'
import '@nuton/ui/styles.css'Usage
import { SearchField } from '@nuton/ui'
const [query, setQuery] = useState('')
<SearchField
aria-label="Search your library"
placeholder="Search your library"
shape="pill"
value={query}
onValueChange={setQuery}
onSearch={runSearch}
/>- Always give it a name:
aria-label,aria-labelledbyor a Field label. A placeholder is not a name. Without one, the field is named "Search" (labels.search). - Use
onValueChangeto filter as people type, oronSearch(Enter) when each search is expensive. - Wrap a page's main search in
<search>orrole="search"so it is a landmark. - Announce result counts in a
role="status"region near the results. shortcutonly shows the hint. Bind the key in your app and passaria-keyshortcuts.
Variants and sizes
Search Field reuses Input's two sizes and adds a pill shape, used by Figma's page search.
Sizes
<SearchField aria-label="Search" placeholder="Large (48)" />
<SearchField aria-label="Search" placeholder="Small (36)" size="sm" />Shapes
<SearchField aria-label="Search" placeholder="Default shape" />
<SearchField aria-label="Search your library" placeholder="Search your library" shape="pill" />Shortcut hint
<SearchField
aria-label="Search or jump to"
placeholder="Search or jump to"
shortcut="⌘K"
aria-keyshortcuts="Meta+K Control+K"
/>This example binds ⌘K / Ctrl+K on the page, so you can try it.
| Part | Measurement |
|---|---|
| Height | lg 48, sm 36 (Input). Figma's search instances are 52 (code-only choice) |
| Radius | default: 16 (lg) / 8 (sm); pill: full (Figma "Search your library") |
| Inset · gap | 16 (lg) / 12 (sm) · 8 (Input, P1). Figma 20 · 8 |
| Search icon | 24 (lg) / 20 (sm), search-2-line. Figma 20 |
| Text | Paragraph/Small 14; placeholder Text/Sub-600 (C1) |
| Clear button | 20px close icon in a 24 × 24 target |
| Shortcut | Kbd: padding 2/6, radius 4, Subheading/2X Small |
States and interactions
Figma differences (pending a decision)
- Figma's page search is 52 tall with a Soft-200 stroke and 20px insets. Code keeps Input's 48, Sub-300 border and P1 insets so search lines up with other fields.
- Figma has no focus ring on the clear button; code adds one.
- Figma shows an info icon in the Command Menu input. It is not part of Search Field; add a Tooltip button next to the field if needed.
Composition examples
Filter the library as you type
Inside a Field
API reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
value · defaultValue | string | — | Controlled or uncontrolled text. |
onValueChange | (value: string) => void | — | Called on every change, and with "" when cleared. |
onSearch | (value: string) => void | — | Called with the text on Enter. |
onClear | () => void | — | Called after the clear button or Escape empties the field. |
size | 'sm' | 'lg' | 'lg' | Input sizes: 36 or 48 tall. |
shape | 'default' | 'pill' | 'default' | pill = fully rounded (Figma page search). |
shortcut | ReactNode | — | Shortcut hint in a Kbd, e.g. "⌘K". Visual only. |
icon | ReactNode | — | Replaces the search icon. Decorative. |
labels | { search?: string; clear?: string } | { search: 'Search', clear: 'Clear search' } | Fallback name and the clear button name. |
invalid | boolean | — | Error styling. Inside a Field, comes from error. |
disabled · readOnly | boolean | — | Both hide the clear button. |
…input props | InputHTMLAttributes | — | aria-label, placeholder, name, aria-keyshortcuts and others go to the <input type="search">. The ref points at it. |
Accessibility
Keyboard
| Key | Behaviour |
|---|---|
| Enter | Runs onSearch with the current text |
| Escape | Clears the text. When already empty, Escape passes through (e.g. to close a dialog) |
| Tab | Moves to the clear button when there is text, then on |
Screen readers
A native searchbox named by its label. The clear button is named "Clear search" and controls the input. Icons and the shortcut chip are hidden; aria-keyshortcuts announces the shortcut.
Focus
The field shows Input's focus halo. Clearing with the button moves focus back to the input, so it is never lost.
Contrast and colour
Text Strong-950 and placeholder Sub-600 (6.7:1), not Figma's Soft-400 (C1). The empty search icon is decorative.
Touch and pointer
The field is 36 or 48 tall; the clear button target is 24 × 24 (WCAG 2.5.8).
You must: name the field, announce result counts, and bind any shortcut you show.
Figma mapping
| Figma property | Figma values | Code |
|---|---|---|
| State | Default · Hover · Active | Interactive states; Active = focused with text |
| Shortcut | Boolean | shortcut |
| Button | Info icon (empty) · close button (Active) | Clear button when there is text; info icon not included |
| Instance radius 2000 | Library and Spaces search | shape="pill" |
Guidelines and related components
Use Search Field for
- Searching or filtering a library, spaces or lessons
- The input at the top of a command menu
Don't use Search Field for
- Choosing one value from a known list (use Combobox or Select)
- Ordinary text entry (use Input)