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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
children | React.ReactNode | No | The label content (Fluent's | |
info | React.ReactNode | Yes | The information the info button's note shows: text, links or other rich content. | |
infoButtonLabel | string | No | 'Information' | Accessible name of the info button: the second half of its name, after the label text ("Password Information"). Localize it here. |
openOnHover | boolean | No | true | Opens the note on a mouse hover, after a short delay, and on keyboard focus, next to a click (see |
motion | MotionSlot | null | No | the fade and slide of InfoButton's note | The motion of the info button's note, passed through unchanged (see |
ref | React.Ref<HTMLSpanElement> | No | Ref to the root | |
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 | |
disabled | boolean | No | false | Whether the label is visually dimmed. |
size | 'small' | 'medium' | 'large' | No | 'medium' | Text size of the label: |
required | boolean | React.ReactNode | No | false | Whether to show a required indicator. |
weight | 'regular' | 'medium' | 'semibold' | 'bold' | No | 'regular' | Font weight of the label (the shared |
Any other prop is passed to the element it renders (HTMLSpanElement).
Parts
labelinfoButtoninfo
Stable class names
| Part | Class |
|---|---|
root | wave-info-label |
label | wave-info-label__label |
infoButton | wave-info-label__info-button |
info | wave-info-label__info |