Skip to content

Label

Label

A text label for a form control (htmlFor), on the Fluent type ramp. The optional required indicator is decorative (aria-hidden). Field renders its own label; use Label for custom layouts.

Examples

Default

export const Default: Story = {};

Required

export const Required: Story = {
  args: {
    children: 'Email address',
    required: true,
  },
};

Disabled

export const Disabled: Story = {
  args: {
    children: 'Disabled label',
    disabled: true,
  },
};

Semibold

export const Semibold: Story = {
  args: {
    children: 'Semibold label',
    weight: 'semibold',
  },
};

Bold

export const Bold: Story = {
  args: {
    children: 'Bold label',
    weight: 'bold',
  },
};

Sizes

export const Sizes: Story = {
  render: (args) => (
    <div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
      <Label {...args} size="small">
        Small label
      </Label>
      <Label {...args} size="medium">
        Medium label
      </Label>
      <Label {...args} size="large">
        Large label
      </Label>
    </div>
  ),
};

Custom Required

export const CustomRequired: Story = {
  args: {
    children: 'Promo code',
    required: <span>(required)</span>,
  },
};

Props

NameTypeRequiredDefaultDescription
requiredboolean | React.ReactNodeNofalse

Whether to show a required indicator. true shows a decorative asterisk; other content replaces it (for example a (required) text). Decorative (aria-hidden), so it must not be focusable; mark the control itself required.

disabledbooleanNofalse

Whether the label is visually dimmed.

size'small' | 'medium' | 'large'No'medium'

Text size of the label: small = caption-1, medium = body-1, large = body-2.

weight'regular' | 'medium' | 'semibold' | 'bold'No'regular'

Font weight of the label (the shared TextWeight vocabulary).

refReact.Ref<HTMLLabelElement>No

Ref to the <label> element.

slotProps{ required?: SlotPart<'span'> }No

Props for the elements the Label draws inside its root, by part, merged into each part's own (Fluent UI's required slot prop): your classes after the part's (yours win a conflict), your styles over its styles, your handlers and attributes added, your ref attached. Every attribute the Label sets on a part is locked. A part takes no children (the required prop gives the indicator its content).

Any other prop is passed to the element it renders (HTMLLabelElement).

Parts

  • required

Stable class names

PartClass
rootwave-label
requiredwave-label__required