---
productId: material-ui
title: React Button component
components: Button, IconButton, ButtonBase
materialDesign: https://m2.material.io/components/buttons
githubLabel: 'scope: button'
waiAria: https://www.w3.org/WAI/ARIA/apg/patterns/button/
githubSource: packages/mui-material/src/Button
---
# Button
Buttons allow users to take actions, and make choices, with a single tap.
Buttons communicate actions that users can take. They are typically placed throughout your UI, in places like:
- Modal windows
- Forms
- Cards
- Toolbars
## Basic button
The `Button` comes with three variants: text (default), contained, and outlined.
```tsx
import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
export default function BasicButtons() {
return (
);
}
```
### Text button
[Text buttons](https://m2.material.io/components/buttons#text-button)
are typically used for less-pronounced actions, including those located: in dialogs, in cards.
In cards, text buttons help maintain an emphasis on card content.
```tsx
import Button from '@mui/material/Button';
import Stack from '@mui/material/Stack';
export default function TextButtons() {
return (
);
}
```
### Contained button
[Contained buttons](https://m2.material.io/components/buttons#contained-button)
are high-emphasis, distinguished by their use of elevation and fill.
They contain actions that are primary to your app.
```tsx
import Button from '@mui/material/Button';
import Stack from '@mui/material/Stack';
export default function ContainedButtons() {
return (
);
}
```
You can remove the elevation with the `disableElevation` prop.
```tsx
import Button from '@mui/material/Button';
export default function DisableElevation() {
return (
);
}
```
### Outlined button
[Outlined buttons](https://m2.material.io/components/buttons#outlined-button) are medium-emphasis buttons.
They contain actions that are important but aren't the primary action in an app.
Outlined buttons are also a lower emphasis alternative to contained buttons,
or a higher emphasis alternative to text buttons.
```tsx
import Button from '@mui/material/Button';
import Stack from '@mui/material/Stack';
export default function OutlinedButtons() {
return (
);
}
```
## Handling clicks
All components accept an `onClick` handler that is applied to the root DOM element.
```jsx
```
Note that the documentation [avoids](/material-ui/guides/api/#native-properties) mentioning native props (there are a lot) in the API section of the components.
## Color
```tsx
import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
export default function ColorButtons() {
return (
);
}
```
In addition to using the default button colors, you can add custom ones, or disable any you don't need. See the [Adding new colors](/material-ui/customization/palette/#custom-colors) examples for more info.
## Sizes
For larger or smaller buttons, use the `size` prop.
```tsx
import Box from '@mui/material/Box';
import Button from '@mui/material/Button';
export default function ButtonSizes() {
return (
);
}
```
## Buttons with icons and label
Sometimes you might want to have icons for certain buttons to enhance the UX of the application as we recognize logos more easily than plain text. For example, if you have a delete button you can label it with a dustbin icon.
```tsx
import Button from '@mui/material/Button';
import DeleteIcon from '@mui/icons-material/Delete';
import SendIcon from '@mui/icons-material/Send';
import Stack from '@mui/material/Stack';
export default function IconLabelButtons() {
return (
}>
Delete
}>
Send
);
}
```
## Icon button
Icon buttons are commonly found in app bars and toolbars.
Icons are also appropriate for toggle buttons that allow a single choice to be selected or
deselected, such as adding or removing a star to an item.
```tsx
import IconButton from '@mui/material/IconButton';
import Stack from '@mui/material/Stack';
import DeleteIcon from '@mui/icons-material/Delete';
import AlarmIcon from '@mui/icons-material/Alarm';
import AddShoppingCartIcon from '@mui/icons-material/AddShoppingCart';
export default function IconButtons() {
return (
);
}
```
### Sizes
For larger or smaller icon buttons, use the `size` prop.
```tsx
import Stack from '@mui/material/Stack';
import IconButton from '@mui/material/IconButton';
import DeleteIcon from '@mui/icons-material/Delete';
export default function IconButtonSizes() {
return (
);
}
```
### Colors
Use `color` prop to apply theme color palette to component.
```tsx
import Stack from '@mui/material/Stack';
import IconButton from '@mui/material/IconButton';
import Fingerprint from '@mui/icons-material/Fingerprint';
export default function IconButtonColors() {
return (
);
}
```
### Loading
Starting from v6.4.0, use `loading` prop to set icon buttons in a loading state and disable interactions.
```tsx
import * as React from 'react';
import Tooltip from '@mui/material/Tooltip';
import IconButton from '@mui/material/IconButton';
import ShoppingCartIcon from '@mui/icons-material/ShoppingCart';
export default function LoadingIconButton() {
const [loading, setLoading] = React.useState(false);
React.useEffect(() => {
const timeout = setTimeout(() => {
setLoading(false);
}, 2000);
return () => clearTimeout(timeout);
});
return (
setLoading(true)} loading={loading}>
);
}
```
### Badge
You can use the [`Badge`](/material-ui/react-badge/) component to add a badge to an `IconButton`.
```tsx
import { styled } from '@mui/material/styles';
import IconButton from '@mui/material/IconButton';
import Badge, { badgeClasses } from '@mui/material/Badge';
import ShoppingCartIcon from '@mui/icons-material/ShoppingCartOutlined';
const CartBadge = styled(Badge)`
& .${badgeClasses.badge} {
top: -12px;
right: -6px;
}
`;
export default function IconButtonWithBadge() {
return (
);
}
```
## File upload
To create a file upload button, turn the button into a label using `component="label"` and then create a visually-hidden input with type `file`.
```tsx
import { styled } from '@mui/material/styles';
import Button from '@mui/material/Button';
import CloudUploadIcon from '@mui/icons-material/CloudUpload';
const VisuallyHiddenInput = styled('input')({
clip: 'rect(0 0 0 0)',
clipPath: 'inset(50%)',
height: 1,
overflow: 'hidden',
position: 'absolute',
bottom: 0,
left: 0,
whiteSpace: 'nowrap',
width: 1,
});
export default function InputFileUpload() {
return (
}
>
Upload files
console.log(event.target.files)}
multiple
/>
);
}
```
## Loading
Starting from v6.4.0, use the `loading` prop to set buttons in a loading state and disable interactions.
```tsx
import Button from '@mui/material/Button';
import SaveIcon from '@mui/icons-material/Save';
import Stack from '@mui/material/Stack';
export default function LoadingButtons() {
return (
}
variant="outlined"
>
Save
}
variant="outlined"
>
Full width
}
variant="outlined"
>
Full width
}
>
Save
);
}
```
Toggle the loading switch to see the transition between the different states.
```tsx
import * as React from 'react';
import Button from '@mui/material/Button';
import Box from '@mui/material/Box';
import FormControlLabel from '@mui/material/FormControlLabel';
import Switch from '@mui/material/Switch';
import SaveIcon from '@mui/icons-material/Save';
import SendIcon from '@mui/icons-material/Send';
export default function LoadingButtonsTransition() {
const [loading, setLoading] = React.useState(true);
function handleClick() {
setLoading(true);
}
return (
);
}
```
:::warning
When the `loading` prop is set to `boolean`, the loading wrapper is always present in the DOM to prevent a [Google Translation Crash](https://github.com/mui/material-ui/issues/27853).
The `loading` value should always be `null` or `boolean`. The pattern below is not recommended as it can cause the Google Translation crash:
```jsx