Unified UI

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 label
pnpm dlx @work-rjkashyap/unified-ui add label
npx @work-rjkashyap/unified-ui add label
bunx @work-rjkashyap/unified-ui add label

If 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-ui
pnpm add @work-rjkashyap/unified-ui
yarn add @work-rjkashyap/unified-ui
bun add @work-rjkashyap/unified-ui

Anatomy

import {
	Label,
	FormLabel,
} from "@work-rjkashyap/unified-ui";

Examples

Basic Usage

Sizes

SizeFont SizeWeight
sm12pxMedium
md14pxMedium
lg14pxSemibold

Required Indicator

With Description

Disabled State


Props

PropTypeDefaultDescription
size"sm" | "md" | "lg""md"Size of the label text.
requiredbooleanfalseShows a red asterisk (*) after the label text.
disabledbooleanfalseReduces opacity and changes cursor.
descriptionReactNodeHelper text displayed below the label.
descriptionClassNamestringAdditional CSS classes for the description text.
wrapperClassNamestringAdditional CSS classes for the wrapper (when description set).
htmlForstringThe id of the associated form control.
classNamestringAdditional 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-required on the control.
  • Disabled state — Visual only; disable the input itself for functional disabling.
  • Peer-disabled — Supports Tailwind's peer-disabled pattern for automatic styling when the input is disabled.

Design Tokens

TokenUsage
--foregroundLabel text color
--dangerRequired indicator color
--muted-foregroundDescription text color

On this page