Label
Names a control. Renders a native label, so clicking it focuses or toggles
the control it points at.
import { Label } from "antlitz";
API
| Prop | Type | Default |
|---|---|---|
| asChild | boolean | false |
| required | boolean | false |
| tone | "base" | "muted" | "subtle" | base |
Usage
export function Basic() {
return (
<>
<Label htmlFor="email">Email</Label>
<Input id="email" type="email" placeholder="you@example.com" />
</>
);
}htmlFor must match the control's id. Field wires this for you — reach for
Label directly only when composing a layout Field does not cover.
Tones
export function Tones() {
return (
<>
<Label>Base</Label>
<Label tone="muted">Muted</Label>
<Label tone="subtle">Subtle</Label>
</>
);
}Required
export function Required() {
return (
<>
<Label htmlFor="name" required>
Full name
</Label>
<Input id="name" required />
</>
);
}The asterisk is presentational — set required on the control itself for the
browser to enforce it.
Composition
export function Composition() {
return (
<>
<Label htmlFor="api-key">
API key
<Badge size="sm" variant="soft" radius="full">
Required
</Badge>
</Label>
<Input id="api-key" placeholder="key-…" />
</>
);
}Label is a flex row with a gap, so badges and hints sit alongside the text without extra wrappers.
asChild merges its styling onto a child instead of rendering a label —
which is how Fieldset renders a legend matching every other label.
Disabled
export function Disabled() {
return (
<>
<Field label="Disabled input">
<Input disabled defaultValue="Not editable" />
</Field>
<Field orientation="horizontal" label="Disabled checkbox">
<Checkbox disabled />
</Field>
</>
);
}A Label dims when the control inside its Field is disabled, including when a
surrounding Fieldset disables the whole group.
This works through group-has-disabled/field, which looks downward for a
disabled control. A sibling selector could not: the input is wrapped by
Checkbox, Radio and Switch, and in a vertical Field the label comes first.