Base · Forms
Label
A text label tied to a form control.
HTML / JSPlannedReactStableReact NativeDraftSwift (SwiftUI)PlannedGodotPlannedVueDraftSvelteDraftSolidDraft
Reviewed
Props
tsx
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
<Label htmlFor="reference">
Reference number
<span className="font-normal text-muted-foreground">Optional</span>
</Label>
<Input id="reference" placeholder="PO-2291-A" />Overview
Label renders a native label element with the form label text style. Linking it to a control with htmlFor lets people click the text to focus the control and gives the control its accessible name.
When to use
- To name a single input, select, checkbox or switch that you are laying out by hand.
- Next to a checkbox or switch, so the text is part of the click target.
When not to use
- When the control also needs help text or an error message: use Field, which includes a label and wires up the layout.
- To title a group of controls: use FieldLegend inside a FieldSet.
- For text that does not name a control: use a heading or plain text.
Anatomy
Text
The control’s name in sentence case, without a trailing colon.
Inline content (optional)
A hint such as “Optional”, or an icon, placed inside the label with an 8px gap.
Props
The contract every language implements. Names follow each language’s conventions (camelCase in React, snake_case in Rust).
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | Reference number | The label text. Passed as children. |
| hint | string | Optional | Secondary text shown after the label in the demo, passed as a child span. Leave empty to hide it. |
| htmlFor | string | – | The id of the control this label names. |
States
- Rest
- Medium-weight small text in the default foreground color.
- Control disabled
- Dims to 50% opacity when a sibling peer control is disabled, or when a parent has data-disabled="true".
Accessibility
Role: label
- Always connect the label with htmlFor and a matching id, or wrap the control inside the label.
- Clicking the label focuses a text control and toggles a checkbox or switch.
- Do not use placeholder text in place of a label: it disappears as soon as the person types.
- Mark optional fields in the label text rather than marking required fields with color alone.
Design tokens
Change any of these in Foundations and this component follows, in every language.
Platform notes
- HTML / JS
- Planned
- Not built in HTML / JS yet.
- React
- Stable
- Matches the contract with no platform differences.
- React Native
- Draft
- A Text. Mobile has no htmlFor: pass the control's ref as `control` so pressing the label focuses it, and give the input the same text as its accessibilityLabel.
- Swift (SwiftUI)
- Planned
- Not built in Swift yet.
- Godot
- Planned
- Not built in Godot yet.
- Vue
- Draft
- Usage snippet only; same props and behavior as the React component.
- Svelte
- Draft
- Usage snippet only; same props and behavior as the React component.
- Solid
- Draft
- Usage snippet only; same props and behavior as the React component.