Input
A text field with a floating label. The label rests inside the field and moves up when you focus or type, so the field stays compact and is never left without a name.
Install
npx shadcn@latest add @nelumbo/inputVariants
Filled is the default: a soft container that draws an underline on focus. Outlined puts the label in a gap in the top border. Click into the fields.
filled
We send the receipt here.
Enter the full number, with country code.
Placeholder shows on focus.
outlined
We send the receipt here.
Enter the full number, with country code.
Placeholder shows on focus.
Sizes
Default is 56px. Use sm (48px) for dense forms and settings panels, and xs (36px) for toolbars and filters. xs drops the floating label: the label becomes the placeholder and still names the field for assistive tech. The icons and padding scale with it.
filled
outlined
Trailing actions
Put an Icon Button in the trailing slot to reveal a password or clear a search. Use size sm so it fits the field.
Without a label
Leave out label for search bars and inline edits. The placeholder then stays visible. Give the field an aria-label instead.
On any background
The gap in the outlined border is cut out of the border, not painted over it, so the background shows through.
With the line
Filled fields have no line at rest; focus and error draw one. Set indicator to keep the thin line under the container at all times.
Usage
import { Input } from "@/components/ui/input"<Input label="Email" type="email" icon="mail" description="We send the receipt here." /><Input variant="outlined" label="Phone" error="Enter the full number." />// react-hook-form: ref and field props go to the <input><Input label="Name" {...register("name")} error={errors.name?.message} />Props
className goes to the wrapper; all other props and the ref go to the <input>.
| Prop | Type | Default | Notes |
|---|---|---|---|
label | string | Floating label. Leave out for search bars (then set aria-label) | |
variant | "filled" | "outlined" | "filled" | |
indicator | boolean | false | Filled only: show the thin line under the container at rest. It always appears on focus and error. |
size | "default" | "sm" | "xs" | "default" | 56px, 48px, or 36px compact with the label as placeholder |
icon | IconName | Leading Material Symbol | |
trailing | ReactNode | Trailing slot, e.g. an Icon Button with size sm | |
description | ReactNode | Help text, linked with aria-describedby | |
error | ReactNode | boolean | Marks the field invalid; a message replaces the description | |
placeholder | string | With a label, shown only while focused |