Skip to main content
Tw Twintrinsic
  • Getting Started
  • Components
  • Theming
  • Completion
Examples
Data Dashboard Game Map
Core
App
Layout
Accordion AccordionItem Card Container Panel Separator Sidebar Splitter
Navigation
AppHeader BottomBar Breadcrumb BreadcrumbItem Menu MenuItem Tabs Tab TabList TabPanel TreeMenu
Data Display
Avatar AvatarGroup Badge Carousel CarouselItem Chip ChipGroup CodeBlock CodeBlockSpeed CodeEditor DataTable Map Progress Skeleton Table TableBody TableCell TableHead TableHeader TableRow Tag TagGroup Timeline TimelineItem Tooltip Tree TreeNode
Metrics
DonutChart PieChart LineChart BarChart HorizontalBarChart AreaChart StatsCard MetricGrid KPICard GaugeChart ProgressMetric MetricTrend
Form
AutoComplete Button ButtonGroup Calendar Checkbox ColorPicker Combobox Dropdown FileUpload FloatLabel Form FormField Input InputSwitch InvalidState Knob ListInput Listbox NumberInput Radio RadioGroup Rating Select SelectGroup Slider Switch TextInput Textarea
Feedback
Modal Stepper StepperStep Toast
Utility
Icon Lazy LazyPanel Masonry ThemeToggle

Input

The Input component is a versatile form control that supports validation, floating labels, input masking, and icon integration. It's built with accessibility in mind and follows modern web best practices.

Examples

Basic Usage

<Input label="Username" placeholder="Enter username" />

With Icons

<Input
  label="Password"
  type="password"
  leftIcon="lock"
  rightIcon="eye"
  placeholder="Enter password"
/>

Floating Label

<Input
  label="Email"
  type="email"
  floating={true}
  placeholder="Enter email"
/>

Validation and Error States

<Input
  label="Email"
  type="email"
  value="invalid-email"
  error="Please enter a valid email address"
  required
/>

Input Masking

<Input
  label="Phone"
  type="tel"
  mask="(###) ###-####"
  placeholder="(555) 555-5555"
/>

Props

PropTypeDefaultDescription
labelstringRequiredLabel text for the input
typestringtextHTML input type (text, email, password, etc.)
valuestring""Input value
placeholderstring""Placeholder text
namestring""Name attribute for the input
idstringautoUnique identifier for the input
disabledbooleanfalseWhether the input is disabled
requiredbooleanfalseWhether the input is required
floatingbooleanfalseWhether to use floating labels
readonlybooleanfalseWhether the input is readonly
errorstring""Error message to display
helpTextstring""Help text to display below input
leftIconstring""Name of icon to display on the left
rightIconstring""Name of icon to display on the right
classstring""Additional CSS classes
maskstring""Input mask pattern (# for numbers, A for letters, * for any)

Events

EventDetail TypeDescription
oninput{ value: string }Fired when input value changes
onfocusvoidFired when input gains focus
onblurvoidFired when input loses focus
onleftIconClickvoidFired when left icon is clicked
onrightIconClickvoidFired when right icon is clicked

Accessibility

The Input component follows WAI-ARIA guidelines for form fields:

  • Labels are properly associated with inputs using for attributes
  • Required fields are marked with both visual and ARIA indicators
  • Error messages are linked to inputs using aria-describedby
  • Invalid states are indicated with aria-invalid
  • Icons are properly hidden from screen readers when decorative

Input Masking

The mask pattern uses the following special characters:

  • # - Matches a number (0-9)
  • A - Matches a letter (a-z, A-Z)
  • * - Matches any character
  • Any other character is treated as a literal

Example patterns:

  • Phone: (###) ###-####
  • Date: ##/##/####
  • Credit Card: #### #### #### ####
  • Serial Number: AA-##-**