Components
Label
A native label with an optional decorative required marker.
Server-compatible (no "use client")
import.tsx
label-field.tsx
Edit on GitHubPurpose
Label names a form control. It renders a native <label>.
Import
import { Label } from "@neshel-ui/components";Usage
Preview: label-field
import { Input, Label } from "@neshel-ui/components";
import { Stack } from "@neshel-ui/layout";
export default function LabelField() {
return (
<Stack space="2" className="max-w-sm">
{/* htmlFor ties the label to the control: clicking it focuses the input. */}
<Label htmlFor="demo-full-name" required>
Full name
</Label>
<Input id="demo-full-name" name="fullName" autoComplete="name" required />
</Stack>
);
}API
LabelProps
| Prop | Type | Default | Description |
|---|---|---|---|
| ref | Ref<HTMLLabelElement> | — | — |
| required | boolean | — | Shows a decorative "*" (hidden from assistive technology; use required on the control). |
Also accepts the props of: React DOM attributes.
required adds a decorative * marked aria-hidden; the control's own required attribute is what
browsers and screen readers announce.
Accessibility
Connect it with htmlFor (matching the control's id) — this also makes clicking the label focus the
control. Selection controls (Select, MultiSelect, Combobox) are labelled the same way through
their id.
Common mistakes
requiredon the Label but not on the control: the field is not actually required.