Overview
The App Bar (also known as a header or top app bar) is positioned at the top of the screen and displays navigation, branding, screen titles, and actions. It provides a consistent location for navigation and important actions. App Bars are commonly used for:- Primary navigation with menu buttons and links
- Branding with logos and application names
- Search functionality
- User account actions and notifications
- Context-specific actions for the current view
Import
Basic Usage
A simple app bar with a title and login button.With Navigation Drawer
App bar integrated with a responsive navigation drawer for mobile and desktop.Color Variants
The AppBar supports all theme colors plus additional options.Positioning
Control how the app bar is positioned on the page.Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | The content of the app bar, typically a Toolbar |
color | 'default' | 'inherit' | 'primary' | 'secondary' | 'transparent' | 'error' | 'info' | 'success' | 'warning' | 'primary' | The color of the component from the theme palette |
position | 'fixed' | 'absolute' | 'sticky' | 'static' | 'relative' | 'fixed' | The positioning type |
elevation | number | 4 | Shadow depth, accepts values between 0 and 24 |
enableColorOnDark | boolean | false | If true, the color prop is applied in dark mode |
square | boolean | true | If false, rounded corners are enabled |
sx | SxProps<Theme> | - | System prop for defining CSS styles |
component | ElementType | 'header' | The component used for the root node |
Inherited Props
AppBar inherits all props from the Paper component, including:variant- The variant to use ('elevation'or'outlined')- All standard HTML attributes for the header element
Positioning Behavior
Theposition prop determines how the AppBar behaves:
fixed(default): Positioned relative to the viewport, stays in place when scrolling. Useful for persistent navigation.absolute: Positioned relative to the nearest positioned ancestor. Useful for overlaying content.sticky: Switches between relative and fixed based on scroll position. Note: Not universally supported, falls back to static.static: Normal document flow positioning. Does not stay visible when scrolling.relative: Positioned relative to its normal position.
Color Options
The AppBar supports extended color options:- Theme colors:
primary,secondary,default,inherit - Status colors:
error,info,success,warning - Special:
transparent- removes background color
Elevation
By default, AppBar has an elevation of 4. You can customize this:Toolbar Component
The AppBar is typically used with the Toolbar component, which provides proper padding and flex layout:Responsive Considerations
When usingposition="fixed", remember to add spacing to your content so it doesn’t hide behind the AppBar:
Accessibility
- Use semantic
<nav>element by settingcomponent="nav"when AppBar contains navigation - Ensure sufficient color contrast for text and icons
- Provide
aria-labelfor icon buttons - Make sure interactive elements are keyboard accessible
Best Practices
- Keep it simple - Don’t overcrowd the app bar with too many actions
- Prioritize actions - Put the most important actions on the right (in LTR layouts)
- Use consistent positioning - Stick with one position type throughout your app
- Mobile first - Design for mobile screens first, then enhance for desktop
- Consider z-index - AppBar has a high z-index; ensure other positioned elements don’t conflict
API Reference
- AppBar API - Full API documentation
- Inherits Paper API
- Source:
packages/mui-material/src/AppBar/AppBar.d.ts:1