Search Field
A Search Field component is a UI element that provides a text input specifically designed for search functionality. It includes a built-in search icon and clear button, allowing users to quickly enter, modify, and clear search queries.
Rendered live, with the same build of the library you install.
Query: Empty
SearchField.tsx
import { useState } from 'react';import { NSearchField } from '@nayan-ui/react';const SearchField = () => {const [query, setQuery] = useState('');return (<div><div className="space-y-4 max-w-sm"><NSearchField value={query} onChange={setQuery} placeholder="Search components..." /><p className="text-sm text-muted">Query: {query || 'Empty'}</p></div></div>);};export default SearchField;
| Name | Type | Default | Details |
|---|---|---|---|
| value | string | Optional | Controlled value. |
| defaultValue | string | Optional | Default value. |
| onChange | (value: string) => void | Optional | Callback when value changes. |
| onSubmit | (value: string) => void | Optional | Callback on submit. |
| onClear | () => void | Optional | Callback when cleared. |
| placeholder | string | 'Search...' | Placeholder text. |
| disabled | boolean | false | Disables the search field. |
| isInvalid | boolean | false | Marks as invalid. |
| variant | 'primary' | 'secondary' | 'primary' | Visual variant. |
| fullWidth | boolean | false | Full width mode. |
| className | string | ' ' | Additional CSS classes. |
Other components solving nearby problems.