Every example is a complete Vue file. Copy it into an app that has the registry installed, or open it in StackBlitz. The whole box takes the focus edge when the field inside has focus.
Search with an icon and a count
The icon is decoration. The field is named with aria-label, and the count is read after it.
InputGroupSearch.vue
<script setup lang="ts">
import { Search } from '@lucide/vue'
import { computed, ref } from 'vue'
import { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText } from '@/components/ui/input-group'
const orders = ['SO-1042 Corner Hardware', 'SO-1043 Green Leaf Grocery', 'SO-1044 Corner Hardware', 'SO-1045 Blue Harbor Books']
const query = ref('')
const count = computed(() => orders.filter(order => order.toLowerCase().includes(query.value.toLowerCase())).length)
</script>
<template>
<InputGroup class="max-w-sm">
<InputGroupAddon>
<Search aria-hidden="true" />
</InputGroupAddon>
<InputGroupInput v-model="query" type="search" aria-label="Search orders" aria-describedby="order-count" />
<InputGroupAddon align="inline-end">
<InputGroupText id="order-count" aria-live="polite">{{ count }} orders</InputGroupText>
</InputGroupAddon>
</InputGroup>
</template>Fixed text before and after
Letters, numbers and hyphens only.
InputGroupAddress.vue
<script setup lang="ts">
import { Field, FieldDescription, FieldLabel } from '@/components/ui/field'
import { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText } from '@/components/ui/input-group'
</script>
<template>
<Field class="max-w-md">
<FieldLabel for="store-address">Store address</FieldLabel>
<InputGroup>
<InputGroupAddon>
<InputGroupText>https://</InputGroupText>
</InputGroupAddon>
<InputGroupInput id="store-address" default-value="corner-hardware" aria-describedby="store-address-help" />
<InputGroupAddon align="inline-end">
<InputGroupText>.shop.example</InputGroupText>
</InputGroupAddon>
</InputGroup>
<FieldDescription id="store-address-help">Letters, numbers and hyphens only.</FieldDescription>
</Field>
</template>A button inside: show the password
An icon-only button, named by its tooltip.
The password of the ERP user the sync signs in as.
InputGroupPassword.vue
<script setup lang="ts">
import { Eye, EyeOff } from '@lucide/vue'
import { ref } from 'vue'
import { Field, FieldDescription, FieldLabel } from '@/components/ui/field'
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from '@/components/ui/input-group'
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'
// The icon button is named by its tooltip (relationship="label") and says what it will do next.
const visible = ref(false)
</script>
<template>
<Field class="max-w-sm">
<FieldLabel for="erp-password">ERP password</FieldLabel>
<InputGroup>
<InputGroupInput id="erp-password" :type="visible ? 'text' : 'password'" autocomplete="current-password" aria-describedby="erp-password-help" />
<InputGroupAddon align="inline-end">
<TooltipProvider>
<Tooltip relationship="label">
<TooltipTrigger as-child>
<InputGroupButton size="icon-xs" @click="visible = !visible">
<EyeOff v-if="visible" />
<Eye v-else />
</InputGroupButton>
</TooltipTrigger>
<TooltipContent>{{ visible ? 'Hide password' : 'Show password' }}</TooltipContent>
</Tooltip>
</TooltipProvider>
</InputGroupAddon>
</InputGroup>
<FieldDescription id="erp-password-help">The password of the ERP user the sync signs in as.</FieldDescription>
</Field>
</template>Text area with a count and an action
align="block-end" puts the addon under the text.
InputGroupReply.vue
<script setup lang="ts">
import { Send } from '@lucide/vue'
import { computed, ref } from 'vue'
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupText, InputGroupTextarea } from '@/components/ui/input-group'
const reply = ref('')
const left = computed(() => 500 - reply.value.length)
</script>
<template>
<InputGroup class="max-w-md">
<InputGroupTextarea v-model="reply" maxlength="500" aria-label="Reply to the customer" aria-describedby="reply-left" />
<InputGroupAddon align="block-end">
<InputGroupText id="reply-left">{{ left }} characters left</InputGroupText>
<InputGroupButton variant="default" class="ml-auto">
<Send />Send reply
</InputGroupButton>
</InputGroupAddon>
</InputGroup>
</template>