Button API
API reference docs for the React Button component. Learn about the props, CSS, and other APIs of this exported module.
Demos
Import
import Button from '@mui/material/Button';
// or
import { Button } from '@mui/material';
Learn about the difference by reading this guide on minimizing bundle size.
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 classes 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.
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 root element if disabled={true} . | |
.Mui-focusVisible | State class applied to the ButtonBase root element if the button is keyboard focused. | |
.MuiButton-colorError | colorError | Styles applied to the root element if color="error" . |
.MuiButton-colorInfo | colorInfo | Styles applied to the root element if color="info" . |
.MuiButton-colorInherit | colorInherit | Styles applied to the root element if color="inherit" . |
.MuiButton-colorPrimary | colorPrimary | Styles applied to the root element if color="primary" . |
.MuiButton-colorSecondary | colorSecondary | Styles applied to the root element if color="secondary" . |
.MuiButton-colorSuccess | colorSuccess | Styles applied to the root element if color="success" . |
.MuiButton-colorWarning | colorWarning | Styles applied to the root element if color="warning" . |
.MuiButton-contained | contained | Styles applied to the root element if variant="contained" . |
.MuiButton-containedError | containedError | Styles applied to the root element if variant="contained" and color="error" . |
.MuiButton-containedInfo | containedInfo | Styles applied to the root element if variant="contained" and color="info" . |
.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-containedSizeLarge | containedSizeLarge | Styles applied to the root element if size="large" and variant="contained" . |
.MuiButton-containedSizeMedium | containedSizeMedium | Styles applied to the root element if size="medium" and variant="contained" . |
.MuiButton-containedSizeSmall | containedSizeSmall | Styles applied to the root element if size="small" and variant="contained" . |
.MuiButton-containedSuccess | containedSuccess | Styles applied to the root element if variant="contained" and color="success" . |
.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} . |
.MuiButton-endIcon | endIcon | Styles applied to the endIcon element if supplied. |
.MuiButton-fullWidth | fullWidth | Styles applied to the root element if fullWidth={true} . |
.MuiButton-icon | icon | Styles applied to the icon element if supplied |
.MuiButton-iconSizeLarge | iconSizeLarge | Styles applied to the icon element if supplied and size="large" . |
.MuiButton-iconSizeMedium | iconSizeMedium | Styles applied to the icon element if supplied and size="medium" . |
.MuiButton-iconSizeSmall | iconSizeSmall | Styles applied to the icon element if supplied and size="small" . |
.MuiButton-outlined | outlined | Styles applied to the root element if variant="outlined" . |
.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-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-outlinedSizeLarge | outlinedSizeLarge | Styles applied to the root element if size="large" and variant="outlined" . |
.MuiButton-outlinedSizeMedium | outlinedSizeMedium | Styles applied to the root element if size="medium" and variant="outlined" . |
.MuiButton-outlinedSizeSmall | outlinedSizeSmall | Styles applied to the root element if size="small" and variant="outlined" . |
.MuiButton-outlinedSuccess | outlinedSuccess | Styles applied to the root element if variant="outlined" and color="success" . |
.MuiButton-outlinedWarning | outlinedWarning | Styles applied to the root element if variant="outlined" and color="warning" . |
.MuiButton-root | root | Styles applied to the root element. |
.MuiButton-sizeLarge | sizeLarge | Styles applied to the root element if size="large" . |
.MuiButton-sizeMedium | sizeMedium | Styles applied to the root element if size="medium" . |
.MuiButton-sizeSmall | sizeSmall | Styles applied to the root element if size="small" . |
.MuiButton-startIcon | startIcon | Styles applied to the startIcon element if supplied. |
.MuiButton-text | text | Styles applied to the root element if variant="text" . |
.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-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-textSizeLarge | textSizeLarge | Styles applied to the root element if size="large" and variant="text" . |
.MuiButton-textSizeMedium | textSizeMedium | Styles applied to the root element if size="medium" and variant="text" . |
.MuiButton-textSizeSmall | textSizeSmall | Styles applied to the root element if size="small" and variant="text" . |
.MuiButton-textSuccess | textSuccess | Styles applied to the root element if variant="text" and color="success" . |
.MuiButton-textWarning | textWarning | Styles applied to the root element if variant="text" and color="warning" . |
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.