Form & Input
Components for collecting user input with accessibility and validation.
Form & Input
Form and input components help you build accessible, validated forms that integrate seamlessly with react-hook-form and provide a consistent user experience across text inputs, selections, toggles, and date pickers.
Choosing the right input
For text entry: Use Input for short text (names, emails, URLs) and Textarea for longer content (descriptions, comments). Both support placeholder text, icons, and clearable states.
For selections: Use Select for dropdown menus when you have a predefined list of options. Use Radio Group when users must choose exactly one option from a small, visible list. Use Checkbox for multiple independent yes/no choices or multi-select scenarios.
For toggles: Use Switch for boolean settings (on/off, enabled/disabled). Switches are ideal for immediate state changes without form submission.
For dates and times: Use Calendar for inline date selection, or Date Picker for a popover date/datetime selector—both integrate with form validation.
For labels and actions: Pair inputs with Label for accessibility. Use Button to trigger form submissions or secondary actions.
Integration with react-hook-form
All form components work with react-hook-form via standard onChange and value props. Use controller or hook into form state to bind inputs:
import { useForm } from "react-hook-form";
import { Input } from "@loke/design-system/input";
import { Label } from "@loke/design-system/label";
export default function MyForm() {
const { register, handleSubmit } = useForm();
return (
<form onSubmit={handleSubmit(onSubmit)}>
<Label htmlFor="name">Name</Label>
<Input {...register("name")} />
</form>
);
}Components
| Component | Use case | Key features |
|---|---|---|
| Input | Single-line text entry (name, email, search) | Auto icons by type, clearable, focus states |
| Textarea | Multi-line text entry (descriptions, comments) | Resizable, consistent padding, accessible |
| Select | Choose from predefined options | Keyboard navigation, searchable, grouped options |
| Radio Group | Single choice from visible options | Horizontal or vertical layout, keyboard support |
| Checkbox | Multiple independent toggles | Indeterminate state, label support, accessible |
| Switch | Boolean settings (on/off, enable/disable) | Instant feedback, keyboard accessible |
| Calendar | Inline date selection widget | Month/year navigation, accessible navigation |
| Date Picker | Date/datetime selection via popover | Calendar + time picker, timezone aware |
| Label | Accessible form field labels | Required indicator support, focus pairing |
| Button | Trigger actions or submit forms | Multiple variants (primary, destructive, outline) |