Label
Hello, my name is Email. An accessible name for a form control.
Demo
Installation
Usage
<script setup lang="ts">
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
</script>
<template>
<Label for="email">Email</Label>
<Input id="email" type="email" />
</template>
Inside a Field, use FieldLabel instead: it finds the control on its own.
Double-clicking a Label doesn't select its text. Put the control first and give it the peer class, as a checkbox does, and the label dims when the control is disabled.
API Reference
class is also accepted and merged over the base classes.
Label
Props
| Prop | Default | Type and description |
|---|---|---|
| for | — | stringThe |
| asChild | — | booleanRender the single child instead of a wrapper, merging the label's attributes and classes onto it. |
| as | — | AsTag | ComponentThe element or component to render. |
Slots
| Slot | Scope and description |
|---|---|
| default | {}The label text. |
Props
- for
stringTheidof the control this label names.- asChild
booleanRender the single child instead of a wrapper, merging the label's attributes and classes onto it.- as
AsTag | ComponentThe element or component to render.
Slots
- default
{}The label text.
Data attributes
| data-slot | Attributes | Description |
|---|---|---|
| label | — | The label. |
Changelog
No changes yet.