Skip to main content

Input

StorybookView in Storybook

Explore interactive examples and all component variations in our Storybook.

The Input component provides a styled text input field with multiple size variants. Built with accessibility and customization in mind, it supports all standard HTML input attributes and integrates seamlessly with forms.

Basic Usage

Input Sizes

Input Types

Input States

Form Example

File Input

Properties

Input

PropertyTypeDescription
sizing"sm" | "md" | "lg" | "xl" | "2xl"The size variant of the input. Default: "md".
typestringThe HTML input type (text, email, password, etc.).
placeholderstringPlaceholder text displayed when the input is empty.
disabledbooleanWhether the input is disabled.
readOnlybooleanWhether the input is read-only.
requiredbooleanWhether the input is required for form submission.
valuestringThe controlled value of the input.
defaultValuestringThe default value for uncontrolled inputs.
onChange(event: ChangeEvent<HTMLInputElement>) => voidEvent handler called when the input value changes.
onFocus(event: FocusEvent<HTMLInputElement>) => voidEvent handler called when the input receives focus.
onBlur(event: FocusEvent<HTMLInputElement>) => voidEvent handler called when the input loses focus.
classNamestringAdditional CSS classes for custom styling.
idstringThe HTML id attribute for the input.
namestringThe HTML name attribute for the input.
autoCompletestringThe HTML autocomplete attribute.
autoFocusbooleanWhether the input should automatically receive focus.

Size Variants

SizeHeightFont SizePaddingUse Case
sm32px12px8pxCompact forms, tables, tight spaces
md40px14px12pxGeneral use, most forms (default)
lg48px16px16pxProminent forms, landing pages
xl56px18px20pxHero sections, important CTAs
2xl64px20px24pxLarge displays, accessibility needs

Accessibility

The Input component includes comprehensive accessibility features:

  • Keyboard Navigation - Full keyboard support for all interactions
  • Screen Reader Support - Proper labeling and ARIA attributes
  • Focus Management - Clear focus indicators and logical tab order
  • Form Integration - Works seamlessly with form validation
  • Error States - Supports validation styling and error messages
  • Required Fields - Proper indication of required vs optional fields

Common Use Cases

The Input component is perfect for:

  • Contact Forms - Name, email, phone, message fields
  • User Registration - Account creation and profile setup
  • Search Functionality - Search bars and filter inputs
  • Settings Panels - Configuration and preference inputs
  • Data Entry - Forms for creating and editing content
  • Authentication - Login, signup, password reset forms
  • File Uploads - Document and media file selection

Best Practices

  1. Appropriate Labels - Always provide clear, descriptive labels
  2. Placeholder Text - Use helpful placeholder text that doesn't replace labels
  3. Input Types - Use specific input types for better UX (email, tel, url)
  4. Validation - Provide clear validation feedback and error messages
  5. Size Selection - Choose appropriate sizes for the context and importance
  6. Required Fields - Clearly indicate which fields are required
  7. Autocomplete - Use autocomplete attributes for better user experience
  8. Mobile Optimization - Ensure inputs work well on touch devices