Unified UI

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 input
pnpm dlx @work-rjkashyap/unified-ui add input
npx @work-rjkashyap/unified-ui add input
bunx @work-rjkashyap/unified-ui add input

If 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-ui
pnpm add @work-rjkashyap/unified-ui
yarn add @work-rjkashyap/unified-ui
bun add @work-rjkashyap/unified-ui

Anatomy

import { Input } from "@work-rjkashyap/unified-ui";

Examples

Variants

Sizes

SizeHeightFont Size
sm32px12px
md36px14px
lg40px14px

With Icons

States

Input Types

With Error Message

Please enter a valid email address.

With Success Message

Username is available!

Combined Features

This email is already taken.

Props

PropTypeDefaultDescription
variant"default" | "error" | "success""default"Visual variant for validation state.
size"sm" | "md" | "lg""md"Size of the input. Matches Button height scale.
iconLeftReactNodeIcon displayed on the left side.
iconRightReactNodeIcon displayed on the right side.
clearablebooleanfalseShow a clear button when the input has a value.
onClear() => voidCallback when the clear button is clicked.
wrapperClassNamestringCSS classes for the outer wrapper (when icons are used).
disabledbooleanfalseDisables the input.
readOnlybooleanfalseMakes the input read-only.
classNamestringAdditional 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-describedby to link the input to error/helper text elements.
  • Disabled inputs set both the disabled attribute and aria-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:

TokenUsage
--borderDefault border color
--dangerError variant border
--successSuccess variant border
--muted-foregroundPlaceholder and icon color
--disabledDisabled background
--disabled-foregroundDisabled text color
--radius-mdBorder radius
--duration-fastTransition speed for focus/hover
--easing-standardEasing curve for transitions

On this page