Input
A single-line text field. Inside a Field it gets its label, description and error wired for you.
Installation
Or with the shadcn CLI, from the registry:
Usage
Variants
default is a bordered field. filled is a grey well that becomes a bordered field on focus, for dense forms and
settings panels. underline keeps only the bottom border, for inline edits; its focus thickens the line rather than
drawing a ring. Each village draws them its own way: Iwa's filled well keeps its heavy border.
Sizes
sm, default and lg follow the village's control heights, so an input lines up with a button of the same size. On
phones the text stays at 16px whatever the size, so the browser doesn't zoom into the field.
Inside a Field, the input takes the Field's size and variant; its own props win.
Invalid
Inside a Field, the input turns destructive when the field is invalid: from its own validation (required, type="email"),
or from invalid on the Field. Outside a Field, pass aria-invalid.
Disabled
disabled greys the input out and keeps it out of the tab order.
Villages
Height, padding, radius and border come from the village: the input lines up with a button of the same size.
Accessibility
- An
<input>: label it with aFieldLabel(or a<label>), never with the placeholder alone. - Inside a Field, the description and error are linked with
aria-describedby, and the field's validity setsaria-invalid. - The focus ring is the village's and shows for the keyboard and the pointer alike, as text fields expect.
API reference
The props of Base UI's Input, which are those of <input>, plus:
| Prop | Type | Default |
|---|---|---|
variant | "default" | "filled" | "underline" | the Field's, else "default" |
size | "sm" | "default" | "lg" | the Field's, else "default" |
className | string |
size replaces the <input> attribute of the same name; set a width with className. inputVariants({ variant, size })
returns the classes, for an element that should look like an input.