Skip to content

InfoLabel

InfoLabel

A label followed by a button that reveals more information about it (Fluent's InfoLabel): the label renders in a real <label htmlFor>, and the button shows info — text, links or other rich content — in a note next to it, rendered once whether the note is open or closed (see InfoButton, which owns that note and its opening, closing and Tab order).

- children is the label content.
- htmlFor, required, size, weight and disabled route to the <label>; disabled dims only the label text, and the info button stays usable.
- The button is named "‹label text› ‹infoButtonLabel›" through aria-labelledby, which points at the <label> and at the button's own id (whose aria-label supplies the second half), so several InfoLabels on a page are told apart; infoButtonLabel localizes that second half. openOnHover, motion and size reach the button too.
- No controlRef: InfoLabel is a label, not a form control, so C-ROUTING's composite-control routing does not apply to it; a layout that needs the button's own element renders InfoButton next to a Label instead.

Examples

Default

export const Default: Story = {};

With Info

export const WithInfo: Story = {
  args: {
    children: 'Password strength',
    info: 'Use at least 8 characters with a mix of letters, numbers, and symbols.',
  },
};

Localized Button Label

export const LocalizedButtonLabel: Story = {
  args: {
    children: 'Benutzername',
    info: 'Ihre eindeutige Kennung für dieses Konto.',
    infoButtonLabel: 'Weitere Informationen',
  },
};

Rich Info

export const RichInfo: Story = {
  args: {
    children: 'Password',
    info: (
      <>
        Use at least 12 characters. <Link href="#password-rules">Learn more</Link>
      </>
    ),
  },
};

Click Only

export const ClickOnly: Story = {
  args: {
    children: 'API key',
    info: 'Regenerating the key invalidates the previous one immediately.',
    openOnHover: false,
  },
};

Sizes

export const Sizes: Story = {
  render: (args) => (
    <div className="flex flex-col gap-4">
      <InfoLabel {...args} size="small">
        Small
      </InfoLabel>
      <InfoLabel {...args} size="medium">
        Medium
      </InfoLabel>
      <InfoLabel {...args} size="large">
        Large
      </InfoLabel>
    </div>
  ),
};

Required

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

In Field

export const InField: Story = {
  args: {
    children: 'Password',
    info: 'Use at least 12 characters.',
  },
  render: (args) => (
    <div className="flex flex-col gap-6">
      <Field label={<InfoLabel {...args} />} required>
        <Input type="password" placeholder="Enter a password" />
      </Field>
      <Field label={<InfoLabel {...args} />} orientation="horizontal" required>
        <Input type="password" placeholder="Enter a password" />
      </Field>
    </div>
  ),
};

Props

NameTypeRequiredDefaultDescription
childrenReact.ReactNodeNo

The label content (Fluent's children).

infoReact.ReactNodeYes

The information the info button's note shows: text, links or other rich content.

infoButtonLabelstringNo'Information'

Accessible name of the info button: the second half of its name, after the label text ("Password Information"). Localize it here.

openOnHoverbooleanNotrue

Opens the note on a mouse hover, after a short delay, and on keyboard focus, next to a click (see InfoButton's openOnHover, which this passes through unchanged).

motionMotionSlot | nullNothe fade and slide of InfoButton's note

The motion of the info button's note, passed through unchanged (see InfoButton's motion: undefined is the default fade and slide, null none, a value replaces it). Fluent's Popover surfaceMotion.

refReact.Ref<HTMLSpanElement>No

Ref to the root <span>.

slotProps{ label?: SlotPart<'label'>; infoButton?: SlotPart<'button'>; info?: SlotPart<'div'> }No

Props for the elements the InfoLabel draws besides its root, by part, merged into each part's own: your classes after the part's (yours win a conflict), your styles over its styles, your attributes and handlers added, your ref beside its ref. Every attribute the InfoLabel sets on a part is locked and keeps its value (its own props routed there win); you add the attributes it does not set. A part takes no children. The InfoLabel renders a Label and an InfoButton: label and infoButton are their props, so their own rules apply, and info is the InfoButton's info part (the InfoButton's beak is not a part here). Fluent UI's InfoLabel has label and infoButton slots, and its info prop reaches the InfoButton's info slot, the note.

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.

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.

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

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

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

Parts

  • label
  • infoButton
  • info

Stable class names

PartClass
rootwave-info-label
labelwave-info-label__label
infoButtonwave-info-label__info-button
infowave-info-label__info