Input
Single-line text entry, with room for icons, text, keyboard hints and small buttons inside the field.
Usage
pnpm dlx shadcn@latest add input input-groupThen replace components/ui/input.tsx, input-group.tsx, textarea.tsx and button.tsx (Input group's inline buttons use it) with the Matrix versions. They keep shadcn's API and add the Matrix sizes, fill, focus and error styles.
import { Input } from '@/components/ui/input';
<Input type="email" placeholder="name@example.com" aria-label="Email" />Use Input for a plain field. When the field needs an icon, text, a shortcut or a button inside it, wrap it in an InputGroup.
Variants
Icons inside the field are 16px and use the subtle text color. Clicking an icon or text addon focuses the field; buttons inside it keep their own action.
Sizes
Sizes match Button, so an input and a button of the same size sit level. md is the default in forms and content; sm fits dense toolbars and table filters; lg is for mobile and single focused tasks like onboarding (its 17px text also stops iOS from zooming into the field).
States
Enter a full email address, like name@example.com.
Errors set aria-invalid (coral border) and always come with a message below the field, linked with aria-describedby; in forms, use Field for the label, help text and error. Disabled fields get a muted fill instead of fading out, so the value stays readable. Tab into any field on this page to see the focus ring.
Behavior
Validate when the person leaves the field
Let people finish typing before checking. Showing "invalid email" after three characters is obvious and frustrating; never show an error while they're still in the field.
After the first error, validate as they type
Once a field has shown an error, check it on every change so the error clears the moment it's fixed.
Show "checking" only for real server calls
The spinner appears only while a request is in flight, after the person leaves the field or stops typing for 300ms, never on every keystroke.
Confirm only what's uncertain
Use the checkmark for things that can genuinely fail, like a handle that might be taken. For ordinary fields, no error is enough.
API reference
Input
Prop
Type
All other props go to the native <input>. shadcn's native size attribute is replaced by the Matrix size; set width with className.
InputGroup
Prop
Type
Put one InputGroupInput (or InputGroupTextarea) inside, plus InputGroupAddon before or after it.
InputGroupAddon
Prop
Type
Holds an icon, InputGroupText, a <kbd> or an InputGroupButton.
InputGroupButton
Prop
Type
Guidelines
- Give every field a visible label in sentence case, short and meaningful: "Email address", not "Email Address".
- Write errors that name the exact problem and how to fix it: "Enter a full email address, like name@example.com", not "Invalid input". One error at a time.
- Match the field's width to what goes in it: a code field is narrow, a description field is full width.
- Use the right
type(email,tel,url,number,search) for better mobile keyboards and autofill. - Don't use the placeholder as the only label; it disappears as soon as someone types.
- Don't rely on color alone for errors; always show the message below the field.
- Don't hide an error until the input is fixed.