Forms
Search
Search field with clear button, trailing icon button, find button and an after slot.
import { Search } from "datui";Playground
<Search placeholder="Search" />Examples
Search with cancel
Accessibility
- The input is
type="search"withenterKeyHint="search", named byplaceholderunless labelled otherwise. - It is not a landmark by default; for the main page search pass
slotProps={{ root: { role: "search" } }}or wrap it in<search>. - Clear button (
clearLabel) and Esc empty the field through a real change event and keep focus in it. - The icon button needs
iconLabel. The find button is shown only at compact (desktop) density.
API
Search
Search field: `type="search"` input with icon, clear button (also Esc), optional trailing icon button and find button. Native `onChange(event)`; clearing dispatches a real change event with `""`.
| Prop | Type | Default | Description |
|---|---|---|---|
| after | ReactNode | — | Content after the field, e.g. a "Cancel" button. |
| before | ReactNode | <SearchIcon className="size-icon-sm" aria-hidden /> | Leading content inside the field. |
| className | string | — | |
| clearLabel | string | Clear | Accessible label of the clear button. |
| findButtonText | string | Find | Text of the find button. |
| hideClearButton | boolean | false | |
| icon | ReactNode | ((render: SearchIconButtonRenderer) => ReactNode) | — | Trailing icon inside the field. A node becomes an icon button when `onIconClick` is set; a function receives a renderer that makes styled icon buttons. |
| iconLabel | string | — | Accessible label of the icon button. |
| noPadding | boolean | false | Removes the outer padding. |
| onFindButtonClick | MouseEventHandler<HTMLElement> | — | Shows a find button next to the field on compact (desktop) density. |
| onIconClick | MouseEventHandler<HTMLButtonElement> | — | |
| slotProps | { root?: (HTMLAttributes<HTMLDivElement> & { ref?: Ref<HTMLDivElement>; }); } | undefined | — | Props for the wrapper. `className` and `style` also go there. Pass `{ root: { role: "search" } }` when this field is the page's search landmark; it is not one by default so several fields can share a page. |
| value | string | — |