ButtonGroup
Groups related Button immediate children into a visually joined cluster - adjacent borders collapse and the group's borderRadius rounds only its outer corners (the first/last buttons keep their...
Demos
For usage examples, visit the component demo page: ButtonGroup
Import
import { ButtonGroup } from '@soroush.tech/design-system/ButtonGroup'Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'contained' | 'outlined' | 'text' | 'outlined' | Visual style for all child buttons. |
color | keyof Theme['palette'] | 'primary' | Color palette for all child buttons. |
size | keyof Theme['sizes'] | 'md' | Density for all child buttons. |
orientation | 'horizontal' | 'vertical' | 'horizontal' | Layout flow direction. |
borderRadius | keyof Theme['radii'] | 'md' | Group corner radius - rounds the outer corners only. |
disabled | boolean | false | Disables all child buttons. |
fullWidth | boolean | false | Group fills its container; children share the width. |
as | ElementType | 'div' | Overrides the root element. |
Also supports space props on the root.
Notes
- Renders
role="group"- always providearia-labeloraria-labelledby. - Separation between adjacent buttons is variant-aware:
outlinedhides the trailing button's leading edge (keeping its width) so the-thinoverlap shows a single, un-doubled border, whilecontainedandtextdraw a divider there instead (the color'sdarkshade forcontained, a translucentmainfortext). - Children must be immediate
Buttons (or components that readButtonGroupContext). - This design system's buttons are flat (no elevation), so no
shouldDisableElevationprop exists. - A split button (a dropdown-driven action) isn't built in yet: a
Menuwraps its trigger in a box of its own, which the group can't join to its buttons.
Source code
If this page does not answer your question, have a look at the implementation of the component for more detail.