CompoundButton
A button with a main label and a secondary line of text below it, and an optional icon beside them. Built on Button: same appearances, sizes, token colors, type="button" default, disabled/disabledFocusable and polymorphic as behaviour (as="a" renders a link; a non-interactive as gets role="button", a tab stop and Enter/Space activation; disabled becomes aria-disabled on non-form-control elements).
- The text lines sit in a column wrapper (span[data-wave-compound-content]); the icon renders before or after it (iconPosition).
- secondaryText and contentContainer are slots: content or a slot object (as, className, attributes, a render function) for the second line, a slot object for the column around the text, both merged over slotProps.
- shape rounds the corners as on Button.
- With only an icon (no label and no secondaryText) it is an icon-only Button: square, with the icon-only sizing and name check.
Examples
Default
export const Default: Story = {};Without Secondary Text
export const WithoutSecondaryText: Story = {
args: {
children: 'Compound button',
secondaryText: undefined,
},
};Primary
export const Primary: Story = {
args: {
appearance: 'primary',
children: 'Create account',
secondaryText: 'Free for 30 days',
},
};With Icon
export const WithIcon: Story = {
args: {
children: 'Schedule meeting',
secondaryText: 'Next Monday at 9:00',
icon: <CalendarIcon />,
},
};Icon After
export const IconAfter: Story = {
args: {
children: 'Schedule meeting',
secondaryText: 'Next Monday at 9:00',
icon: <CalendarIcon />,
iconPosition: 'after',
},
};Disabled
export const Disabled: Story = {
args: {
disabled: true,
},
};As Link
export const AsLink: AnchorStory = {
args: {
as: 'a',
href: '#compound-button-docs',
children: 'Read the guide',
secondaryText: 'Five-minute introduction',
},
};Sizes
export const Sizes: Story = {
argTypes: {
size: { control: false },
},
render: (args) => (
<div className="flex items-start gap-2">
{sizes.map((size) => (
<CompoundButton key={size} {...args} size={size} secondaryText={`${size} size`}>
{size}
</CompoundButton>
))}
</div>
),
};Shapes
export const Shapes: Story = {
argTypes: {
shape: { control: false },
},
render: (args) => (
<div className="flex items-start gap-2">
<CompoundButton {...args} shape="rounded" secondaryText="rounded">
Rounded
</CompoundButton>
<CompoundButton {...args} shape="circular" secondaryText="circular">
Circular
</CompoundButton>
<CompoundButton {...args} shape="square" secondaryText="square">
Square
</CompoundButton>
</div>
),
};Slot Objects
export const SlotObjects: Story = {
args: {
secondaryText: { children: 'Free for 30 days', className: 'italic' },
contentContainer: { className: 'gap-0.5', 'data-testid': 'column' },
children: 'Create account',
},
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
secondaryText | Slot<'span'> | No | Secondary descriptive text displayed below the main label (part of the accessible name), Fluent's | |
contentContainer | SlotObject<'span'> | No | The element around the two lines of text, Fluent's | |
appearance | 'primary' | 'outline' | 'subtle' | 'transparent' | No | 'outline' | Visual style variant. |
size | 'extra-small' | 'small' | 'medium' | 'large' | 'extra-large' | No | 'medium' | Size affecting padding and font size. |
shape | 'circular' | 'square' | 'rounded' | No | 'rounded' | Corner shape, as on Button. |
disabled | boolean | No | false | Disables the button. As with Button: a native |
disabledFocusable | boolean | No | false | Marks the button unavailable but keeps it focusable and in the tab order (for a Tooltip that explains why, or a toolbar). Renders |
icon | Slot<'span'> | No | Icon shown beside the two lines of text, in a 40px box (32px at | |
iconPosition | 'before' | 'after' | No | 'before' | Where the icon renders: before the text column (the inline start) or after it (the inline end). Follows the writing direction through DOM order. Has no effect without an icon or on an icon-only button. |
slotProps | { contentContainer?: SlotPart<'span'>; primaryText?: SlotPart<'span'>; secondaryText?: SlotPart<'span'> } | No | Props for the elements the CompoundButton draws inside the button, by part, merged into each part's own (Fluent UI's | |
as | React.ElementType | No | 'button' | Render as a different element or component (its props are type-checked). |
Any other prop is passed to the element it renders (HTMLButtonElement).
Parts
contentContainerprimaryTextsecondaryText
Stable class names
| Part | Class |
|---|---|
root | wave-compound-button |
icon | wave-compound-button__icon |
contentContainer | wave-compound-button__content-container |
primaryText | wave-compound-button__primary-text |
secondaryText | wave-compound-button__secondary-text |