A text input component for forms and user data entry with built-in styling and accessibility features.
Installation#
bunx --bun fabricator-ui@latest add input
Usage#
import { Input } from "@/components/ui/input"<Input />Basic#
Types#
Input is for text: text, email, tel, url, and password and
search below. It never shows the browser's own controls, so every field
looks and moves like the rest of the library in light and dark. Every other
input type has a component of its own, built on the same frame. The preview at the top of this page shows each one:
| Type | Use |
|---|---|
text, email, tel, url | Input |
password | Input in an Input Group with a show button (Password) |
search | An Input Group with a clear button (Search), or Search in toolbars |
number | Number Field |
date | Date Picker |
time | Time Input |
datetime-local | Date Picker with hasTime |
month | Date Picker with granularity="month" |
color | Color Picker |
file | File Upload |
range | Slider |
checkbox, radio | Checkbox, Radio Group |
Password#
Put a password in an Input Group with a button that shows it. The button says
what it does next and reports aria-pressed. The browser's own reveal button
never shows.
Search#
type="search" without the browser's clear button: add your own, which
appears once there's text and puts the focus back in the field.
Sizes#
Inputs take their height, padding and text size from the density. Set
data-density or a density-compact / density-spacious class on the input
or any parent, and the input stays the same height as the buttons beside it.
Field#
Use Field, FieldLabel, and FieldDescription to create an input with a
label and description.
Choose a unique username for your account.
Field Group#
Use FieldGroup to show multiple Field blocks and to build forms.
We'll send updates to this address.
Disabled#
Use the disabled prop to disable the input. To style the disabled state, add the data-disabled attribute to the Field component.
This field is currently disabled.
Invalid#
Use the aria-invalid prop to mark the input as invalid. To style the invalid state, add the data-invalid attribute to the Field component.
This field contains validation errors.
Number#
For numbers, use Number Field: steppers, min and max, keyboard stepping and locale formatting such as currency or percent.
Billing follows the seats in use. Up to 50 on the Team plan.
Date#
For dates, use Date Picker: it opens the library's
calendar, with a column of times beside it when you add hasTime.
The day the work begins.
Time#
For times, use Time Input: type 930 or 9:30 pm,
or pick from a list of times.
Month#
For a month, use Date Picker
with granularity="month": pick from a year of months, or with editable, type
3/2028 or Mar 2028.
Type 3/2028 or Mar 2028, or pick it from the year.
Color#
For colours, use Color Picker: a swatch and hex trigger that opens a saturation area, hue and alpha tracks, and HEX, RGB, HSL and OKLCH fields.
File#
For files, use File Upload. Its field is the size and frame of an Input: drop files on it or choose them, and they show inside it as chips you can remove, on one row that scrolls sideways, so the field keeps its height.
Drop files on the field or choose them. Up to 10 MB each.
Inline#
Use Field with orientation="horizontal" to create an inline input.
Pair with Button to create a search input with a button.
Grid#
Use a grid layout to place multiple inputs side by side.
Required#
Use the required attribute to indicate required inputs.
This field must be filled out.
Badge#
Use Badge in the label to highlight a recommended field.
Input Group#
To add icons, text, or buttons inside an input, use the InputGroup component. See the Input Group component for more examples.
Button Group#
To add buttons to an input, use the ButtonGroup component. See the Button Group component for more examples.
Form#
A full form example with multiple inputs, a select, and a button.
API Reference#
Input#
Input takes every prop of the native input element and passes it through.
| Prop | Type | Default | Description |
|---|---|---|---|
type | string | "text" | A text type: text, email, password, tel, url or search. |
aria-invalid | boolean | - | Turns the frame red. Pair with data-invalid on the Field. |
disabled | boolean | false | Dims the input and blocks interaction. |
className | string | - | Merged last, for layout such as width. |
Accessibility#
- Give every input a visible label with
FieldLabelandhtmlFor, or anaria-labelwhen the label is implied (a search field with an icon). - Describe errors with
FieldErrorinside aFieldthat hasdata-invalid, and setaria-invalidon the input so assistive technology announces it. - Focus shows a firmer neutral ring; the caret marks the focused field.
- Text is 16px below the
mdbreakpoint so iOS doesn't zoom into the field.