Skip to content

ButtonGroup API

API reference docs for the React ButtonGroup component. Learn about the props, CSS, and other APIs of this exported module.

Demos

Import

import ButtonGroup from '@mui/material/ButtonGroup';
// or
import { ButtonGroup } from '@mui/material';

Learn about the difference by reading this guide on minimizing bundle size.

Props

Props of the native component are also available.

NameTypeDefaultDescription
childrennode-

The content of the component.

classesobject-

Override or extend the styles applied to the component.

See CSS classes API below for more details.

color'inherit'
| 'primary'
| 'secondary'
| 'error'
| 'info'
| 'success'
| 'warning'
| string
'primary'

The color of the component. It supports both default and custom theme colors, which can be added as shown in the palette customization guide.

componentelementType-

The component used for the root node. Either a string to use a HTML element or a component.

disabledboolfalse

If true, the component is disabled.

disableElevationboolfalse

If true, no elevation is used.

disableFocusRippleboolfalse

If true, the button keyboard focus ripple is disabled.

disableRippleboolfalse

If true, the button ripple effect is disabled.

fullWidthboolfalse

If true, the buttons will take up the full width of its container.

orientation'horizontal'
| 'vertical'
'horizontal'

The component orientation (layout flow direction).

size'small'
| 'medium'
| 'large'
| string
'medium'

The size of the component. small is equivalent to the dense button styling.

sxArray<func
| object
| bool>
| func
| object
-

The system prop that allows defining system overrides as well as additional CSS styles.

See the `sx` page for more details.

variant'contained'
| 'outlined'
| 'text'
| string
'outlined'

The variant to use.

The ref is forwarded to the root element.

Theme default props

You can use MuiButtonGroup to change the default props of this component with the theme.

CSS classes

These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.

Class nameRule nameDescription
.Mui-disabledState class applied to the child elements if disabled={true}.
.MuiButtonGroup-colorPrimarycolorPrimaryStyles applied to the root element if color="primary"
.MuiButtonGroup-colorSecondarycolorSecondaryStyles applied to the root element if color="secondary"
.MuiButtonGroup-containedcontainedStyles applied to the root element if variant="contained".
.MuiButtonGroup-disableElevationdisableElevationStyles applied to the root element if disableElevation={true}.
.MuiButtonGroup-firstButtonfirstButtonStyles applied to the first button in the button group.
.MuiButtonGroup-fullWidthfullWidthStyles applied to the root element if fullWidth={true}.
.MuiButtonGroup-groupedgroupedStyles applied to the children.
.MuiButtonGroup-groupedContainedgroupedContainedStyles applied to the children if variant="contained".
.MuiButtonGroup-groupedContainedHorizontalgroupedContainedHorizontalStyles applied to the children if variant="contained" and orientation="horizontal".
.MuiButtonGroup-groupedContainedPrimarygroupedContainedPrimaryStyles applied to the children if variant="contained" and color="primary".
.MuiButtonGroup-groupedContainedSecondarygroupedContainedSecondaryStyles applied to the children if variant="contained" and color="secondary".
.MuiButtonGroup-groupedContainedVerticalgroupedContainedVerticalStyles applied to the children if variant="contained" and orientation="vertical".
.MuiButtonGroup-groupedHorizontalgroupedHorizontalStyles applied to the children if orientation="horizontal".
.MuiButtonGroup-groupedOutlinedgroupedOutlinedStyles applied to the children if variant="outlined".
.MuiButtonGroup-groupedOutlinedHorizontalgroupedOutlinedHorizontalStyles applied to the children if variant="outlined" and orientation="horizontal".
.MuiButtonGroup-groupedOutlinedPrimarygroupedOutlinedPrimaryStyles applied to the children if variant="outlined" and color="primary".
.MuiButtonGroup-groupedOutlinedSecondarygroupedOutlinedSecondaryStyles applied to the children if variant="outlined" and color="secondary".
.MuiButtonGroup-groupedOutlinedVerticalgroupedOutlinedVerticalStyles applied to the children if variant="outlined" and orientation="vertical".
.MuiButtonGroup-groupedTextgroupedTextStyles applied to the children if variant="text".
.MuiButtonGroup-groupedTextHorizontalgroupedTextHorizontalStyles applied to the children if variant="text" and orientation="horizontal".
.MuiButtonGroup-groupedTextPrimarygroupedTextPrimaryStyles applied to the children if variant="text" and color="primary".
.MuiButtonGroup-groupedTextSecondarygroupedTextSecondaryStyles applied to the children if variant="text" and color="secondary".
.MuiButtonGroup-groupedTextVerticalgroupedTextVerticalStyles applied to the children if variant="text" and orientation="vertical".
.MuiButtonGroup-groupedVerticalgroupedVerticalStyles applied to the children if orientation="vertical".
.MuiButtonGroup-horizontalhorizontalStyles applied to the root element if orientation="horizontal".
.MuiButtonGroup-lastButtonlastButtonStyles applied to the last button in the button group.
.MuiButtonGroup-middleButtonmiddleButtonStyles applied to buttons in the middle of the button group.
.MuiButtonGroup-outlinedoutlinedStyles applied to the root element if variant="outlined".
.MuiButtonGroup-rootrootStyles applied to the root element.
.MuiButtonGroup-texttextStyles applied to the root element if variant="text".
.MuiButtonGroup-verticalverticalStyles applied to the root element if orientation="vertical".

You can override the style of the component using one of these customization options:

Source code

If you did not find the information in this page, consider having a look at the implementation of the component for more detail.