ButtonGroup API
API reference docs for the React ButtonGroup component. Learn about the props, CSS, and other APIs of this exported module.
Component demos
Import
import ButtonGroup from '@mui/material/ButtonGroup';
// or
import { ButtonGroup } from '@mui/material';
Props of the native component are also available.
Override or extend the styles applied to the component.
See CSS API below for more details.
Type:object
The color of the component. It supports both default and custom theme colors, which can be added as shown in the palette customization guide.
Type:'inherit'
| 'primary'
| 'secondary'
| 'error'
| 'info'
| 'success'
| 'warning'
| string
Default:'primary'
The component used for the root node. Either a string to use a HTML element or a component.
Type:elementType
The component orientation (layout flow direction).
Type:'horizontal'
| 'vertical'
Default:'horizontal'
The size of the component. small
is equivalent to the dense button styling.
Type:'small'
| 'medium'
| 'large'
| string
Default:'medium'
The system prop that allows defining system overrides as well as additional CSS styles.
See the `sx` page for more details.
Type:Array<func
| object
| bool>
| func
| object
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.
These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.
Styles applied to the root element if variant="contained"
.
Rule name:contained
Styles applied to the root element if disableElevation={true}
.
Rule name:disableElevation
Styles applied to the first button in the button group.
Rule name:firstButton
Styles applied to the children if variant="contained"
.
Rule name:groupedContained
Styles applied to the children if variant="contained"
and orientation="horizontal"
.
Rule name:groupedContainedHorizontal
Styles applied to the children if variant="contained"
and color="primary"
.
Rule name:groupedContainedPrimary
Styles applied to the children if variant="contained"
and color="secondary"
.
Rule name:groupedContainedSecondary
Styles applied to the children if variant="contained"
and orientation="vertical"
.
Rule name:groupedContainedVertical
Styles applied to the children if orientation="horizontal"
.
Rule name:groupedHorizontal
Styles applied to the children if variant="outlined"
.
Rule name:groupedOutlined
Styles applied to the children if variant="outlined"
and orientation="horizontal"
.
Rule name:groupedOutlinedHorizontal
Styles applied to the children if variant="outlined"
and color="primary"
.
Rule name:groupedOutlinedPrimary
Styles applied to the children if variant="outlined"
and color="secondary"
.
Rule name:groupedOutlinedSecondary
Styles applied to the children if variant="outlined"
and orientation="vertical"
.
Rule name:groupedOutlinedVertical
Styles applied to the children if variant="text"
and orientation="horizontal"
.
Rule name:groupedTextHorizontal
Styles applied to the children if variant="text"
and color="primary"
.
Rule name:groupedTextPrimary
Styles applied to the children if variant="text"
and color="secondary"
.
Rule name:groupedTextSecondary
Styles applied to the children if variant="text"
and orientation="vertical"
.
Rule name:groupedTextVertical
Styles applied to the children if orientation="vertical"
.
Rule name:groupedVertical
Styles applied to the last button in the button group.
Rule name:lastButton
Styles applied to buttons in the middle of the button group.
Rule name:middleButton
You can override the style of the component using one of these customization options:
- With a global class name.
- With a rule name as part of the component's
styleOverrides
property in a custom theme.