Input

updated

You type, it holds. That's the whole deal.

Demo

Open Props in the corner of the example to try variant, size, disabled and aria-invalid. size runs from xs, 28px, to xl, 48px, as tall as the button of the same name, so an input and a button line up in a row; from 768px up xs sets 12px text and xl 16px, below that every size keeps 16px. A disabled input takes its colours from --foreground, like a disabled button. An invalid one turns its line --destructive: when aria-invalid is set, by a Field or by hand, and when the browser's own validation fails after the user has interacted with it, through :user-invalid, so required or type="email" work without any script and an empty form does not start out red.

  • outline: a border
  • soft: a tinted surface, no border
  • subtle: a tinted surface with a border
  • filled: a tinted surface with a line underneath
  • ghost: invisible until hover or focus, for editing in place (like a title)

soft and ghost barely show where the field is. Fine for a search box in a toolbar, but in forms use outline, filled or subtle.

Installation

Usage

<script setup lang="ts">
import { Input } from '@/components/ui/input'

const email = ref('')
</script>

<template>
  <Input v-model="email" type="email" placeholder="Email" />
</template>

Works like a native <input>: every attribute goes straight to it.

Inside a Field it gets its label, error and state for free. On its own, give it a Label or aria-label.

Text is 16px on phones and 14px on desktop. Any smaller, and iOS zooms in on focus.

Want the label inside the input? That's Input Floating.

Input's variants, states and sizes come from Text Control, the frame Textarea, Select, Combobox and the other text fields share, so a field of your own can wear it too.

Examples

File

v-model on a file input gives you the browser's fake path, not the files. For a File or File[] model, drag and drop or a list of what was picked, use File Upload.

File

PNG or JPG, up to 2 MB.

API Reference

class is also accepted and lands on the input, so width classes work.

Data attributes

data-slotAttributesDescription
inputdata-variant, data-sizeThe input. Both attributes are set even when left at their defaults, outline and md.

Changelog

  1. registry 0.22.0

    939037b — A focused text control that is :user-invalid (a required Input, Textarea, InputFloating or PinInput slot left empty) keeps its destructive border; the focus border used to win over it, leaving a primary outer edge around a destructive inner ring.

    0c80a2d — Textarea works its vertical padding out from the control height of its size and its own line height, so a one-row textarea is as tall as the Input of the same size and variant, on narrow screens too (it was 2px taller, 6px below 768px, and the filled variant needs 1px more at the top for its single border). Every textarea loses 1 to 6px of vertical padding. A py-* class on it still wins.

    70d1620 — Colours written inside arbitrary values and variables now resolve where the element sits, so a .dark island (or any subtree that sets a token) gets its own: the filled Input, InputGroup and DatePicker underline, the Table hover, selected and stripe tints, the disabled Slider and Rating fills and the ColorPicker checkerboard read --theme(--color-x) instead of var(--color-x), which Tailwind resolves once on :root. The ripple wave reads --state-pressed where it is pressed (the ripple item no longer pins --kappa-ripple-opacity on :root), so a subtree that changes --state-pressed changes the wave as well as the state layer.

  2. core 0.16.0

    70d1620 — Colours written inside arbitrary values and variables now resolve where the element sits, so a .dark island (or any subtree that sets a token) gets its own: the filled Input, InputGroup and DatePicker underline, the Table hover, selected and stripe tints, the disabled Slider and Rating fills and the ColorPicker checkerboard read --theme(--color-x) instead of var(--color-x), which Tailwind resolves once on :root. The ripple wave reads --state-pressed where it is pressed (the ripple item no longer pins --kappa-ripple-opacity on :root), so a subtree that changes --state-pressed changes the wave as well as the state layer.

  3. registry 0.21.0

    e5495ef — size works the same way everywhere. Every component exports its size type (AlertSize, BadgeSize, CardSize, CheckboxSize, RadioSize, SwitchSize, EmptySize, InputFloatingSize, ItemSize, ListboxSize, SeparatorSize, SliderSize, StepperSize, TabsSize, TextareaSize, TimelineSize) and the props take it without null; Button-based parts take ButtonSize, Input TextControlSize, SelectTrigger SelectSize and Tree TreeSize. ToggleGroup and ToolbarToggleGroup carry data-size on the group as well. Table's row heights moved into tableSize, so a class on DataTable's ui.table overrides --table-row-h at every size, not only at md.

  4. registry 0.18.0

    779955e — Corners come in three roles: rounded-control-*, rounded-surface-* and rounded-item-*, each scaled from --radius and tunable on its own with --control-radius, --surface-radius and --item-radius, on :root or any element. Every component uses them, and cn() merges them, so a class prop still wins.

    - --control-radius was the Input family's frame variable. It now sets every control, and the frames use --frame-radius. - Nested parts no longer turn square at small radii: the InputGroup button, the InputNumber steppers, the TagsInput chips, the DatePicker trigger and the Toast and Tour close buttons. - Menus, lists, pill tabs, the menubar and the toolbar wrap their corners around their items. Pill tabs are rounder (12/8px at md instead of 8/4px), menus and lists grow by up to 2px, and their rows at sizes xs and xl follow their height. Item sm takes 8px instead of 6.4px.

  5. registry 0.13.0

    d9c272f — New DatePicker and DateRangePicker: an InputDate or InputDateRange with a calendar button that opens a Calendar or RangeCalendar in a popover, so a date can be typed or picked into the same v-model. <DatePicker v-model="date" /> renders the whole thing; the parts (DatePickerInput, DatePickerTrigger, DatePickerValue, DatePickerContent, DatePickerCalendar and their range twins) compose a layout of your own, including the shadcn-style outline button with DatePickerTrigger as-child. The field comes in Input's five variants and five sizes, the calendar follows the field's size unless it has its own, and inside an InputGroup the picker takes the group's frame. Picking a day closes the calendar (not when there are time segments, whose typed time a pick keeps), clicking the selected day keeps it, every month draws six weeks so the panel doesn't jump, and Alt+ArrowDown opens it from a segment. Focus on open lands on the selected day, today or the first day you can pick, never on a hidden copy from the neighbouring month. focus and blur fire once for the field, the button and the calendar together, so validate-on-blur doesn't flag the field while the calendar is open. In a Field, a button trigger takes the label, the description and the invalid state, and name submits through a hidden input: YYYY-MM-DD for a date, name[start] and name[end] for a range, with required needing both ends.

    936ab40 — New InputDate and InputDateRange: segmented date fields over Reka UI's DateField and DateRangeField, in Input's five variants and five sizes, with optional time segments, min-value/max-value, is-date-unavailable, loading and Field wiring. Inside an InputGroup they drop their own frame and take the group's variant and size. Pasting an ISO date (2025-03-14, or 2025-03-14T09:30) fills every segment, and Enter submits the form through its submit button, like a native date input. InputDateRange submits name[start] and name[end] as ISO dates, empty until that end is filled, and required needs both.

    InputTime and InputTimeRange get the same fixes. focus and blur now fire once when focus enters or leaves the field, so a form library's validate-on-blur runs; before, they never fired. Clicking the frame outside the segments focuses the first one, Enter submits the form, and changing granularity or hour-cycle after mount rebuilds the segments instead of leaving stale ones. InputTimeRange with name now submits name[start] and name[end] instead of one start - end field, which read undefined - undefined while empty and never failed required. If your server reads the old field, read the two new ones.

    93e57a0 — Every size on the control scale is named xs to xl; default and the bare icon are gone. To move over:

    - Button: size="default" becomes size="md", or leave size out; size="icon" becomes size="icon-md". The full set is xs to xl and icon-xs to icon-xl. Toggle, ToggleGroup, ToggleGroupItem, the Toolbar parts, AlertDialogAction, AlertDialogCancel and ToastAction take the same names; Button, Toggle and ToggleGroup default to md, the Toolbar parts keep sm and ToastAction keeps xs. InputGroupButton keeps its own xs, sm, icon-xs and icon-sm, 24 and 32px to fit inside the group, xs by default. Pagination hands its md to Button as it is. Button, Toggle and ToggleGroupItem set data-variant, data-color and data-size even when you leave them at their defaults. - AlertDialogContent: size="default" becomes size="md", still the default; sm is unchanged. The size option of useConfirm's confirm, alert and prompt takes the same names. - Table and DataTable: density becomes size, data-density becomes data-size, and the TableDensity type is now TableSize. sm, md and lg keep their 36, 44 and 52px rows; xs (28px) and xl (60px) are new, and DataTable's virtual row estimates cover them. The cells' padding above and below the text is now --table-cell-py on the table: 8px as before, 3px at xs. At xs, DataTable's sort buttons and expand and group toggles shrink to fit the row. The table-density example is now table-sizes. - DrawerMenu: size takes xs to xl like Menu and reads the control scale, plus room for a thumb. sm, md and lg keep their 40, 48 and 56px rows, padding and icons; xs is 36px and xl 64px. Overriding a --control-* token on :root now resizes DrawerMenu rows as well. - Select and Combobox: the list opens at the trigger's or anchor's size instead of always at md, so <SelectTrigger size="xl"> opens an xl list. size on SelectContent or ComboboxList picks another. Behind an as-child button, set size on ComboboxAnchor to match the button. The Select list now sets its menu variables on SelectContent instead of its viewport, so a class such as [--menu-item-height:2.5rem] on SelectContent reaches the items. - Input, Textarea, InputFloating, SelectTrigger, ComboboxAnchor and Separator set data-size with the default filled in, and the anchor sets data-variant too. With as-child, the anchor leaves the button's own data-variant and data-size alone.

  6. registry 0.12.0

    c79028b — The control scale is now a set of tokens: --control-height-*, --control-padding-*, --control-icon-* and --control-gap-* for xs to xl, added to :root by the tokens item. Button, Input, InputFloating, Select, Combobox, InputNumber, TagsInput, PinInput, InputTime, InputGroup, Menu, Tabs, ColorPicker and Pagination read them, so overriding one on :root resizes every control of that size.

    Some sizes that strayed from the scale now follow it. Button icons are 20px at lg and xl instead of 16px, and so are the icons of Toggle, ToggleGroup, Toolbar and Pagination at those sizes. The gap between an icon and its label is 6, 8, 8, 10 and 12px from xs to xl, about half the icon, everywhere that has one: Button and the components built on it (where it was 4, 6, 8, 8 and 8px), Menu items and the Select, Combobox and Command lists (8, 10, 12, 12 and 12px), and Tabs triggers (6, 8, 8, 8 and 10px). Inset and checkbox or radio items move their labels with it, so they stay in line with items that have an icon. Everything else keeps its size.

  7. registry 0.10.0

    e03458c — New InputTime and InputTimeRange: segmented time fields over Reka UI's TimeField and TimeRangeField, in Input's five variants and five sizes, with 12- or 24-hour cycles, hour, minute or second granularity, step, min-value/max-value, loading and Field wiring. Inside an InputGroup they drop their own frame and take the group's variant and size.

  8. registry 0.9.0

    3724c06 — New Combobox: a text input that filters a list of options as you type, over Reka UI's Combobox. ComboboxAnchor is Input's frame with its variants and sizes and holds ComboboxInput, ComboboxCancel and the chevron ComboboxTrigger; with as-child the anchor and trigger become a button of your own and the input moves into the list. ComboboxList, ComboboxViewport, ComboboxItem, ComboboxGroup, ComboboxLabel, ComboboxSeparator and ComboboxEmpty take Select's list styles. Single or multiple choice, wired to a surrounding Field.

    0c326fd — New InputNumber: a number field over Reka UI's NumberField with InputNumberInput, InputNumberIncrement and InputNumberDecrement parts inside one frame, in Input's variants and sizes, horizontal or vertical, with min, max, step, formatOptions and locale, wired to a surrounding Field.

    Input now exports textControlFrameVariant, the text control variants for a frame around a control, read from the control's focus, invalid and disabled state. InputGroup draws its frame from it; its radius variable is renamed from --input-group-radius to --control-radius.

    a7aad5f — New TagsInput: tags typed into one text control frame over Reka UI's TagsInput, with TagsInputItem chips drawn as badges, TagsInputItemText, TagsInputItemDelete and TagsInputInput parts, in Input's variants and sizes, with delimiter, paste, max and duplicate handling, wired to a surrounding Field.

  9. registry 0.7.0

    c08ee4f — PinInput: PinInput, PinInputGroup, PinInputSlot and PinInputSeparator over Reka UI's pin input, with the text control variants and sizes of Input, one-time-code autofill on by default, and label, state and error from a surrounding Field.

  10. registry 0.6.0

    5043a12 — InputFloating is the input with a floating label; Input no longer takes label. Replace <Input label="…"> with <InputFloating label="…"> from @/components/ui/input-floating. The wrapper's data-slot is input-floating, the input inside it input-floating-input and the label input-floating-label.