Input

Forms
Core

Form input with validation states, icon support, and multiple sizes. Supports all HTML input types with consistent styling.

Preview

Basic input with placeholder

Variants

Default, filled, and error styles

Best for search bars and embedded inputs

This field is required

Sizes

Small, medium, and large input sizes

With Icons

Add icons to the left or right of the input

Input Types

Different HTML input types

Props

Input component API reference

PropTypeDefaultDescription
variant'default' | 'filled' | 'error''default'Input style variant
inputSize'sm' | 'md' | 'lg''md'Input size
leftIconReactNodeIcon at the start of the input
rightElementReactNodeElement at the end of the input
typestring'text'HTML input type
placeholderstringPlaceholder text
disabledbooleanfalseDisable the input
classNamestringAdditional CSS classes

Size Dimensions

PropTypeDefaultDescription
sm-h-9, px-3, py-2, text-sm, rounded-lg
md-h-11, px-4, py-2.5, text-sm, rounded-lg
lg-h-14, px-4, py-3, text-base, rounded-xl

Usage

Import and implementation example

import { Input } from '@/components/ui/input'
import { Search, Lock, Eye, EyeOff } from 'lucide-react'

export default function Example() {
  const [showPassword, setShowPassword] = useState(false)

  return (
    <>
      {/* Basic input */}
      <Input placeholder="Enter text..." />

      {/* With size */}
      <Input inputSize="sm" placeholder="Small" />
      <Input inputSize="md" placeholder="Medium" />
      <Input inputSize="lg" placeholder="Large" />

      {/* With error state */}
      <Input variant="error" placeholder="Invalid input" />

      {/* With left icon */}
      <Input
        leftIcon={<Search className="w-4 h-4" />}
        placeholder="Search..."
      />

      {/* With right element (toggle) */}
      <Input
        type={showPassword ? 'text' : 'password'}
        leftIcon={<Lock className="w-4 h-4" />}
        rightElement={
          <button onClick={() => setShowPassword(!showPassword)}>
            {showPassword ? <EyeOff className="w-4 h-4" /> : <Eye className="w-4 h-4" />}
          </button>
        }
        placeholder="Password"
      />

      {/* Different types */}
      <Input type="email" placeholder="Email" />
      <Input type="tel" placeholder="Phone" />
      <Input type="number" placeholder="Number" />
    </>
  )
}

Features

Built-in functionality

  • Three variants: Default (white), filled (gray), and error styles
  • Three sizes: Small, medium, and large dimensions
  • Left icon support: Icon positioned at input start
  • Right element support: Custom elements at input end
  • All input types: text, email, password, tel, number, etc.
  • Focus states: Clear focus ring for keyboard navigation
  • Disabled state: Visual disabled indicator with opacity
  • Dark mode: Full dark mode support

Accessibility

Accessibility considerations

ARIA Attributes

Native input element semanticsaria-invalid when in error stateSupports aria-label and aria-labelledby

Keyboard Navigation

KeyAction
TabFocus the input
TypeEnter text

Notes

  • WCAG compliant focus indicators
  • Error state uses both color and border
  • Icons are decorative (aria-hidden)
  • Always pair with label for accessibility