0 Tk

app-bar

Import

import AppBar from '@mui/material/AppBar';
// or
import { AppBar } from '@mui/material';

Learn about the difference by reading this guide on minimizing bundle size.

Props of the Paper 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 ‘default’ | ‘inherit’ | ‘primary’ | ‘secondary’ | ‘transparent’ | ‘error’ | ‘info’ | ‘success’ | ‘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.
enableColorOnDark bool false If true, the color prop is applied in dark mode.
position ‘absolute’ | ‘fixed’ | ‘relative’ | ‘static’ | ‘sticky’ ‘fixed’ The positioning type. The behavior of the different options is described in the MDN web docs. Note: sticky is not universally supported and will fall back to static when unavailable.
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.

The ref is forwarded to the root element.

Inheritance

While not explicitly documented above, the props of the Paper component are also available in AppBar. You can take advantage of this to target nested components.

Theme default props

You can use MuiAppBar 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
.MuiAppBar-colorDefault colorDefault Styles applied to the root element if color="default".
.MuiAppBar-colorError colorError Styles applied to the root element if color="error".
.MuiAppBar-colorInfo colorInfo Styles applied to the root element if color="info".
.MuiAppBar-colorInherit colorInherit Styles applied to the root element if color="inherit".
.MuiAppBar-colorPrimary colorPrimary Styles applied to the root element if color="primary".
.MuiAppBar-colorSecondary colorSecondary Styles applied to the root element if color="secondary".
.MuiAppBar-colorSuccess colorSuccess Styles applied to the root element if color="success".
.MuiAppBar-colorTransparent colorTransparent Styles applied to the root element if color="transparent".
.MuiAppBar-colorWarning colorWarning Styles applied to the root element if color="warning".
.MuiAppBar-positionAbsolute positionAbsolute Styles applied to the root element if position="absolute".
.MuiAppBar-positionFixed positionFixed Styles applied to the root element if position="fixed".
.MuiAppBar-positionRelative positionRelative Styles applied to the root element if position="relative".
.MuiAppBar-positionStatic positionStatic Styles applied to the root element if position="static".
.MuiAppBar-positionSticky positionSticky Styles applied to the root element if position="sticky".
.MuiAppBar-root root Styles applied to the root element.

You can override the style of the component using one of these customization options:

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.