Label
Renders an accessible label associated with controls.
Label is a styled native HTML <label>. The for prop (or htmlFor) is required to link it to the field (Input, Checkbox, RadioGroup…).
Clicking the label focuses or toggles the associated field (native HTML behavior).
Installation
$ bext ui add label
Copy and paste the following into src/components/ui/label.tsx.
Usage
Anatomy
<Label for="input-id">Label text</Label>
API Reference
Label
| Prop | Type | Default | Description |
|---|---|---|---|
| for | string | — | id of the associated field. Can also be written htmlFor. |
| className | string | — | text-sm font-medium leading-none by default. |
Accessibility
Clicking a linked Label focuses the Input, checks or unchecks the Checkbox, and so on (native HTML behavior).
Never use a placeholder in place of a label: assistive technologies do not announce it correctly.
Edit this example live in the bext playground. It compiles and runs entirely in your browser.
The React idiom: same UI, for comparison.
On This Page