Label

Names a control. Built on ui-sdk's Label: point htmlFor at the control's id and a press on the label focuses it, for any control, not only native inputs.

BetaReady to use. Its API can still change in a minor release; the changelog says when.

import { Label } from "@leap-crm/design-system";

Playground

Change a prop and the component follows. Its code is under Props.

Props

children
required
optional

Best practices

When to use it, and the rules that apply in particular places.

GuidancePractice
DoUse Field's label for a form control. Use Label on its own only for a control outside a Field, and point htmlFor at the control's id.
DoMark the control itself required as well. The label's asterisk is visual only, so a screen reader learns it from the control.
DoSet optional on the few fields a lawyer can skip when most of a form is required. Screen readers hear "Optional" as part of the name.
Don'tType the asterisk or "(optional)" into the label text. Use required or optional, so every form shows them the same way.
Don'tUse a placeholder instead of a label. It disappears once someone types, and the control loses its name.

Props

Also takes every prop of ui-sdk's Label, including htmlFor.

PropTypeDefaultDescription
childrenReactNode—What it shows inside.
requiredbooleanfalseShows the red asterisk. Mark the control itself required too; the asterisk is visual only.
optionalbooleanfalseShows a muted "Optional", which screen readers hear as part of the name.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

Code

What the playground shows, ready to copy.

import { Label } from "@leap-crm/design-system";

<Label>Full name</Label>