Every example is a complete Vue file. Copy it into an app that has the registry installed, or open it in StackBlitz.
A form section
A field set with a legend, then fields 16 px apart. Help text goes under the field; when it must be read before typing, as for the return policy, it goes between the label and the field, wrapped with the label in a FieldContent.
FieldStoreDetails.vue
<script setup lang="ts">
import { Button } from '@/components/ui/button'
import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel, FieldLegend, FieldSet } from '@/components/ui/field'
import { Input } from '@/components/ui/input'
import { Textarea } from '@/components/ui/textarea'
</script>
<template>
<form class="w-full max-w-md" @submit.prevent>
<FieldSet>
<FieldLegend>Store details</FieldLegend>
<FieldDescription>Customers see these on invoices and order emails.</FieldDescription>
<FieldGroup>
<Field>
<FieldLabel for="details-name">Store name</FieldLabel>
<Input id="details-name" autocomplete="organization" />
</Field>
<Field>
<FieldLabel for="details-email">Support email</FieldLabel>
<Input id="details-email" type="email" autocomplete="email" aria-describedby="details-email-help" />
<FieldDescription id="details-email-help">Replies to order emails go here.</FieldDescription>
</Field>
<Field>
<FieldContent>
<FieldLabel for="details-returns">Return policy</FieldLabel>
<FieldDescription id="details-returns-help">One or two sentences. Printed on the packing slip.</FieldDescription>
</FieldContent>
<Textarea id="details-returns" aria-describedby="details-returns-help" />
</Field>
<Field orientation="horizontal">
<Button type="submit">Save store details</Button>
</Field>
</FieldGroup>
</FieldSet>
</form>
</template>Checkboxes with descriptions
orientation="horizontal" puts the checkbox beside its label. The box lines up with the first line of the label.
FieldCheckboxes.vue
<script setup lang="ts">
import { Checkbox } from '@/components/ui/checkbox'
import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel, FieldLegend, FieldSet } from '@/components/ui/field'
const alerts = [
{ id: 'alert-failed', label: 'A sync fails', description: 'Sent at once, with the orders that did not go through.', checked: true },
{ id: 'alert-stock', label: 'Stock runs low', description: 'When a product falls below its reorder point in the ERP.', checked: true },
{ id: 'alert-new-channel', label: 'A sales channel is added', description: 'Once a day, in the morning summary.', checked: false },
]
</script>
<template>
<FieldSet class="w-full max-w-md">
<FieldLegend variant="label">Email me when</FieldLegend>
<FieldGroup data-slot="checkbox-group">
<Field v-for="alert in alerts" :key="alert.id" orientation="horizontal">
<Checkbox :id="alert.id" :default-value="alert.checked" />
<FieldContent>
<FieldLabel :for="alert.id">{{ alert.label }}</FieldLabel>
<FieldDescription>{{ alert.description }}</FieldDescription>
</FieldContent>
</Field>
</FieldGroup>
</FieldSet>
</template>Choice cards
A FieldLabel around a whole field makes a card people can click anywhere. The chosen card takes the selected fill and edge.
FieldChoiceCards.vue
<script setup lang="ts">
import { ref } from 'vue'
import { Field, FieldContent, FieldDescription, FieldLabel, FieldLegend, FieldSet, FieldTitle } from '@/components/ui/field'
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'
// A FieldLabel wrapped around a whole Field is a choice card: the whole card is the click target.
const plans = [
{ value: 'realtime', title: 'As orders come in', description: 'Each order reaches the ERP within a minute.' },
{ value: 'hourly', title: 'Every hour', description: 'Fewer requests to the online store. Good for most stores.' },
{ value: 'nightly', title: 'Every night', description: 'One run at 2:00. Stock may be up to a day out of date.' },
]
const plan = ref('hourly')
</script>
<template>
<FieldSet class="max-w-md">
<FieldLegend variant="label">Sync orders</FieldLegend>
<RadioGroup v-model="plan">
<FieldLabel v-for="option in plans" :key="option.value" :for="`plan-${option.value}`">
<Field orientation="horizontal">
<FieldContent>
<FieldTitle>{{ option.title }}</FieldTitle>
<FieldDescription>{{ option.description }}</FieldDescription>
</FieldContent>
<RadioGroupItem :id="`plan-${option.value}`" :value="option.value" />
</Field>
</FieldLabel>
</RadioGroup>
</FieldSet>
</template>