Label
An accessible label component with required indicator, sizing, description text, and disabled state. Built on Radix UI Label.
Overview
The Label component provides an accessible <label> element for form controls. It supports required indicators, descriptions, multiple sizes, and disabled states. Built on Radix UI's Label primitive for proper accessibility semantics.
Installation
Install the component via the CLI in one command.
npx @work-rjkashyap/unified-ui add labelpnpm dlx @work-rjkashyap/unified-ui add labelnpx @work-rjkashyap/unified-ui add labelbunx @work-rjkashyap/unified-ui add labelIf you haven't initialized your project yet, run npx @work-rjkashyap/unified-ui init first. See the CLI docs for details.
Or install the full package
Use this approach if you prefer to install the entire design system as a dependency instead of copying individual components.
npm install @work-rjkashyap/unified-uipnpm add @work-rjkashyap/unified-uiyarn add @work-rjkashyap/unified-uibun add @work-rjkashyap/unified-uiAnatomy
import {
Label,
FormLabel,
} from "@work-rjkashyap/unified-ui";Examples
Basic Usage
Sizes
| Size | Font Size | Weight |
|---|---|---|
sm | 12px | Medium |
md | 14px | Medium |
lg | 14px | Semibold |
Required Indicator
With Description
Disabled State
Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | "sm" | "md" | "lg" | "md" | Size of the label text. |
required | boolean | false | Shows a red asterisk (*) after the label text. |
disabled | boolean | false | Reduces opacity and changes cursor. |
description | ReactNode | — | Helper text displayed below the label. |
descriptionClassName | string | — | Additional CSS classes for the description text. |
wrapperClassName | string | — | Additional CSS classes for the wrapper (when description set). |
htmlFor | string | — | The id of the associated form control. |
className | string | — | Additional CSS classes for the label element. |
Accessibility
The required indicator is decorative (aria-hidden). Always set aria-required="true" on the associated input for screen reader support.
- Semantic HTML — Renders as a native
<label>element via Radix UI's Label primitive. - htmlFor linkage — Clicking the label focuses the associated input.
- Required indicator — Visual only; use
aria-requiredon the control. - Disabled state — Visual only; disable the input itself for functional disabling.
- Peer-disabled — Supports Tailwind's
peer-disabledpattern for automatic styling when the input is disabled.
Design Tokens
| Token | Usage |
|---|---|
--foreground | Label text color |
--danger | Required indicator color |
--muted-foreground | Description text color |