Button API
Demos
For examples and details on the usage of this React component, visit the component demo pages:
Import
import Button from '@mui/material/Button';
// or
import { Button } from '@mui/material';
Props of the ButtonBase 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 API below for more details. | |
color | 'inherit' | 'primary' | 'secondary' | 'success' | 'error' | 'info' | '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 |
endIcon | node | Element placed after the children. | |
fullWidth | bool | false | If |
href | string | The URL to link to when the button is clicked. If defined, an | |
size | 'small' | 'medium' | 'large' | string | 'medium' | The size of the component. |
startIcon | node | Element placed before the children. | |
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 | 'text' | The variant to use. |
ref
is forwarded to the root element.Inheritance
While not explicitly documented above, the props of the ButtonBase component are also available in Button. You can take advantage of this to target nested components.
Theme default props
You can use MuiButton
to change the default props of this component with the theme.
The following class names are useful for styling with CSS (the state classes are marked).
To learn more, visit the component customization page.
Global class | Rule name | Description |
---|---|---|
.MuiButton-root | root | Styles applied to the root element. |
.MuiButton-text | text | Styles applied to the root element if variant="text" . |
.MuiButton-textInherit | textInherit | Styles applied to the root element if variant="text" and color="inherit" . |
.MuiButton-textPrimary | textPrimary | Styles applied to the root element if variant="text" and color="primary" . |
.MuiButton-textSecondary | textSecondary | Styles applied to the root element if variant="text" and color="secondary" . |
.MuiButton-textSuccess | textSuccess | Styles applied to the root element if variant="text" and color="success" . |
.MuiButton-textError | textError | Styles applied to the root element if variant="text" and color="error" . |
.MuiButton-textInfo | textInfo | Styles applied to the root element if variant="text" and color="info" . |
.MuiButton-textWarning | textWarning | Styles applied to the root element if variant="text" and color="warning" . |
.MuiButton-outlined | outlined | Styles applied to the root element if variant="outlined" . |
.MuiButton-outlinedInherit | outlinedInherit | Styles applied to the root element if variant="outlined" and color="inherit" . |
.MuiButton-outlinedPrimary | outlinedPrimary | Styles applied to the root element if variant="outlined" and color="primary" . |
.MuiButton-outlinedSecondary | outlinedSecondary | Styles applied to the root element if variant="outlined" and color="secondary" . |
.MuiButton-outlinedSuccess | outlinedSuccess | Styles applied to the root element if variant="outlined" and color="success" . |
.MuiButton-outlinedError | outlinedError | Styles applied to the root element if variant="outlined" and color="error" . |
.MuiButton-outlinedInfo | outlinedInfo | Styles applied to the root element if variant="outlined" and color="info" . |
.MuiButton-outlinedWarning | outlinedWarning | Styles applied to the root element if variant="outlined" and color="warning" . |
.MuiButton-contained | contained | Styles applied to the root element if variant="contained" . |
.MuiButton-containedInherit | containedInherit | Styles applied to the root element if variant="contained" and color="inherit" . |
.MuiButton-containedPrimary | containedPrimary | Styles applied to the root element if variant="contained" and color="primary" . |
.MuiButton-containedSecondary | containedSecondary | Styles applied to the root element if variant="contained" and color="secondary" . |
.MuiButton-containedSuccess | containedSuccess | Styles applied to the root element if variant="contained" and color="success" . |
.MuiButton-containedInfo | containedInfo | Styles applied to the root element if variant="contained" and color="info" . |
.MuiButton-containedError | containedError | Styles applied to the root element if variant="contained" and color="error" . |
.MuiButton-containedWarning | containedWarning | Styles applied to the root element if variant="contained" and color="warning" . |
.MuiButton-disableElevation | disableElevation | Styles applied to the root element if disableElevation={true} . |
.Mui-focusVisible | focusVisible | State class applied to the ButtonBase root element if the button is keyboard focused. |
.Mui-disabled | disabled | State class applied to the root element if disabled={true} . |
.MuiButton-colorInherit | colorInherit | Styles applied to the root element if color="inherit" . |
.MuiButton-textSizeSmall | textSizeSmall | Styles applied to the root element if size="small" and variant="text" . |
.MuiButton-textSizeMedium | textSizeMedium | Styles applied to the root element if size="medium" and variant="text" . |
.MuiButton-textSizeLarge | textSizeLarge | Styles applied to the root element if size="large" and variant="text" . |
.MuiButton-outlinedSizeSmall | outlinedSizeSmall | Styles applied to the root element if size="small" and variant="outlined" . |
.MuiButton-outlinedSizeMedium | outlinedSizeMedium | Styles applied to the root element if size="medium" and variant="outlined" . |
.MuiButton-outlinedSizeLarge | outlinedSizeLarge | Styles applied to the root element if size="large" and variant="outlined" . |
.MuiButton-containedSizeSmall | containedSizeSmall | Styles applied to the root element if size="small" and variant="contained" . |
.MuiButton-containedSizeMedium | containedSizeMedium | Styles applied to the root element if size="medium" and variant="contained" . |
.MuiButton-containedSizeLarge | containedSizeLarge | Styles applied to the root element if size="large" and variant="contained" . |
.MuiButton-sizeSmall | sizeSmall | Styles applied to the root element if size="small" . |
.MuiButton-sizeMedium | sizeMedium | Styles applied to the root element if size="medium" . |
.MuiButton-sizeLarge | sizeLarge | Styles applied to the root element if size="large" . |
.MuiButton-fullWidth | fullWidth | Styles applied to the root element if fullWidth={true} . |
.MuiButton-startIcon | startIcon | Styles applied to the startIcon element if supplied. |
.MuiButton-endIcon | endIcon | Styles applied to the endIcon element if supplied. |
.MuiButton-iconSizeSmall | iconSizeSmall | Styles applied to the icon element if supplied and size="small" . |
.MuiButton-iconSizeMedium | iconSizeMedium | Styles applied to the icon element if supplied and size="medium" . |
.MuiButton-iconSizeLarge | iconSizeLarge | Styles applied to the icon element if supplied and size="large" . |
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.