Input Group
updatedAn input that brought friends. An input or textarea framed together with icons, text and buttons, in all of Input's variants and sizes.
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
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.
Textarea
With InputGroupTextarea and a block-end addon the group becomes a message box; the textarea keeps autoresize and maxrows.
Block start
In a field
InputGroupInput takes its id, description and invalid state from a surrounding field, like the input.
Letters, numbers and dashes.
API Reference
InputGroup
class is also accepted on every part and merged over its classes with tailwind-merge.
| Prop | Default | Type and description |
|---|---|---|
| variant | "outline" | InputGroupVariantThe frame, with the input's five variants: |
| size | "md" | InputGroupSizeHeight, padding and text size, from 28px for |
| Slot | Scope and description |
|---|---|
| default | {}An |
InputGroupAddon
| Prop | Default | Type and description |
|---|---|---|
| align | "inline-start" | NonNullable<"inline-start" | "inline-end" | "block-start" | "block-end" | null | undefined>
|
| Slot | Scope and description |
|---|---|
| default | {}Icons, |
InputGroupButton
| Prop | Default | Type and description |
|---|---|---|
| variant | "ghost" | "ghost" | "solid" | "soft" | "subtle" | "outline" | "link" | nullButton variant, |
| color | "neutral" | ButtonColor | (string & {})Button colour, |
| size | "xs" | NonNullable<"xs" | "sm" | "icon-xs" | "icon-sm" | null | undefined>
|
| type | "button" | "button" | "submit" | "reset"
|
| Slot | Scope and description |
|---|---|
| default | {}The label or icon. |
InputGroupInput
| Prop | Default | Type and description |
|---|---|---|
| id | — | stringOverrides the |
| defaultValue | — | string | numberThe starting value when |
| disabled | — | booleanDisables the input and fades the group. Also set by a disabled field. |
| required | — | booleanMarks the input required. Also set by a required field. |
| modelValue | — | string | numberThe value, bound with |
| Event | Payload and description |
|---|---|
| update:modelValue | [value: string | number | undefined]Fires as the value changes. |
InputGroupText
| Prop | Default | Type and description |
|---|---|---|
| asChild | — | booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it. |
| as | "span" | AsTag | ComponentThe element or component to render. |
| Slot | Scope and description |
|---|---|
| default | {}Muted text, with icons at 16px. |
InputGroupTextarea
| Prop | Default | Type and description |
|---|---|---|
| modelValue | — | stringThe value, bound with |
| Event | Payload and description |
|---|---|
| update:modelValue | [value: string | undefined]Fires as the value changes. |
| Member | Type and description |
|---|---|
| resize | () => void | undefinedFits the height to the text again, like |
class is also accepted on every part and merged over its classes with tailwind-merge.
Props
- variant
"outline" InputGroupVariantThe frame, with the input's five variants:outline,soft,filled,ghostandsubtle. The group draws it; the control inside has none.- size
"md" InputGroupSizeHeight, padding and text size, from 28px forxsto 48px forxl— the input's sizes. A textarea or a block addon lets the height grow.
Slots
- default
{}AnInputGroupInputorInputGroupTextareaand its addons, in any order: addons place themselves byalign.
Props
- align
"inline-start" NonNullable<"inline-start" | "inline-end" | "block-start" | "block-end" | null | undefined>inline-startorinline-endsit before or after the control on its line;block-startandblock-endtake a full row above or below it. A click on the addon, outside its buttons, focuses the control.
Slots
- default
{}Icons,InputGroupText,InputGroupButtons or aKbd.
Props
- variant
"ghost" "ghost" | "solid" | "soft" | "subtle" | "outline" | "link" | nullButton variant,ghostby default.- color
"neutral" ButtonColor | (string & {})Button colour,neutralby default.- size
"xs" NonNullable<"xs" | "sm" | "icon-xs" | "icon-sm" | null | undefined>xs(24px) orsm(32px), andicon-xsoricon-smfor a square icon button. The radius follows the frame's: it is the frame's radius less the button's distance from its edge, and at the start or end of a line the button sits as far from the side as from the top.- type
"button" "button" | "submit" | "reset"buttonby default, so a button inside a form doesn't submit it.
Slots
- default
{}The label or icon.
Props
- id
stringOverrides theidtaken from a surrounding field.- defaultValue
string | numberThe starting value whenv-modelis not used.- disabled
booleanDisables the input and fades the group. Also set by a disabled field.- required
booleanMarks the input required. Also set by a required field.- modelValue
string | numberThe value, bound withv-model.
Emits
- update:modelValue
[value: string | number | undefined]Fires as the value changes.
Props
- asChild
booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it.- as
"span" AsTag | ComponentThe element or component to render.
Slots
- default
{}Muted text, with icons at 16px.
Props
- modelValue
stringThe value, bound withv-model. The textarea's other props,rows,maxrowsandautoresizeamong them, pass through.
Emits
- update:modelValue
[value: string | undefined]Fires as the value changes.
Exposed
- resize
() => void | undefinedFits the height to the text again, likeTextarea's. Does nothing withoutautoresize.
Data attributes
| data-slot | Attributes | Description |
|---|---|---|
| input-group | data-variant, data-size | The frame. |
| input-group-addon | data-align | Icons, text or buttons around the control. |
| input-group-button | data-size | A button inside an addon. |
| input-group-control | — | The input or textarea. |
| input-group-text | — | Muted text inside an addon. |
CSS variables
| Variable | Default | Description |
|---|---|---|
| --input-group-height | 36px | The group's height for its size; buttons centre themselves on it. |
| --frame-radius | --radius-control-md at md | The 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-padding | 12px | Side padding of the control and of inline addons, per size. |