import { ButtonGroup } from "@senvenli/react/action";Examples
Split button
A main action with a second button for its alternatives.import { Button, ButtonGroup } from "@senvenli/react/action";
export default function Example() {
return (
<ButtonGroup aria-label="Send" variant="split">
<Button variant="primary">Send invoice</Button>
<Button variant="primary" iconOnly iconBefore="chevron-down" aria-label="More send options" />
</ButtonGroup>
);
}Icon buttons
Each button keeps its own accessible name; the group has one too.import { Button, ButtonGroup } from "@senvenli/react/action";
export default function Example() {
return (
<ButtonGroup aria-label="History">
<Button iconOnly iconBefore="undo-2" aria-label="Undo" />
<Button iconOnly iconBefore="redo-2" aria-label="Redo" />
</ButtonGroup>
);
}Guidelines
When to use it
- Two to four related actions belong together.
- A main action has a menu of variants (split).
Use something else when
- The buttons hold a pressed state, such as a view or format choice. Toggle button
- A longer row of controls above a list or editor. Toolbar
Accessibility
Built in
- Exposed as a group.
You provide
- An
aria-labelthat names the group.
API reference
ButtonGroup
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "split" | "default" |
|
variant"default" | "split"Default"default"split: a primary main action with an icon button that opens a menu of alternatives; the seam uses the pressed brand fill instead ofds-border.