Label

Labels name form controls. Keep required and supplementary hint context compact and beside the visible label.

Overview and decision boundary

Use Label to provide an accessible name for a form control.

Do not rely on placeholders or icons alone.

import {  Input,  Label,  LabelContent,  LabelRequired,  LabelRow,} from "@nerio-ui/ui";import { LabelHint } from "@nerio-ui/ui/client";<LabelRow>  <LabelContent>    <Label htmlFor="project-name">Project name</Label>    <LabelRequired />    <LabelHint label="Choose a recognizable name for collaborators." />  </LabelContent></LabelRow><Input id="project-name" required />

Installation and imports

Install the editable registry source, or use the matching package entrypoint when the product keeps Nerio as a workspace dependency.

pnpm dlx nerio add labelimport { Input, Label, LabelContent, LabelRequired, LabelRow } from '@nerio-ui/ui';import { LabelHint } from '@nerio-ui/ui/client';

Usage

import { Input, Label, LabelContent, LabelRequired, LabelRow } from '@nerio-ui/ui';import { LabelHint } from '@nerio-ui/ui/client';<LabelRow>  <LabelContent>    <Label htmlFor="project-name">Project name</Label>    <LabelRequired />    <LabelHint label="Choose a recognizable name for collaborators." />  </LabelContent></LabelRow><Input id="project-name" required />

Variants

CompositionUse
DefaultA visible native Label paired with one control.
RequiredAdd LabelRequired and the control's native required attribute.
With hintUse LabelRow and LabelContent to keep supplementary guidance beside the label.

Anatomy

LabelRowLabelContentLabel + required + hint
SlotPurpose
rootNative <label> associated with a control through htmlFor.
contentLeft-side group for the label text, required marker, and hint.
requiredRed visual asterisk that never replaces native required semantics.
hintQuestion-mark tooltip trigger for non-essential context beside the label.

States

StateBehavior
DefaultThe visible Label gives the control its accessible name.
RequiredLabelRequired adds a visual marker while the control uses native required.
HintLabelHint reveals supplementary guidance on hover, focus, or activation.

Motion

  • State changes should use shared motion tokens and preserve reduced-motion behavior.

Accessibility

  • Use htmlFor to associate the label with a control id.
  • Forwards refs and native label attributes.
  • Keep labels visible for reusable product forms.
  • Avoid relying on placeholder text as the only label.
  • Use LabelRow and LabelContent so the interactive hint is not nested inside the native label.
  • LabelHint uses a native type=button trigger so it remains keyboard discoverable without submitting the surrounding form.
  • Pair LabelRequired with a native required control.
  • Tooltip guidance is supplementary and must not carry essential requirements.

API

PartPropsPurpose
LabelLabelHTMLAttributesNative label that supplies the accessible control name.
LabelRowHTMLAttributesKeeps label text and a supplementary hint as separate semantic siblings.
LabelContentHTMLAttributesGroups the native label, required marker, and hint.
LabelRequiredHTMLAttributesVisual red asterisk; pair with the control's required attribute.
LabelHintlabel + ariaLabel?Small client-only question icon with a supplementary tooltip.

Implementation contract

ContractValue
Registry itemlabel installs Tailwind-first Label, composition helpers, LabelHint, and the token bridge.
Base UITooltip for LabelHint only.
Registry dependenciestooltip
Package dependencies@nerio-ui/adapters, clsx, react, tailwind-merge, tailwindcss

Styling contract

ContractValue
AuthoringComplete, statically detectable Tailwind CSS v4 recipes own component visuals.
ValuesSemantic and component --n-* variables remain the canonical customization layer.
OverridesCustomizable slots merge consumer className values with tailwindCn so conflicting utilities resolve deterministically.
Residual CSSOnly shared keyframes and scoped no-Preflight compatibility rules remain; there is no parallel visual selector layer.

Design notes

  • Use Label to provide an accessible name for a form control.

Do / do not

Do

Keep the label visible and use a short LabelHint only for supplementary context.

Do not

Do not put a button or link inside the native Label, or use a lock icon without a matching control state.

Tokens

GroupTokensControls
Typography--n-label-font-size / --n-label-font-weightLabel text hierarchy.
Layout--n-label-gapRhythm between label text, required marker, and hint.
Required--n-label-required-colorRequired marker color.
Context--n-label-hint-icon-size / --n-label-icon-colorHint icon treatment.
Focus--n-focus-ringVisible keyboard focus for the hint.