Label
A caption for a form control.
Native <label>
<script setup lang="ts">
import { Checkbox } from '@/components/ui/checkbox';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
</script>
<template>
<div class="field">
<Label for="name">Name</Label>
<Input id="name" placeholder="Ada Lovelace" />
</div>
<Label><Checkbox /> Wrap a control to label it without an id</Label>
</template>
<style scoped>
.field {
display: grid;
gap: var(--dui-space-2);
width: min(100%, 20rem);
margin-bottom: var(--dui-space-4);
}
</style>
Installation
npx distill-ui add label- Set up the tokens once, if you haven't: see manual installation.
- Copy these files into your project:
<template>
<label class="label"><slot /></label>
</template>
<!--
Options you can set from a parent or on the label itself:
--dui-label-fg
-->
<style scoped>
.label {
display: flex;
align-items: center;
gap: var(--dui-space-2);
color: var(--dui-label-fg, var(--dui-color-foreground));
font-size: var(--dui-text-sm);
line-height: 1;
font-weight: var(--dui-weight-medium);
user-select: none;
}
</style>
export { default as Root, default as Label } from './Label.vue';
Customizing
Set any of these on the component or on a parent element. See Customizing for how they work.
| Custom property | Default |
|---|---|
--dui-label-fg | var(--dui-color-foreground) |