Input
A text input component with icons, clearable option, and validation states.
Overview
The Input component is a production-ready text input for capturing user data. It supports 3 validation variants, 3 sizes, leading/trailing icons, a clearable option, and all standard HTML input types.
Installation
Install the component via the CLI in one command.
npx @work-rjkashyap/unified-ui add inputpnpm dlx @work-rjkashyap/unified-ui add inputnpx @work-rjkashyap/unified-ui add inputbunx @work-rjkashyap/unified-ui add inputIf you haven't initialized your project yet, run npx @work-rjkashyap/unified-ui init first. See the CLI docs for details.
Or install the full package
Use this approach if you prefer to install the entire design system as a dependency instead of copying individual components.
npm install @work-rjkashyap/unified-uipnpm add @work-rjkashyap/unified-uiyarn add @work-rjkashyap/unified-uibun add @work-rjkashyap/unified-uiAnatomy
import { Input } from "@work-rjkashyap/unified-ui";Examples
Variants
Sizes
| Size | Height | Font Size |
|---|---|---|
sm | 32px | 12px |
md | 36px | 14px |
lg | 40px | 14px |
With Icons
States
Input Types
With Error Message
With Success Message
Combined Features
Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "error" | "success" | "default" | Visual variant for validation state. |
size | "sm" | "md" | "lg" | "md" | Size of the input. Matches Button height scale. |
iconLeft | ReactNode | — | Icon displayed on the left side. |
iconRight | ReactNode | — | Icon displayed on the right side. |
clearable | boolean | false | Show a clear button when the input has a value. |
onClear | () => void | — | Callback when the clear button is clicked. |
wrapperClassName | string | — | CSS classes for the outer wrapper (when icons are used). |
disabled | boolean | false | Disables the input. |
readOnly | boolean | false | Makes the input read-only. |
className | string | — | Additional CSS classes for the input element. |
All standard <input> HTML attributes are also supported.
Accessibility
Always pair error/success variants with descriptive text linked via
aria-describedby for screen reader users.
- Error variant automatically sets
aria-invalid="true"unless explicitly overridden. - Use
aria-describedbyto link the input to error/helper text elements. - Disabled inputs set both the
disabledattribute andaria-disabled. - The clear button has
aria-label="Clear input"and is excluded from tab order (tabIndex={-1}). - Focus ring is visible on keyboard navigation only (
focus-visible). - Icons are marked
aria-hidden="true"since they are decorative.
Design Tokens
The Input uses the following design system tokens:
| Token | Usage |
|---|---|
--border | Default border color |
--danger | Error variant border |
--success | Success variant border |
--muted-foreground | Placeholder and icon color |
--disabled | Disabled background |
--disabled-foreground | Disabled text color |
--radius-md | Border radius |
--duration-fast | Transition speed for focus/hover |
--easing-standard | Easing curve for transitions |
Button
The primary interactive element for triggering actions. Supports 4 variants, 3 sizes, loading state, icon support, and polymorphic rendering.
Input Group
A composed input field with prefix/suffix icons, left/right text addons, and inline action buttons. Fully styled and size-consistent with the Input component.