Forms
Form components and patterns for collecting user input.
<div className="space-y-2"> <Label htmlFor="email">Email</Label> <Input id="email" type="email" placeholder="Enter your email" /> </div>
<Textarea
placeholder="Enter your message..."
rows={5}
/>We'll never share your email with anyone else.
Choose a unique username.
<Field> <FieldLabel>Email</FieldLabel> <FieldDescription>We'll never share your email.</FieldDescription> <Input type="email" placeholder="Enter your email" /> </Field>
Labels: Always provide clear labels for form inputs. Use the Label component and associate it with the input using htmlFor and id attributes.
Placeholders: Use placeholders to provide examples of expected input format, but don't rely on them as the only instruction.
Validation: Provide clear error messages when validation fails. Use the Field component's error prop to display validation errors.
Accessibility: Ensure all form inputs are keyboard accessible and work with screen readers. Use proper ARIA attributes when needed.
Required Fields: Clearly indicate required fields, either with an asterisk (*) or by stating "required" in the label.