datui
Color scheme

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" with enterKeyHint="search", named by placeholder unless 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 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 `""`.

PropTypeDefaultDescription
afterReactNode—Content after the field, e.g. a "Cancel" button.
beforeReactNode<SearchIcon className="size-icon-sm" aria-hidden />Leading content inside the field.
classNamestring—
clearLabelstringClearAccessible label of the clear button.
findButtonTextstringFindText of the find button.
hideClearButtonbooleanfalse
iconReactNode | ((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.
iconLabelstring—Accessible label of the icon button.
noPaddingbooleanfalseRemoves the outer padding.
onFindButtonClickMouseEventHandler<HTMLElement>—Shows a find button next to the field on compact (desktop) density.
onIconClickMouseEventHandler<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.
valuestring—