Skip to main content

label

Renders an accessible label associated with controls.

Philosophy

Labels are the accessibility backbone of every form. A form control without a label is invisible to screen readers. We ship Label as a standalone component rather than baking it into every form element because composition is more flexible than configuration - you decide where the label goes and how it connects.

Installation


npx @gentleduck/cli add label

npx @gentleduck/cli add label

Usage

import { Label } from "@/components/ui/label"
import { Label } from "@/components/ui/label"
<Label htmlFor="email">Your email address</Label>
<Label htmlFor="email">Your email address</Label>

RTL Support

Direction is resolved through the shared primitives direction module. Use a local dir="rtl" override when the component exposes it, or set DirectionProvider at app/root level for global RTL/LTR behavior.

Motion

Use MotionLabel for a fade+blur entrance animation powered by motion. Pairs well with MotionInput for staggered form field entrance.

API Reference

Label

Renders an accessible label element associated with form controls.

PropTypeDefaultDescription
dir'ltr' | 'rtl'-Text direction override. Resolved via useDirection (dir prop -> DirectionProvider -> 'ltr').
classNamestring-Additional class names for the label element
htmlForstring-The id of the form element this label is associated with
childrenReact.ReactNode-Label text or elements
refReact.Ref<HTMLLabelElement>-Ref forwarded to the label element
...propsReact.HTMLProps<HTMLLabelElement>-Additional props to spread to the label element

MotionLabel

Same props as Label plus an optional index prop for stagger delay (50ms per index). Adds fade+blur entrance. Requires the motion package.