Examples
Basic entry
A named single-line value with a native input type.
Basic Input
import { Input } from "@phuctech/ui/components/input";
export function Example() {
return <Input aria-label="Workspace name" placeholder="PhucTech workspace" />;
}
Density
Use sm, default, or lg to match the surrounding form rhythm.
Input size comparison
import { Input } from "@phuctech/ui/components/input";
export function Example() {
return <Input aria-label="Workspace name" placeholder="PhucTech workspace" />;
}Controlled value
Feature state owns the value when validation or submission needs it.
Type to test the controlled value.
Controlled Input value
import { Input } from "@phuctech/ui/components/input";
export function Example() {
return <Input aria-label="Workspace name" placeholder="PhucTech workspace" />;
}Uncontrolled value
Use defaultValue for a local native form value that does not need mirrored state.
Uncontrolled Input with default value
import { Input } from "@phuctech/ui/components/input";
export function Example() {
return <Input aria-label="Workspace name" placeholder="PhucTech workspace" />;
}Disabled, read-only, and invalid
State styling stays paired with a readable label and explanation.
Invalid, read-only, and disabled Input states
import { Input } from "@phuctech/ui/components/input";
export function Example() {
return <Input aria-label="Workspace name" placeholder="PhucTech workspace" />;
}When to use
Use Input for short values such as names, URLs, search terms, and identifiers. Use a textarea for multi-line text, a select for a constrained choice, and a specialized control only when the interaction requires it.
Usage
import { Input } from "@phuctech/ui/components/input";
export function Example() {
return <Input aria-label="Workspace name" placeholder="PhucTech workspace" />;
}
For a form, wrap Input in Field. Use a controlled value when the surrounding feature needs to validate or submit it; use defaultValue for an uncontrolled form field.
States
API
Tokens
Accessibility
- Every Input needs a visible label or an explicit accessible name.
- Use native input types, autocomplete hints, and spellcheck settings when they improve completion.
- Do not communicate an error through border color alone; provide text and connect it with
aria-describedby.
Do and don’t
Use Field for the label and error, then keep the Input responsible for value and native control behavior.
Use placeholder text as the only label, switch controlled/uncontrolled models, or hide the error message.
Related
- Field supplies the label, description, and error relationship.
- Button handles submit and cancel actions around a form.
- Accessibility documents the focus and validation contract.