Appbar
An app bar is a header component that displays information and actions relating to the current screen, providing navigation, branding, and key functionality.
The App Bar is a critical element in your application's UX. It establishes hierarchy, provides essential navigation, and communicates your brand. Follow these guidelines to use app bars effectively.
When to Use
Use an App Bar when
- You need to display a page title or screen name
- Your application requires persistent navigation
- You want to establish consistent branding across pages
- You need to provide quick access to key actions
- Your application spans multiple sections or views that users navigate between
- You need to display user information or account actions
Avoid App Bars when
- You're building a simple, single-purpose page with no navigation
- Space is extremely limited (consider simplifying to essential elements only)
- The app bar would duplicate navigation already provided elsewhere
Accessibility
- Ensure the app bar has sufficient color contrast (WCAG AA compliant)
- Use semantic HTML and ARIA labels for navigation
- Make interactive elements keyboard accessible
- Ensure the app bar doesn't interfere with screen reader navigation
- Use proper heading hierarchy within the app bar content
- Provide visible focus indicators for all interactive elements
Props
children: The content of the componentclasses: Override or extend the styles applied to the componentcolor: The color of the component ("default" | "inherit" | "primary" | "secondary" | "transparent" | "error" | "info" | "success" | "warning")component: The component used for the root node. Either a string to use a HTML element or a componentelevation: Shadow depth, corresponds to dp in the spec. It accepts values between 0 and 24 inclusiveenableColorOnDark: Iftrue, the color prop is applied in dark modeposition: The positioning type ("absolute" | "fixed" | "relative" | "static" | "sticky")square: Iffalse, rounded corners are enabledsx: The system prop that allows defining system overrides as well as additional CSS styles