Input Group

updated

An input that brought friends. An input or textarea framed together with icons, text and buttons, in all of Input's variants and sizes.

Demo
⌘K

Open Props in the corner of the example to try variant and size. size sets the height, padding and text of the whole group, from xs to xl.

The frame takes all five Input variants.

Installation

Usage

<script setup lang="ts">
import { Search } from '@lucide/vue'

import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from '@/components/ui/input-group'
</script>

<template>
  <InputGroup>
    <InputGroupInput placeholder="Search" />
    <InputGroupAddon>
      <Search />
    </InputGroupAddon>
    <InputGroupAddon align="inline-end">
      <InputGroupButton>Search</InputGroupButton>
    </InputGroupAddon>
  </InputGroup>
</template>

The whole group shares one frame, so focus and error states wrap the icons and buttons too.

Addons go where align says, no matter where they sit in the markup. Click one (anywhere but its buttons), and the input gets focus.

Examples

Addons

Addons
https://
.com
$
USD

Buttons

InputGroupButton is a ghost neutral button by default, in its own sizes: xs and sm, or icon-xs and icon-sm. Its radius is the frame's radius less its distance from the frame's edge, so the corners stay concentric at every size, and at the start or end of the line it sits as far from the side as from the top.

Buttons

Textarea

With InputGroupTextarea and a block-end addon the group becomes a message box; the textarea keeps autoresize and maxrows.

Textarea
280 left

Block start

Block start
greet.ts

In a field

InputGroupInput takes its id, description and invalid state from a surrounding field, like the input.

In a field
kappa-ui.dev/

Letters, numbers and dashes.

API Reference

Data attributes

data-slotAttributesDescription
input-groupdata-variant, data-sizeThe frame.
input-group-addondata-alignIcons, text or buttons around the control.
input-group-buttondata-sizeA button inside an addon.
input-group-control—The input or textarea.
input-group-text—Muted text inside an addon.

CSS variables

VariableDefaultDescription
--input-group-height36pxThe group's height for its size; buttons centre themselves on it.
--frame-radius--radius-control-md at mdThe frame's radius for its size, the same variable Input uses. Buttons take this less their distance from the edge, but never less than half of it. Set --control-radius to change every control at once.
--input-group-padding12pxSide padding of the control and of inline addons, per size.

Changelog

  1. registry 0.24.1

    35a5371 — No component styles an element through a :has() on its parent or group any more. Chrome restyles the whole subtree of every :has() anchor above a node that is added or removed, once some rule puts :has() away from the element it styles: a page wrapped in one such anchor recalculated every element for each list row it mounted. The Dialog, Drawer and Tour headers, the InputGroup and InputNumber insets, the Combobox clear button, the InputFloating notch, a FieldLabel beside a disabled checkbox or radio, the Rating ring, and the Slider and ScrollArea examples now read their neighbours with ~ or a :has() on the element itself. The InputGroup addons fade through a variable that the group sets. FileUpload, Image, Marquee and DataTable mark the state on an element instead: the hidden input's focus, an ImageError inside, keyboard focus, and the body above pinned bottom rows. scripts/has-selectors.test.ts keeps the pattern out.

    useSwipeSnap no longer flushes styles for an instant move that leaves the offset where it is, such as new points at rest.

  2. core 0.17.1

    35a5371 — No component styles an element through a :has() on its parent or group any more. Chrome restyles the whole subtree of every :has() anchor above a node that is added or removed, once some rule puts :has() away from the element it styles: a page wrapped in one such anchor recalculated every element for each list row it mounted. The Dialog, Drawer and Tour headers, the InputGroup and InputNumber insets, the Combobox clear button, the InputFloating notch, a FieldLabel beside a disabled checkbox or radio, the Rating ring, and the Slider and ScrollArea examples now read their neighbours with ~ or a :has() on the element itself. The InputGroup addons fade through a variable that the group sets. FileUpload, Image, Marquee and DataTable mark the state on an element instead: the hidden input's focus, an ImageError inside, keyboard focus, and the body above pinned bottom rows. scripts/has-selectors.test.ts keeps the pattern out.

    useSwipeSnap no longer flushes styles for an instant move that leaves the offset where it is, such as new points at rest.

  3. registry 0.22.0

    4712efa — A Kbd inside a Button wrapped in TooltipTrigger as-child (or any other as-child trigger) keeps the button's colours, and an InputGroupButton wrapped the same way in a block addon keeps the addon's inset. The trigger's data-slot replaces the child's own, as in shadcn, so Kbd now keys on the <button> element (any button tints it, Toggle and Toolbar items included) and the block addon sets the inset on its children.

    7fbf5ee — InputGroupButton inside a disabled Field is disabled, not only faded with its addon: it no longer takes focus or runs its click (InputTimeGroup's "Now" button changed the value of a disabled field). A disabled attribute passed to the button still wins.

    897f2ac — An InputGroup holding a DatePicker or DateRangePicker keeps its frame in the focus colour while the calendar is open, as the picker's own frame does; focus has moved into the calendar, so the group's focus rule no longer matched.

    29fb25c — InputGroupTextarea exposes resize(), like Textarea.

    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.

  4. 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.

  5. registry 0.21.0

    95a0fa1 — Parts follow their root's size through CSS variables instead of the context, so a class on a part wins over the size. PinInput sets --pin-input-slot, TagsInput --tags-input-line and --tags-input-delete, and PinInput, InputNumber, TagsInput and InputGroup set --control-text and --control-text-leading for the field inside (textControlText and textControlInnerText in @/ui/input). NavigationMenu's triggers and links read the --nav-* variables of the menu instead of setting their own, and DataTable's sort buttons and row toggles shrink at xs through the table's variables. PinInput's slots now sit --control-gap-* apart (2px wider at sm, lg and xl); nothing else moves. inputNumberInputVariants, tagsInputInputVariants and tagsInputItemDeleteVariants became the strings inputNumberInput, tagsInputInput and tagsInputItemDelete, inputGroupControlText is gone, and pinInputSlotVariants lost its size key.

  6. 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.

  7. 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.

  8. 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.

  9. registry 0.11.0

    The text control frame of InputGroup, InputNumber, TagsInput and the Combobox anchor ignores what sits in an InputGroupAddon: a disabled checkbox's hidden form input no longer greys the frame or fades the addons, and the browser focusing it after a failed submit no longer lights the frame. A focused control that fails native validation shows the destructive edge again instead of the focus one.

  10. 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.

    e03458c — The text control frame of InputGroup, InputNumber, TagsInput and the Combobox anchor reads focus, invalid and disabled from any input, textarea or role="spinbutton" inside it, not only from a direct child. An InputGroupAddon click focuses the first segment of a segmented control, and addons fade when any input inside the group is disabled.

  11. registry 0.9.0

    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.