On this page

Label

Live examples of Label, with the exact Vue file that renders each one.

Every example is a complete Vue file. Copy it into an app that has the registry installed, or open it in StackBlitz. Click a label to reach its control.

Above a field

for matches the field’s id. Clicking the label puts focus in the field.

LabelWithInput.vue
<script setup lang="ts">
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
</script>

<template>
  <div class="grid w-full max-w-sm gap-(--bh-space-100)">
    <Label for="warehouse-name">Warehouse name</Label>
    <Input id="warehouse-name" />
  </div>
</template>

Beside a checkbox

Clicking the label checks the box. A label after a disabled checkbox turns grey by itself.

LabelWithCheckbox.vue
<script setup lang="ts">
import { Checkbox } from '@/components/ui/checkbox'
import { Label } from '@/components/ui/label'
</script>

<template>
  <div class="grid gap-(--bh-space-150)">
    <div class="flex items-center gap-(--bh-space-100)">
      <Checkbox id="daily-summary" :default-value="true" />
      <Label for="daily-summary">Send me a daily sync summary</Label>
    </div>
    <!-- The label follows the disabled checkbox before it (peer) and turns grey. -->
    <div class="flex items-center gap-(--bh-space-100)">
      <Checkbox id="weekly-report" disabled />
      <Label for="weekly-report">Send a weekly report to the accountant</Label>
    </div>
  </div>
</template>