Search Field

Loading...

Installation

Add the component with the CLI.

npx shadcn@latest add @intentui/search-field

Composed components

When you install this component via the CLI, it automatically loads all composed components, so you don’t need to add them individually.

Manual installation

Install the dependencies, then copy the component source into your project.

npm install react-aria-components @heroicons/react cn

Anatomy

import { SearchField, SearchInput } from "@/components/ui/search-field"

<SearchField>
  <SearchInput placeholder="Search..." />
</SearchField>

Examples

With label

Add a Label inside SearchField to provide a visible label.

Loading...

Validation

Set isRequired and include FieldError to display a validation message when the form is submitted without a value.

Loading...

Description

Add Description inside SearchField to provide supporting text.

Loading...

Controlled

Pass value and update it with onChange to control the search query.

Loading...

Uncontrolled

Use defaultValue to set the initial value of an uncontrolled field.

Loading...

Readonly

When the search field is set to readonly, it cannot be edited.

Loading...

Disabled

Disable the search field by using the isDisabled prop.

Loading...

Component API

SearchField

SearchField extends the React Aria Components <SearchField> component.

classNamestring

SearchInput

SearchInput extends the React Aria Components <Input> component.

classNamestring

See the React Aria for the full API reference.

Design