Button API - Material UI - MUI

Button API

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

Demos

For examples and details on the usage of this React component, visit the component demo pages:

  • Button Group
  • Button
  • Number Field

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

View:table

Props of the ButtonBase 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'| '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.

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 keyboard focus ripple is disabled.

disableRippleboolfalse

If true, the ripple effect is disabled.⚠️ Without a ripple there is no styling for :focus-visible by default. Be sure to highlight the element by applying separate styles with the .Mui-focusVisible class.

endIconnode-

Element placed after the children.

fullWidthboolfalse

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

hrefstring-

The URL to link to when the button is clicked. If defined, an a element will be used as the root node.

loadingboolnull

If true, the loading indicator is visible and the button is disabled. If true | false, the loading wrapper is always rendered before the children to prevent Google Translation Crash.

loadingIndicatornode<CircularProgress color="inherit" size={16} />

Element placed before the children if the button is in loading state. The node should contain an element with role="progressbar" with an accessible name. By default, it renders a CircularProgress that is labeled by the button itself.

loadingPosition'center'| 'end'| 'start''center'

The loading indicator can be positioned on the start, end, or the center of the button.

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

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

startIconnode-

Element placed before the children.

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'text'

The variant to use.

The 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.

CSS classes

View:table

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 root element if disabled={true}.
.Mui-focusVisibleState class applied to the ButtonBase root element if the button is keyboard focused.
.MuiButton-colorErrorcolorErrorStyles applied to the root element if color="error".
.MuiButton-colorInfocolorInfoStyles applied to the root element if color="info".
.MuiButton-colorInheritcolorInheritStyles applied to the root element if color="inherit".
.MuiButton-colorPrimarycolorPrimaryStyles applied to the root element if color="primary".
.MuiButton-colorSecondarycolorSecondaryStyles applied to the root element if color="secondary".
.MuiButton-colorSuccesscolorSuccessStyles applied to the root element if color="success".
.MuiButton-colorWarningcolorWarningStyles applied to the root element if color="warning".
.MuiButton-containedcontainedStyles applied to the root element if variant="contained".
.MuiButton-containedErrorcontainedErrorStyles applied to the root element if variant="contained" and color="error".Deprecated-Combine the .MuiButton-contained and .MuiButton-colorError classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-containedInfocontainedInfoStyles applied to the root element if variant="contained" and color="info".Deprecated-Combine the .MuiButton-contained and .MuiButton-colorInfo classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-containedInheritcontainedInheritStyles applied to the root element if variant="contained" and color="inherit".Deprecated-Combine the .MuiButton-contained and .MuiButton-colorInherit classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-containedPrimarycontainedPrimaryStyles applied to the root element if variant="contained" and color="primary".Deprecated-Combine the .MuiButton-contained and .MuiButton-colorPrimary classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-containedSecondarycontainedSecondaryStyles applied to the root element if variant="contained" and color="secondary".Deprecated-Combine the .MuiButton-contained and .MuiButton-colorSecondary classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-containedSizeLargecontainedSizeLargeStyles applied to the root element if size="large" and variant="contained".Deprecated-Combine the .MuiButton-sizeLarge and .MuiButton-contained classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-containedSizeMediumcontainedSizeMediumStyles applied to the root element if size="medium" and variant="contained".Deprecated-Combine the .MuiButton-sizeMedium and .MuiButton-contained classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-containedSizeSmallcontainedSizeSmallStyles applied to the root element if size="small" and variant="contained".Deprecated-Combine the .MuiButton-sizeSmall and .MuiButton-contained classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-containedSuccesscontainedSuccessStyles applied to the root element if variant="contained" and color="success".Deprecated-Combine the .MuiButton-contained and .MuiButton-colorSuccess classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-containedWarningcontainedWarningStyles applied to the root element if variant="contained" and color="warning".Deprecated-Combine the .MuiButton-contained and .MuiButton-colorWarning classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-disableElevationdisableElevationStyles applied to the root element if disableElevation={true}.
.MuiButton-endIconendIconStyles applied to the endIcon element if supplied.
.MuiButton-fullWidthfullWidthStyles applied to the root element if fullWidth={true}.
.MuiButton-iconiconStyles applied to the icon element if supplied
.MuiButton-iconSizeLargeiconSizeLargeStyles applied to the icon element if supplied and size="large".Deprecated-Combine the .MuiButton-icon and .MuiButtonSizeLarge classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-iconSizeMediumiconSizeMediumStyles applied to the icon element if supplied and size="medium".Deprecated-Combine the .MuiButton-icon and .MuiButtonSizeMedium classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-iconSizeSmalliconSizeSmallStyles applied to the icon element if supplied and size="small".Deprecated-Combine the .MuiButton-icon and .MuiButtonSizeSmall classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-loadingloadingStyles applied to the root element if loading={true}.
.MuiButton-loadingIconPlaceholderloadingIconPlaceholderStyles applied to the loadingIconPlaceholder element.
.MuiButton-loadingIndicatorloadingIndicatorStyles applied to the loadingIndicator element.
.MuiButton-loadingPositionCenterloadingPositionCenterStyles applied to the root element if loadingPosition="center".
.MuiButton-loadingPositionEndloadingPositionEndStyles applied to the root element if loadingPosition="end".
.MuiButton-loadingPositionStartloadingPositionStartStyles applied to the root element if loadingPosition="start".
.MuiButton-loadingWrapperloadingWrapperStyles applied to the loadingWrapper element.
.MuiButton-outlinedoutlinedStyles applied to the root element if variant="outlined".
.MuiButton-outlinedErroroutlinedErrorStyles applied to the root element if variant="outlined" and color="error".Deprecated-Combine the .MuiButton-outlined and .MuiButton-colorError classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-outlinedInfooutlinedInfoStyles applied to the root element if variant="outlined" and color="info".Deprecated-Combine the .MuiButton-outlined and .MuiButton-colorInfo classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-outlinedInheritoutlinedInheritStyles applied to the root element if variant="outlined" and color="inherit".Deprecated-Combine the .MuiButton-outlined and .MuiButton-colorInherit classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-outlinedPrimaryoutlinedPrimaryStyles applied to the root element if variant="outlined" and color="primary".Deprecated-Combine the .MuiButton-outlined and .MuiButton-colorPrimary classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-outlinedSecondaryoutlinedSecondaryStyles applied to the root element if variant="outlined" and color="secondary".Deprecated-Combine the .MuiButton-outlined and .MuiButton-colorSecondary classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-outlinedSizeLargeoutlinedSizeLargeStyles applied to the root element if size="large" and variant="outlined".Deprecated-Combine the .MuiButton-sizeLarge and .MuiButton-outlined classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-outlinedSizeMediumoutlinedSizeMediumStyles applied to the root element if size="medium" and variant="outlined".Deprecated-Combine the .MuiButton-sizeMedium and .MuiButton-outlined classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-outlinedSizeSmalloutlinedSizeSmallStyles applied to the root element if size="small" and variant="outlined".Deprecated-Combine the .MuiButton-sizeSmall and .MuiButton-outlined classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-outlinedSuccessoutlinedSuccessStyles applied to the root element if variant="outlined" and color="success".Deprecated-Combine the .MuiButton-outlined and .MuiButton-colorSuccess classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-outlinedWarningoutlinedWarningStyles applied to the root element if variant="outlined" and color="warning".Deprecated-Combine the .MuiButton-outlined and .MuiButton-colorWarning classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-rootrootStyles applied to the root element.
.MuiButton-sizeLargesizeLargeStyles applied to the root element if size="large".
.MuiButton-sizeMediumsizeMediumStyles applied to the root element if size="medium".
.MuiButton-sizeSmallsizeSmallStyles applied to the root element if size="small".
.MuiButton-startIconstartIconStyles applied to the startIcon element if supplied.
.MuiButton-texttextStyles applied to the root element if variant="text".
.MuiButton-textErrortextErrorStyles applied to the root element if variant="text" and color="error".Deprecated-Combine the .MuiButton-text and .MuiButton-colorError classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-textInfotextInfoStyles applied to the root element if variant="text" and color="info".Deprecated-Combine the .MuiButton-text and .MuiButton-colorInfo classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-textInherittextInheritStyles applied to the root element if variant="text" and color="inherit".Deprecated-Combine the .MuiButton-text and .MuiButton-colorInherit classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-textPrimarytextPrimaryStyles applied to the root element if variant="text" and color="primary".Deprecated-Combine the .MuiButton-text and .MuiButton-colorPrimary classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-textSecondarytextSecondaryStyles applied to the root element if variant="text" and color="secondary".Deprecated-Combine the .MuiButton-text and .MuiButton-colorSecondary classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-textSizeLargetextSizeLargeStyles applied to the root element if size="large" and variant="text".Deprecated-Combine the .MuiButton-sizeLarge and .MuiButton-text classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-textSizeMediumtextSizeMediumStyles applied to the root element if size="medium" and variant="text".Deprecated-Combine the .MuiButton-sizeMedium and .MuiButton-text classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-textSizeSmalltextSizeSmallStyles applied to the root element if size="small" and variant="text".Deprecated-Combine the .MuiButton-sizeSmall and .MuiButton-text classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-textSuccesstextSuccessStyles applied to the root element if variant="text" and color="success".Deprecated-Combine the .MuiButton-text and .MuiButton-colorSuccess classes instead. See Migrating from deprecated APIs for more details.
.MuiButton-textWarningtextWarningStyles applied to the root element if variant="text" and color="warning".Deprecated-Combine the .MuiButton-text and .MuiButton-colorWarning classes instead. See Migrating from deprecated APIs for more details.

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.

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.

Tag » Color Material Ui Button