Label

The caption of a field.

Usage

Point it at the field with htmlFor: clicking the caption focuses the field. Above an Input, a Select or a TextArea, add spaced to line it up with the text inside.

tsx
<Label spaced htmlFor="email">email</Label>
<Input>
  <Input.Text id="email" placeholder="you@domain.com" />
</Input>

Disabled

tsx
<Label spaced htmlFor="city" disabled>city</Label>
<Input>
  <Input.Text id="city" disabled />
</Input>

Next to a control

Beside a Checkbox or a Toggle, leave spaced out: without it the label has no indent and no margin.

tsx
<Checkbox id="terms" />
<Label htmlFor="terms">accept the terms</Label>

Without a field

For a caption that labels nothing, like a group title, render it as a span.

tsx
<Label as="span">components</Label>
components

Reference

proptypedefault
as?ElementType"label"the element or component to render
spaced?booleanfalsean indent and a bottom margin, to sit above a field
disabled?booleanfalsedims it
className?string—merged last, so it wins
…restprops of as—htmlFor and the rest of the element's props