Label
An accessible caption that names a form control.
@garn/ui/labelDefault
Label associated with an input.
Sizing
Text size; match it to the paired control's size.
smmdlgInstallation
garn is copy-in — the garn CLI writes this component's source into your project, so you own and can edit it. It resolves any base files and installs the npm dependencies below for you.
npx garn-ui add label- Registry
label- Source
- label.tsx
- Deps
@radix-ui/react-labelclass-variance-authority- Registry deps
utils
Import
import { Label } from "@garn/ui/label";Props
Generated from the component's TypeScript types.
size- Description
- No description.
- Type
"lg" | "md" | "sm"- Default
md
Plus 283 inherited native <label> attributes.
Styling
Target these data-slots and remap these tokens to restyle without forking the component.
[data-slot="label"]Overview
Label captions a form control so clicking the text focuses the control and assistive tech announces its accessible name. It's the connective tissue of every form: Input, Select, Checkbox, Radio, Switch, and Textarea all expect one. It is not a general text style — for section titles use a heading, for help text use a description element.
Guidelines
Associate every label with its control. Use htmlFor/id (or wrap the control) so the link is real, not just visual proximity — that's what makes the text a click target and gives the field its name. An unassociated label is invisible to screen readers.
Keep labels short, persistent, and in sentence case. A few words naming the field, always visible — don't rely on a placeholder that disappears on focus. Mark optionality explicitly ("(optional)") rather than assuming required-by-default.
Don't borrow the label for styling. If you want bold body text or a section heading, use the right element; a stray <label> with no control is an accessibility smell. Put requirements and examples in a separate description, not baked into the label.
Best practices
- Set
htmlForto the control's id (or wrap the control in the label). - Keep labels short and persistent — don't rely on a placeholder as the label.
- Don't use a label as a generic text style.
- Don't leave a label unassociated from any control.
Content guidelines
- Use a short noun phrase in sentence case (“Email address”), not a sentence or question.
- Don't add a trailing colon or other end punctuation.
- State optionality in words when it matters (“Phone (optional)”) rather than a bare asterisk.
Accessibility
- Role
label
Enforceable contracts
Associate the label with a control (htmlFor matching the control id, or wrap it).
when the label has no `htmlFor` and does not wrap a control
- • Associate with a control via `htmlFor`={control id}, or by wrapping the control.
- Status
- Stable
- Version
v0.3.0- Introduced
v0.1.0
garn doesn't yet record a per-release version history. This reflects the component's current lifecycle state; full changelog entries will appear once the metadata pipeline emits a lifecycle.history field.