Label
A styled <label> element with an optional required indicator.
Preview
Usage
import { Label } from "anexui";
<Label htmlFor="email">Email address</Label>
<Input id="email" type="email" />
Copy codeRequired indicator
<Label htmlFor="name" required>Full name</Label>
<Input id="name" required />
Copy codeThe * is rendered with aria-hidden="true" so screen readers don't announce it — the input's own required attribute handles that.
Disabled appearance
<Label htmlFor="locked" className="opacity-50">Locked field</Label>
<Input id="locked" disabled />
Copy codeProps
| Prop | Type | Default | Description |
|---|---|---|---|
| htmlFor | string | — | ID of the associated form control |
| required | boolean | false | Shows a visible * indicator (aria-hidden) |
All standard HTML <label> attributes are accepted.
Accessibility
- Native
<label>element — clicking it focuses the associated control requiredindicator isaria-hiddento avoid double-announcing; setrequiredon the input too- Do not use
aria-labelas a substitute for a visible label — visible labels aid all users