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 of the native component are also available.
Name | Type | Default | Description |
---|---|---|---|
children | node | - | The content of the component. |
classes | object | - | 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. |
component | elementType | - | The component used for the root node. Either a string to use a HTML element or a component. |
disabled | bool | false | If |
disableElevation | bool | false | If |
disableFocusRipple | bool | false | If |
disableRipple | bool | false | If |
fullWidth | bool | false | If |
orientation | 'horizontal' | 'vertical' | 'horizontal' | The component orientation (layout flow direction). |
size | 'small' | 'medium' | 'large' | string | 'medium' | The size of the component. |
sx | Array<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. |
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.
Class name | Rule name | Description |
---|---|---|
.Mui-disabled | State class applied to the child elements if disabled={true} . | |
.MuiButtonGroup-contained | contained | Styles applied to the root element if variant="contained" . |
.MuiButtonGroup-disableElevation | disableElevation | Styles applied to the root element if disableElevation={true} . |
.MuiButtonGroup-firstButton | firstButton | Styles applied to the first button in the button group. |
.MuiButtonGroup-fullWidth | fullWidth | Styles applied to the root element if fullWidth={true} . |
.MuiButtonGroup-grouped | grouped | Styles applied to the children. |
.MuiButtonGroup-groupedContained | groupedContained | Styles applied to the children if variant="contained" . |
.MuiButtonGroup-groupedContainedHorizontal | groupedContainedHorizontal | Styles applied to the children if variant="contained" and orientation="horizontal" . |
.MuiButtonGroup-groupedContainedPrimary | groupedContainedPrimary | Styles applied to the children if variant="contained" and color="primary" . |
.MuiButtonGroup-groupedContainedSecondary | groupedContainedSecondary | Styles applied to the children if variant="contained" and color="secondary" . |
.MuiButtonGroup-groupedContainedVertical | groupedContainedVertical | Styles applied to the children if variant="contained" and orientation="vertical" . |
.MuiButtonGroup-groupedHorizontal | groupedHorizontal | Styles applied to the children if orientation="horizontal" . |
.MuiButtonGroup-groupedOutlined | groupedOutlined | Styles applied to the children if variant="outlined" . |
.MuiButtonGroup-groupedOutlinedHorizontal | groupedOutlinedHorizontal | Styles applied to the children if variant="outlined" and orientation="horizontal" . |
.MuiButtonGroup-groupedOutlinedPrimary | groupedOutlinedPrimary | Styles applied to the children if variant="outlined" and color="primary" . |
.MuiButtonGroup-groupedOutlinedSecondary | groupedOutlinedSecondary | Styles applied to the children if variant="outlined" and color="secondary" . |
.MuiButtonGroup-groupedOutlinedVertical | groupedOutlinedVertical | Styles applied to the children if variant="outlined" and orientation="vertical" . |
.MuiButtonGroup-groupedText | groupedText | Styles applied to the children if variant="text" . |
.MuiButtonGroup-groupedTextHorizontal | groupedTextHorizontal | Styles applied to the children if variant="text" and orientation="horizontal" . |
.MuiButtonGroup-groupedTextPrimary | groupedTextPrimary | Styles applied to the children if variant="text" and color="primary" . |
.MuiButtonGroup-groupedTextSecondary | groupedTextSecondary | Styles applied to the children if variant="text" and color="secondary" . |
.MuiButtonGroup-groupedTextVertical | groupedTextVertical | Styles applied to the children if variant="text" and orientation="vertical" . |
.MuiButtonGroup-groupedVertical | groupedVertical | Styles applied to the children if orientation="vertical" . |
.MuiButtonGroup-lastButton | lastButton | Styles applied to the last button in the button group. |
.MuiButtonGroup-middleButton | middleButton | Styles applied to buttons in the middle of the button group. |
.MuiButtonGroup-outlined | outlined | Styles applied to the root element if variant="outlined" . |
.MuiButtonGroup-root | root | Styles applied to the root element. |
.MuiButtonGroup-text | text | Styles applied to the root element if variant="text" . |
.MuiButtonGroup-vertical | vertical | Styles applied to the root element if orientation="vertical" . |
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.