Label
A foundational form label primitive. Five sizes, five intents, three tones, three weights, required/optional indicators, leading/trailing icons, optional description, and RTL support.
Playground
Installation
pnpm add @tessinaui/uiUsage
import { Label } from "@tessinaui/ui";<Label htmlFor="email">Email address</Label>
<input id="email" type="email" />Showcase
Sizes
Matches Button / Field sizing so labels line up with adjacent inputs.
| Size | Text class | Use case |
|---|---|---|
xs | text-xs | Dense forms, inline filters |
sm | text-xs | Compact forms |
md | text-sm | Default — matches md inputs |
lg | text-sm | Large forms, settings panels |
xl | text-base | Hero inputs, auth flows |
Intents
Use intent to communicate validation state. Any non-none intent overrides the tone.
| Intent | Token | Typical use |
|---|---|---|
none | inherits tone | Default |
error | text-error | Field failed validation |
warning | text-warning | Field needs attention |
success | text-success | Field passed validation |
info | text-info | Informational hint |
Tones
Controls the base colour when intent="none".
| Tone | Token | Use case |
|---|---|---|
default | text-foreground | Standard on light/background surfaces |
muted | text-muted-foreground | De-emphasised fields (e.g. optional) |
on-color | text-background | Dark surfaces / inverted themes |
Required and optional indicators
<Label required>Full name</Label>
<Label optional>Middle name</Label>Pass requiredIndicator or optionalIndicator to override the default markers (* and (optional)). Indicators are flagged aria-hidden — pair the label with an aria-required or required attribute on the associated control so screen readers announce the state.
<Label htmlFor="pwd" required>Password</Label>
<input id="pwd" type="password" required aria-required="true" />Icons and description
<Label leadingIcon={<Mail />} description="We'll never share your email.">
Email address
</Label>The description renders below the label text and inherits the disabled state.
Disabled
<Label disabled>Unavailable option</Label>disabled visually mutes the label (including any required/optional indicators). Use it when the associated control is disabled — the attribute does NOT disable the underlying input itself.
RTL
Pass dir="rtl" to flip icon and indicator alignment via logical spacing (ms-*).
<Label dir="rtl" required leadingIcon={<Mail />}>
البريد الإلكتروني
</Label>Accessibility
- Renders a native
<label>element — clicking the label focuses the control referenced byhtmlFor. - Required and optional indicators are
aria-hidden="true". Communicate required state on the associated input itself viarequired/aria-required. - Keep label text concise and always visible; avoid placeholder-only labels.
- When the label describes a group of controls (checkbox group, radio group), prefer a
<legend>inside a<fieldset>rather than a standaloneLabel.
API Reference
Label
| Prop | Type | Default | Description |
|---|---|---|---|
size | "xs" | "sm" | "md" | "lg" | "xl" | "md" | Size scale |
intent | "none" | "error" | "warning" | "success" | "info" | "none" | Validation state. Overrides tone when not none. |
tone | "default" | "muted" | "on-color" | "default" | Base colour tone |
weight | "normal" | "medium" | "semibold" | "medium" | Font weight |
required | boolean | false | Show a required indicator after the label |
optional | boolean | false | Show an "(optional)" indicator (ignored if required) |
requiredIndicator | ReactNode | "*" | Custom required marker |
optionalIndicator | ReactNode | "(optional)" | Custom optional marker |
disabled | boolean | false | Visually mute the label |
leadingIcon | ReactNode | — | Icon before the label text |
trailingIcon | ReactNode | — | Icon after the label text (and after indicators) |
description | ReactNode | — | Helper text rendered below the label |
htmlFor | string | — | Native for attribute — associates the label with a control |
dir | "ltr" | "rtl" | — | Text direction |
className | string | — | Extra classes on the root <label> element |
The component extends all standard <label> HTML attributes.
Rating
Captures user sentiment in four patterns — star scale, numeric NPS scale, emoji reaction picker, and binary thumbs — with full intent palette, half-star precision, RTL support, and keyboard navigation.
Field
A text input field with a label, helper text, FieldDropdown prefix, Button suffix, leading/trailing icon buttons, a clearable button, and a character counter. Supports all intent states and full RTL layout.