Input
A flexible text input component with support for labels, helper text, icons, addons, and validation states.
Import
import { Input } from "@raydenui/ui";
import type { InputProps, InputSize } from "@raydenui/ui";Usage
Basic
<Input placeholder="Enter your name" />With Label
<Input label="Email" placeholder="you@example.com" />With Helper Text
Must be at least 8 characters
<Input label="Password" type="password" helperText="Must be at least 8 characters" />Sizes
<Input size="xs" placeholder="Extra small" />
<Input size="sm" placeholder="Small (default)" />
<Input size="md" placeholder="Medium" />
<Input size="lg" placeholder="Large" />Validation States
Email is available
Please enter a valid email
// Success
<Input
label="Email"
success="Email is available"
defaultValue="user@example.com"
/>
// Error
<Input
label="Email"
error="Please enter a valid email"
defaultValue="invalid-email"
/>With Icons
// Leading icon
<Input
leadingIcon="search"
placeholder="Search..."
/>
// Trailing icon
<Input
trailingIcon="x"
placeholder="Clearable input"
/>
// Both icons
<Input
leadingIcon="mail"
trailingIcon="check"
placeholder="Email"
/>With Text Addon
.com
<Input addonRight=".com" placeholder="domain" />With Leading/Trailing Addons
Leading and trailing addons render as separate bordered sections.
https://
$
USD
// Leading addon (e.g., dropdown)
<Input
leadingAddon={<span>https://</span>}
placeholder="example.com"
/>
// Trailing addon (e.g., button)
<Input
trailingAddon={<Button size="sm">Search</Button>}
placeholder="Search..."
/>
// Both addons
<Input
leadingAddon={<span>$</span>}
trailingAddon={<span>USD</span>}
placeholder="0.00"
/>Read-only and Disabled
// Read-only
<Input label="ID" value="USR-12345" readOnly />
// Disabled
<Input label="Email" placeholder="Enter email" disabled />Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | "xs" | "sm" | "md" | "lg" | "sm" | Input size variant |
label | string | — | Label text above the input |
helperText | string | — | Helper text below the input |
error | string | boolean | — | Error message or boolean |
success | string | boolean | — | Success message or boolean |
leadingIcon | ReactNode | IconName | — | Icon on the left |
trailingIcon | ReactNode | IconName | — | Icon on the right |
addonRight | string | — | Text addon on the right |
leadingAddon | ReactNode | — | Separated section before input |
trailingAddon | ReactNode | — | Separated section after input |
wrapperClassName | string | — | Class for the wrapper div |
className | string | — | Class for the input element |
The component also accepts all native <input> HTML attributes.
Accessibility
- Uses semantic
<input>element - Labels are properly associated via
htmlFor - Helper text linked via
aria-describedby - Error states announced via
aria-invalid - Required state indicated via
aria-required
Last updated on