Components
Input
Text input field for collecting user information with support for labels, hints, and validation states.
Installation
Usage
import { Input } from "@/registry/core/input";
export default () => <Input label="Email" placeholder="Enter your email" />;Examples
With Label
<Input label="Full Name" placeholder="John Doe" />With Hint
<Input
label="Username"
placeholder="Choose a username"
hint="Must be 3-20 characters long"
/>States
Please enter a valid email address
Controlled
import { useState } from "react";
export default () => {
const [value, setValue] = useState("");
return (
<Input
label="Controlled Input"
value={value}
onChange={e => setValue(e.target.value)}
hint={`${value.length} characters`}
/>
);
};API Reference
Input
Extends input element props.
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | - | Label text above input |
hint | string | - | Helper text below input |
state | 'default', 'error', 'success' | 'default' | Visual state of the input |
className | string | - | Additional CSS classes |
type | string | 'text' | HTML input type |
placeholder | string | - | Placeholder text |
disabled | boolean | false | Disable input interaction |
value | string | - | Controlled value |
onChange | (e: ChangeEvent) => void | - | Change event handler |
Accessibility
- Automatically generates unique IDs if not provided
- Label is properly associated with input via
htmlFor - Keyboard accessible with standard input behavior
- Focus ring provides clear visual feedback with
ring-4style - Disabled state applies to both input and hint text
- Hint text uses semantic color coding for different states
- All standard input HTML attributes are supported
Notes
- The input uses
peerclass to enable styling of the hint text based on input state - Focus ring color matches the state (primary for default, danger for error, success for success)
- Placeholder text uses muted color for better visual hierarchy
- Disabled inputs have reduced opacity and prevent pointer events
- Labels are non-selectable with
select-nonefor better UX