Components
Label
An accessible label for form controls.
Installation
$ npx veil-ui@latest add labelUsage
import { Label } from "@/components/ui/label";
<Label htmlFor="email">Email</Label>;Examples
Basic
Required
Disabled
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| htmlFor | string | — | Id of the control this label describes. |
| ...props | Radix Label.Root props | — | All native label attributes. |
Accessibility
- Clicking the label focuses or toggles the associated control.
- Radix prevents label clicks from triggering buttons nested inside the label.
- Pair
peer-disabledorgroup-data-[disabled]with the control's disabled state so the label dims consistently.
Vue and plain HTML
This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add label --framework vue or switch the framework in components.json.
<script setup lang="ts">
import { cn } from "@/lib/utils";
const props = defineProps<{ class?: string; for?: string }>();
</script>
<template>
<label
data-slot="label"
:for="props.for"
:class="
cn(
'flex select-none items-center gap-2 text-sm font-medium leading-none',
'group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50',
'peer-disabled:cursor-not-allowed peer-disabled:opacity-50',
props.class,
)
"
>
<slot />
</label>
</template>