Label
Form caption on bits-ui Label. Inherits disabled and checked state from neighbouring controls — no motion, just clear association.
Usage
label.svelte
<script lang="ts">
import { Label } from '$lib/components/ui/label';
import { Input } from '$lib/components/ui/input';
</script>
<div class="flex flex-col gap-1.5">
<Label for="email">Email</Label>
<Input id="email" type="email" placeholder="you@bloom.social" />
</div>States
label.svelte
<script lang="ts">
import { Label as LabelPrimitive } from 'bits-ui';
import { cn } from '$lib/utils.js';
let {
ref = $bindable(null),
class: className,
...restProps
}: LabelPrimitive.RootProps = $props();
</script>
<LabelPrimitive.Root
bind:ref
data-slot="label"
class={cn(
'flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50',
className
)}
{...restProps}
/>
API reference
Inherits bits-ui Label.Root props via spread. Picks up peer-disabled and group-data-[disabled] from surrounding controls automatically.
| Prop | Type | Default | Description |
|---|---|---|---|
string | — | Native htmlFor association with the control. Required for screen-reader wiring. | |
HTMLLabelElement | null | null | Two-way-bindable element reference. | |
string | — | Merged onto the root via tailwind-merge. |