Skip to Content

Input

Text input component for collecting user input with various types and states.

Import

import { Input } from 'poodle'

Usage

Basic Input

<Input placeholder="Enter text..." />

Input Types

<Input type="text" placeholder="Text input" /> <Input type="email" placeholder="Email input" /> <Input type="password" placeholder="Password input" /> <Input type="number" placeholder="Number input" />

Sizes

<Input size="sm" placeholder="Small" /> <Input size="md" placeholder="Medium" /> <Input size="lg" placeholder="Large" />

States

<Input placeholder="Default" /> <Input placeholder="Disabled" disabled /> <Input placeholder="Error" error /> <Input value="Success" success readOnly />

With Label

<label htmlFor="email">Email Address</label> <Input id="email" type="email" placeholder="you@example.com" />

With Helper Text

Must be at least 8 characters

<Input type="password" placeholder="Enter password" /> <span className="text-sm text-gray-500"> Must be at least 8 characters </span>

With Error Message

Please enter a valid email

<Input type="email" placeholder="Email" error /> <span className="text-sm text-red-600"> Please enter a valid email </span>

API Reference

PropTypeDefaultDescription
type'text' | 'email' | 'password' | 'number' | ...'text'HTML input type
placeholderstringundefinedPlaceholder text
valuestringundefinedControlled input value
onChange(event: ChangeEvent) => voidundefinedChange event handler
disabledbooleanfalseWhether input is disabled
requiredbooleanfalseWhether input is required
errorbooleanfalseShow error state
size'sm' | 'md' | 'lg''md'Input size

Examples

Controlled Input

function ControlledInput() { const [value, setValue] = useState('') return ( <Input value={value} onChange={(e) => setValue(e.target.value)} placeholder="Type here..." /> ) }

Form Validation

function ValidatedInput() { const [email, setEmail] = useState('') const [error, setError] = useState('') const validate = (value: string) => { if (!value.includes('@')) { setError('Invalid email') } else { setError('') } } return ( <div> <Input type="email" value={email} onChange={(e) => { setEmail(e.target.value) validate(e.target.value) }} error={!!error} /> {error && <span className="text-red-600">{error}</span>} </div> ) }

Search Input

function SearchInput() { const [query, setQuery] = useState('') return ( <div className="relative"> <Input type="search" placeholder="Search..." value={query} onChange={(e) => setQuery(e.target.value)} /> <SearchIcon className="absolute right-3 top-1/2 -translate-y-1/2" /> </div> ) }

Accessibility

  • Semantic <input> element
  • Keyboard accessible
  • ARIA attributes for states
  • Label association
  • Focus indicators

Best Practices

Do ✅

  • Always provide labels for inputs
  • Use appropriate input types
  • Provide clear placeholder text
  • Show validation feedback
  • Use proper autocomplete attributes

Don’t ❌

  • Don’t use placeholder as label
  • Don’t make required fields unclear
  • Don’t hide password requirements
  • Don’t disable copy/paste in password fields
  • Button - Form submit buttons
  • Card - Form containers