logo

SINGULARITY

DOCS

PurchaseReturn to the Dashboard
Reference

Button

Buttons enable users to perform actions and make selections with a single click.

Buttons convey actions that users can execute. They are commonly integrated into your UI in areas such as:
  • Modal windows
  • Forms
  • Cards
  • Toolbars

Basic button

The Button component offers three variants: text (default), contained, and outlined.

Text button

Text buttonsare generally used for less prominent actions, such as those found in dialogs or cards. In cards, text buttons help keep the focus on the card's content.
Link

Contained button

Contained buttonsstand out with high emphasis due to their elevation and fill. They are used for primary actions within your application.
Link
You can eliminate the elevation effect by using the disableElevation prop.

Outlined button

Outlined buttons provide medium emphasis. They are used for significant but non-primary actions in an application.
Outlined buttons serve as a lower-emphasis alternative to contained buttons or a higher-emphasis option compared to text buttons.
Link

Handling clicks

All components support an onClick handler that is attached to the root DOM element.
<Button
  onClick={() => {
    alert('clicked');
  
>
  Click me
</Button>
Note that the documentation avoids listing native properties (of which there are many) in the components' API section.

Color

Besides the default button colors, you can introduce custom colors or remove unnecessary ones. Refer to the Adding new colors guide for more details.

Sizes

To adjust button sizes, utilize the size prop for larger or smaller buttons.

Buttons with icons and label

Incorporating icons into certain buttons can improve the user experience, as icons are often more recognizable than text alone. For instance, a delete button can be enhanced with a trash can icon.

Icon button

Icon buttons are frequently used in app bars and toolbars.
Icons are ideal for toggle buttons, enabling users to select or deselect an option, such as adding or removing a star from an item.

Sizes

To create larger or smaller icon buttons, apply the size prop.

Colors

Use the color prop to apply the theme's color palette to the component.

Loading

From version 6.4.0, the loading prop can be used to set icon buttons to a loading state, disabling user interactions.

Badge

The Badge component can be used to add a badge to an IconButton.

File upload

To create a file upload button, convert the button into a label using component="label" and include a visually hidden input with type file.

Loading

Starting with version 6.4.0, the loading prop allows buttons to be set to a loading state, preventing user interactions.
Switch the loading state to observe the transition between different states.
:::warning When the loading prop is set to boolean, the loading wrapper remains in the DOM to avoid a Google Translation Crash.
The loading value should always be null or boolean. Avoid the following pattern, as it may trigger the Google Translation crash:
<Button {...(isFetching && { loading: true })}> 
:::

Customization

Below are examples of customizing the component. Learn more in the overrides documentation page.
🎨 For inspiration, explore MUI Treasury's customization examples.

Complex button

Text Buttons, Contained Buttons, Floating Action Buttons, and Icon Buttons are all built on the ButtonBase component. Use this foundational component to create custom interactions.

Third-party routing library

A common scenario is client-side navigation without a server request. The ButtonBase component offers the component prop for this purpose. See a detailed guide for more information.

Limitations

Cursor not-allowed

The ButtonBase component applies pointer-events: none; to disabled buttons, which prevents the display of a disabled cursor.
To use a not-allowed cursor, you have two approaches:
  1. CSS only. Remove the pointer-events style from the disabled state of the <button> element:
.MuiButtonBase-root:disabled {
  cursor: not-allowed;
  pointer-events: auto;
}
However, consider the following:
  • Add pointer-events: none; back when displaying tooltips on disabled elements.
  • The cursor won't change if you use an element other than a button, such as a link <a>.
  1. DOM change. Wrap the button in a container:
<span style={{ cursor: 'not-allowed' }}>
  <Button component={Link} disabled>
    disabled
  </Button>
</span>
This method supports any element, such as a link <a>.