Input
A text field with its label, hint and error.
Examples
Playground
States
Every state side by side. Hover and focus are forced, so they can be reviewed without a pointer.
Content
A hint, the required mark, adornments, and a value longer than the field.
In context
A form row: an Input, a Select and an md Button share one height, label style and corner.
Install
npx shadcn add @hipuku/inputUsage
import { Input } from '@/components/haus/components/Input'
<Input label="Email" type="email" hint="We never share it." value={email} onChange={e => setEmail(e.target.value)} />API
Input also takes the input's own attributes and forwards its ref to the input. className lands
on the root and controlClassName on the field's box.
| Prop | Type | Description |
|---|---|---|
label | string | |
hint | string | |
error | string | |
prefix | React.ReactNode | |
suffix | React.ReactNode | |
required | boolean | |
controlClassName | string | Lands on the field itself rather than the root, for the cases where the
control needs styling and the block around it does not. Ruling B5 put
className on the root of every component; this is the named second
target that rule asks for rather than redirecting the one everyone
expects. |
States
hint is a line of help under the field. error marks it invalid and shows above the hint, which
stays, because it is what the user needs to fix the field. prefix and suffix hold a unit or a
symbol inside the field. An Input stands level with a default Button beside it.
required marks the field and sets aria-required, not the browser's own required, so the
browser shows no validation bubble of its own. Show the problem with error.
Accessibility
- A native input with a real
label: clicking the label focuses the field. - The hint and error are read as the field's description. An error is announced when it appears.
errorsetsaria-invalid, and is not shown by colour alone.