compacto-ui

Search documentation

Jump to a page or a component.

Input

Text field with an optional leading icon and an auto-clear button.

Preview

Installation

No install — ask an AI agent to copy this component from registry.json.

import { Input } from "@/components/ui/input";

Notes

  • Fully controlled — it holds no value state of its own.
  • The clear button appears only when there is a value, the field is not disabled, and either onClear or onChange is supplied.
  • Without onClear, clearing writes an empty value to the DOM node and re-fires onChange with that node as event.target, then returns focus.
  • Renders a native <input>, so labelling is yours: aria-label or aria-labelledby.
  • A data-testid lands on the input; the clear button derives ${testId}-clear-button.

Props

The props worth knowing. Everything else passes straight through to the underlying element, including className, which is merged last so it always wins.

PropTypeDefaultDescription
iconLucideIcon—Leading decorative icon. aria-hidden.
iconColorstring—Fixed color for the icon. Unset falls back to the themed dim tone.
onClear() => void—Replaces the default clear behaviour, for when clearing must reset state onChange cannot reach.
clearLabelstring"Clear"Accessible name for the clear button. Pass a translated string from the call site.