Trivela UI

Label

Renders an accessible caption for a form control, with color token support.

Usage

label-demo.tsx
import { Label } from 'trivela-ui';

export function Example() {
  return <Label htmlFor="email">Email</Label>;
}

Examples

With input

Match htmlFor to the input id so clicking the label focuses the field.

Required

The required prop adds a marker. It is decorative — pair it with required on the input itself, which is what screen readers announce.

Colors

The color token sets the label text color, useful for signalling validation state.

Validation state

Pair a danger label with a danger input to mark a field that failed validation.

Must be at least 8 characters.

With checkbox

Lay the label beside a checkbox so the whole caption becomes a click target.

API Reference

PropTypeDefaultDescription
color'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info' | 'neutral''neutral'Color scale applied to the label text.
requiredbooleanfalseAppends a decorative asterisk. Hidden from assistive tech — set required on the control instead.
htmlForstringId of the control this label captions.
classNamestringMerged with the generated variant classes via cn().
...propsLabelHTMLAttributes<HTMLLabelElement>All native label attributes are forwarded to the root element.