bx

Label

Renders an accessible label associated with controls.

tsx
<Label htmlFor="name">Your name</Label>
<Input id="name" placeholder="Sofia Davis" />

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

Terminal
$ bext ui add label

Usage

tsx
import { Label, Input } from "@bext-stack/ui/primitives"

<div className="grid gap-2">
  <Label htmlFor="username">Username</Label>
  <Input id="username" />
</div>

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.

Try it live Open in play

Edit this example live in the bext playground. It compiles and runs entirely in your browser.

src/app/page.tsx 1 file · react · runs in your browser
The React idiom: same UI, for comparison.