---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Search input

A search field with the magnifier at its start, for narrowing a list or a page, for React and Tailwind CSS. Free, MIT.

Free. Its export: `SearchInput`.

## Try it

Type to search nine help articles: the list says it is searching for a moment, then shows the articles holding every word you typed. Try “study”, “consent” or a word none holds; Escape empties the field (where the field has a clear button, it does too, and the line says it was cleared). Switch the field’s size.

The search is a timer over nine titles of our own. The field shows no clear button (the browser’s is hidden by the theme); Escape, the browser’s own, empties it.

## When to use

- A search field with the magnifier at its start, for narrowing a list or a page.
- Also called: search box or search bar.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Search input on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing.

```sh
npx shadcn@4.23.1 add @goop/meadow-search-input
```

```text
Add the Goop Search input to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { useState } from 'react';
import { SearchInput } from '@/components/ui/goop/search-input';

function NotesSearch({ onSearch }: { onSearch: (words: string) => void }) {
  const [words, setWords] = useState('');
  return (
    <SearchInput
      label="Search notes"
      placeholder="Search notes"
      value={words}
      onChange={(event) => {
        setWords(event.target.value);
        onSearch(event.target.value);
      }}
    />
  );
}
```

- Fits: board, inbox, list, states (their recipes); frame: sidebar-search.
- height, width, padding, corner, border, background, text, motion: add no class for these.

## API reference

### Options

- `label: ReactNode` — The field's name, read by a screen reader and never shown (required).
- `size?: 'sm' | 'md' | 'lg'` — The bar: `md` (the default) 36 px for a toolbar or a list's header, `sm` 28 px for a sidebar, `lg` 40 px.
- `onClear?: () => void` — Called after the clear button or Escape empties the field (its `onChange` has had the empty value already).
- `clearLabel?: string = 'Clear search'` — The clear button's name, read by a screen reader; `Clear search` by default.
- `type?: 'text' | 'email' | 'password' | 'search' | 'tel' | 'url' = 'search'` — The input's own `type` (the other theme's prop, one component API); left out, `search`.
- `value?: string`
- `defaultValue?: string`
- `onChange?: (event: ChangeEvent<HTMLInputElement>) => void`
- `name?: string`
- `required?: boolean`
- `disabled?: boolean`
- `form?: string`

- Takes every prop of TextInput but variant (its page: text-input.md)

## Keyboard

- Tab: move into the field, then to its clear button while it holds words, then on
- Escape: in a field holding words: empty it, the focus staying; in an empty field: nothing, the key passing on
- Enter / Space: on the clear button: empty the field and put the focus back in it

## Accessibility

- The native element answers the keyboard.
- hover: the browser's own (:hover): write nothing
- focus-visible: the attribute data-focus-visible
- disabled: the prop disabled
- invalid: the attribute aria-invalid
- filled: the attribute data-filled

## Motion

- The part sets its own motion: add no transition or animation of your own.

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

## Related

- [Password field](/themes/meadow/components/password-field): A field for a password with a button that shows or hides the typed words, for sign-in, sign-up and reset forms.
- [Number input](/themes/meadow/components/number-input): A field for a number, an amount or a quantity, typed in the reader's language or stepped with the arrow keys.
- [Input group](/themes/meadow/components/input-group): A text field with an action joined to it inside its fill.
- [OTP input](/themes/meadow/components/otp-input): A row of single-character cells for a one-time code, for a two-step sign-in or confirming an email or a phone.
