---
title: "Search Field"
description: "A search field with a key to focus it (/ or ⌘K), a clear button, and a spinner while results load. Escape clears it, and it waits for a pause in typing."
url: https://gelatinui.com/components/search-field
markdown_url: https://gelatinui.com/components/search-field.md
access: free
install: "npx shadcn@latest add @gelatin-ui/search-field"
registry_item: https://gelatinui.com/r/search-field.json
version: "2026-11-08"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Search Field

> A search field with a key to focus it (/ or ⌘K), a clear button, and a spinner while results load. Escape clears it, and it waits for a pause in typing.

Page: https://gelatinui.com/components/search-field

## When to use it

Best for: A search query in one line, with a shortcut, a clear button, and a debounce.

- Use it above a list or a table.
- Set `shortcut` to focus it from anywhere.
- Set `debounce` to run `onSearch` after typing stops.

## When not to use it

- For a list of choices in a popup, use a [Combobox](https://gelatinui.com/components/combobox.md).
- For a plain text field, use an [Input](https://gelatinui.com/components/input.md).

## Notes for agents

- It needs a name: `aria-label`, or a `FieldLabel` in a `Field`.
- `busy` swaps the search icon for a spinner.

## Anatomy

```text
SearchField
```

## API reference

### SearchField

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `rounded` | `"default" \| "full"` | "default" |  |
| `size` | `"default" \| "lg" \| "sm" \| "xs"` | "default" |  |
| `variant` | `"dashed" \| "default"` | "default" |  |
| `value` | `string` |  | The text, when the parent owns it. |
| `defaultValue` | `string` |  | The first text, when the field owns it. Default "". |
| `onValueChange` | `function` |  | Each change of the text, at once (each key, a clear). |
| `onSearch` | `function` |  | Run the search: on Enter, on a clear (with ""), and after `debounce` ms of no typing. |
| `onClear` | `function` |  | The text was cleared (the clear button, or Escape with text). |
| `debounce` | `number` |  | Ms of no typing before `onSearch` runs. `undefined` (the default): typing does not search, only Enter and a clear do. `0`: each change searches. |
| `shortcut` | `false \| SearchFieldShortcut` | false | The key that focuses and selects the field from anywhere. Default `false` (none). |
| `className` | `string` |  | Classes of the frame (the InputGroup), for its width. |
| `busy` | `boolean` | false | The field waits for results: the spinner takes the place of the search icon, and the input is `aria-busy`. |
| `labels` | `Partial<typeof SEARCH_FIELD_LABELS>` |  | The words (`SEARCH_FIELD_LABELS`). Keep the object stable. |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| SearchField | `search-field` | `data-size` |  | `motion-timing` |

## Usage

Import Search Field and compose its parts.

```tsx title="search-field.tsx"
import { SearchField } from "@/components/ui/search-field";

export function SearchFieldDemo() {
  return (
    <SearchField
      aria-label="Search"
      defaultValue="quarterly report"
      className="w-72 max-w-full"
    />
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/search-field
```

It adds 22 registry items: 19 files, 3056 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@phosphor-icons/react`, `@tanstack/react-hotkeys`, `clsx`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Input Group](https://gelatinui.com/components/input-group.md)
- [Kbd](https://gelatinui.com/components/kbd.md)
- [Spinner](https://gelatinui.com/components/spinner.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Animated Close Icon](https://gelatinui.com/components/animated-close-icon.md)
- [Input Group](https://gelatinui.com/components/input-group.md)
- [Kbd](https://gelatinui.com/components/kbd.md)
- [Spinner](https://gelatinui.com/components/spinner.md)
- [Command](https://gelatinui.com/components/command.md): Pick Command for a search field over a list of commands, such as a command palette.
- [Autocomplete](https://gelatinui.com/components/autocomplete.md): Pick Autocomplete when the field must suggest values in a popup while people type.

## Keyboard

| Keys | Action |
| --- | --- |
| Escape | Clears the text. |
| Enter | Runs `onSearch` at once. |
| /, Mod K | Moves the focus to the field, when you set `shortcut`. |

## Accessibility

It is a real input with the search role.

The clear button has a name, and it comes from `labels`.

## Motion

| Part | Motion |
| --- | --- |
| Clear | fade · 150ms · the clear button shows when there is text |
