Input Group
Headless Input Group; covers shadcn/ui InputGroup, Ant Design Input.Group, Reka UI.
| Package | @vizejs/ui/input-group |
| Maturity | stable |
| Quality gates | behavior contract, mounted dom, type inference, tree shaking, bundle size, ssr, hydration, dom compile, ssr compile, vapor compile |
| Bundle budget | 6,000 B JS gzip / 0 B CSS gzip |
| Own the source | vize lib pull input-group |
| Requires | — |
| Aliases | input addon, affix input, grouped field |
| Covers | shadcn/ui InputGroup, Ant Design Input.Group, Reka UI |
Minimal setup
Use a Vue 3.5+ project with Vue SFC compilation configured (see Vite+ integration).
vp install @vizejs/ui
Add the public import below to <script setup lang="ts">. Components provide behavior without styles; the preview uses optional Paper styles.
import { InputGroup, InputGroupAddon, InputGroupInput, InputGroupTextarea, InputGroupButton } from "@vizejs/ui/input-group";
Or copy the source into your project with vize lib pull input-group (see Source Distribution).
Try it
This is the basic example maintained with the component source, using the public package imports. The preview adds the optional Paper styles.
Open the interactive example · Styling these components
Copy the example
<!-- Website field with a protocol addon and a copy button. -->
<script setup lang="ts">
import { ref } from "vue";
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "@vizejs/ui/input-group";
const site = ref("vize.dev");
const copies = ref(0);
</script>
<template>
<div>
<InputGroup label="Website">
<InputGroupAddon>https://</InputGroupAddon>
<InputGroupInput v-model="site" type="url" />
<InputGroupButton @press="copies += 1">Copy</InputGroupButton>
</InputGroup>
<output>Copied {{ copies }}</output>
</div>
</template>
One disabled state for the whole field
InputGroup is a named group. Its input, textarea, and button read that
disabled state, so a prefix, the field, and the action stop together. shadcn's
Input Group is a styling composition. This one also owns the disabled contract.
<script setup lang="ts">
import { ref } from "vue";
import {
InputGroup,
InputGroupAddon,
InputGroupButton,
InputGroupInput,
} from "@vizejs/ui/input-group";
const site = ref("vize.dev");
</script>
<template>
<InputGroup label="Website">
<InputGroupAddon>https://</InputGroupAddon>
<InputGroupInput v-model="site" type="url" aria-label="Website URL" />
<InputGroupButton @press="copy">Copy</InputGroupButton>
</InputGroup>
</template>
Parts stay headless. Affix them with CSS on [data-vize-ui="input-group"].
Give each field its own accessible name with aria-label, aria-labelledby,
or an external <label for> and matching id. The group label names the group.
API
InputGroup
Source: src/components/input-group/input-group.vue
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label (required) |
string |
— | Accessible name of the group. |
disabled |
boolean |
false |
Disable every field and button in the group. |
Slots
| Slot | Slot props | Description |
|---|---|---|
default |
— | Renders addons, fields, and buttons. |
InputGroupAddon
Source: src/components/input-group/input-group-addon.vue
Slots
| Slot | Slot props | Description |
|---|---|---|
default |
— | Renders the addon text or icon. |
InputGroupInput
Source: src/components/input-group/input-group-input.vue
Props
| Prop | Type | Default | Description |
|---|---|---|---|
modelValue |
string |
"" |
Current value. |
type |
"text" | "email" | "url" | "search" | "tel" | "password" |
"text" |
Native input type. |
disabled |
boolean |
false |
Disable this field even when the group is enabled. |
name |
string |
undefined |
Native form name. |
Events
| Event | Payload | Description |
|---|---|---|
update:modelValue |
[value: string] |
Fired when the user edits the field. Carries the next string. |
InputGroupTextarea
Source: src/components/input-group/input-group-textarea.vue
Props
| Prop | Type | Default | Description |
|---|---|---|---|
modelValue |
string |
"" |
Current value. |
rows |
number |
2 |
Visible row count. |
disabled |
boolean |
false |
Disable this field even when the group is enabled. |
name |
string |
undefined |
Native form name. |
Events
| Event | Payload | Description |
|---|---|---|
update:modelValue |
[value: string] |
Fired when the user edits the textarea. Carries the next string. |
InputGroupButton
Source: src/components/input-group/input-group-button.vue
Props
| Prop | Type | Default | Description |
|---|---|---|---|
disabled |
boolean |
false |
Disable this button even when the group is enabled. |
Events
| Event | Payload | Description |
|---|---|---|
press |
[event: MouseEvent] |
Fired when the button is activated and the group is available. Carries the click MouseEvent. |
Slots
| Slot | Slot props | Description |
|---|---|---|
default |
— | Renders the button label. |
Behavior
Normative state × input → outcome table for src/components/input-group/input-group.vue,
src/components/input-group/input-group-addon.vue,
src/components/input-group/input-group-input.vue,
src/components/input-group/input-group-textarea.vue, and
src/components/input-group/input-group-button.vue.
Every row is proven by src/components/input-group/tests/behavior.test.ts.
| # | State | Input | Outcome | Proven by |
|---|---|---|---|---|
| I1 | enabled group | render | group, addon, text field, textarea, and button are distinct parts | renders addons, fields, and a button in one group |
| I2 | text field | edit | update:modelValue carries the next string |
emits the next field value |
| I3 | button | click | one press |
emits press from the group button |
| I4 | group disabled | render | the field, textarea, and button are disabled and the group is aria-disabled |
disables every control from the group |