--- meta: title: Button Group description: Button groups can be used to group related buttons into sections. layout: component --- ```html:preview Left Center Right ``` ```jsx:react import SlButton from '@shoelace-style/shoelace/dist/react/button'; import SlButtonGroup from '@shoelace-style/shoelace/dist/react/button-group'; const App = () => ( Left Center Right ); ``` ## Examples ### Button Sizes All button sizes are supported, but avoid mixing sizes within the same button group. ```html:preview Left Center Right

Left Center Right

Left Center Right ``` ```jsx:react import SlButton from '@shoelace-style/shoelace/dist/react/button'; import SlButtonGroup from '@shoelace-style/shoelace/dist/react/button-group'; const App = () => ( <> Left Center Right

Left Center Right

Left Center Right ); ``` ### Theme Buttons Theme buttons are supported through the button's `variant` attribute. ```html:preview Left Center Right

Left Center Right

Left Center Right

Left Center Right

Left Center Right ``` ```jsx:react import SlButton from '@shoelace-style/shoelace/dist/react/button'; import SlButtonGroup from '@shoelace-style/shoelace/dist/react/button-group'; const App = () => ( <> Left Center Right

Left Center Right

Left Center Right

Left Center Right

Left Center Right ); ``` ### Pill Buttons Pill buttons are supported through the button's `pill` attribute. ```html:preview Left Center Right

Left Center Right

Left Center Right ``` ```jsx:react import SlButton from '@shoelace-style/shoelace/dist/react/button'; import SlButtonGroup from '@shoelace-style/shoelace/dist/react/button-group'; const App = () => ( <> Left Center Right

Left Center Right

Left Center Right ); ``` ### Dropdowns in Button Groups Dropdowns can be placed inside button groups as long as the trigger is an `` element. ```html:preview Button Button Dropdown Item 1 Item 2 Item 3 ``` ```jsx:react import SlButton from '@shoelace-style/shoelace/dist/react/button'; import SlButtonGroup from '@shoelace-style/shoelace/dist/react/button-group'; import SlDropdown from '@shoelace-style/shoelace/dist/react/dropdown'; import SlMenu from '@shoelace-style/shoelace/dist/react/menu'; import SlMenuItem from '@shoelace-style/shoelace/dist/react/menu-item'; const App = () => ( Button Button Dropdown Item 1 Item 2 Item 3 ); ``` ### Split Buttons Create a split button using a button and a dropdown. Use a [visually hidden](/components/visually-hidden) label to ensure the dropdown is accessible to users with assistive devices. ```html:preview Save More options Save Save as… Save all ``` ```jsx:react import SlButton from '@shoelace-style/shoelace/dist/react/button'; import SlButtonGroup from '@shoelace-style/shoelace/dist/react/button-group'; import SlDropdown from '@shoelace-style/shoelace/dist/react/dropdown'; import SlMenu from '@shoelace-style/shoelace/dist/react/menu'; import SlMenuItem from '@shoelace-style/shoelace/dist/react/menu-item'; const App = () => ( Save Save Save as… Save all ); ``` ### Tooltips in Button Groups Buttons can be wrapped in tooltips to provide more detail when the user interacts with them. ```html:preview Left Center Right ``` ```jsx:react import SlButton from '@shoelace-style/shoelace/dist/react/button'; import SlButtonGroup from '@shoelace-style/shoelace/dist/react/button-group'; import SlTooltip from '@shoelace-style/shoelace/dist/react/tooltip'; const App = () => ( <> Left Center Right ); ``` ### Toolbar Example Create interactive toolbars with button groups. ```html:preview
``` ```jsx:react import SlButton from '@shoelace-style/shoelace/dist/react/button'; import SlButtonGroup from '@shoelace-style/shoelace/dist/react/button-group'; import SlIcon from '@shoelace-style/shoelace/dist/react/icon'; import SlTooltip from '@shoelace-style/shoelace/dist/react/tooltip'; const css = ` .button-group-toolbar sl-button-group:not(:last-of-type) { margin-right: var(--sl-spacing-x-small); } `; const App = () => ( <>
); ```