Skip to content

Material 3

Components

App bar

App bars are placed at the top of the screen to help people navigate through a product.

9:30

Explore Banff

Trails, gondolas and wildlife

Lake Louise, Moraine Lake and the Icefields Parkway are a day trip from town, and the gondola up Sulphur Mountain runs year round.

App bars are placed at the top of the screen to help people navigate through a product. They show information about the page, key actions, and navigation actions like Back or Menu. An app bar typically holds:

  • A leading button, such as a menu icon or a back arrow
  • A headline that describes the current page, the current section or the product
  • One or two essential actions

To display more page actions, use a toolbar.

import { AppBar, Icon, IconButton } from '@material-web/react'
import { Button, Heading, Text } from 'react-aria-components'

Basic app bar

Write the parts of the bar as its children, and give each a slot. See Slots.

Explore Banff

Hiking trails, gondolas, wildlife, and more

Lake Louise, Moraine Lake and the Icefields Parkway are a day trip from town, and the gondola up Sulphur Mountain runs year round.

Lake Louise, Moraine Lake and the Icefields Parkway are a day trip from town, and the gondola up Sulphur Mountain runs year round.

Lake Louise, Moraine Lake and the Icefields Parkway are a day trip from town, and the gondola up Sulphur Mountain runs year round.

Lake Louise, Moraine Lake and the Icefields Parkway are a day trip from town, and the gondola up Sulphur Mountain runs year round.

Lake Louise, Moraine Lake and the Icefields Parkway are a day trip from town, and the gondola up Sulphur Mountain runs year round.

Lake Louise, Moraine Lake and the Icefields Parkway are a day trip from town, and the gondola up Sulphur Mountain runs year round.

Lake Louise, Moraine Lake and the Icefields Parkway are a day trip from town, and the gondola up Sulphur Mountain runs year round.

Lake Louise, Moraine Lake and the Icefields Parkway are a day trip from town, and the gondola up Sulphur Mountain runs year round.

Lake Louise, Moraine Lake and the Icefields Parkway are a day trip from town, and the gondola up Sulphur Mountain runs year round.

Lake Louise, Moraine Lake and the Icefields Parkway are a day trip from town, and the gondola up Sulphur Mountain runs year round.

Lake Louise, Moraine Lake and the Icefields Parkway are a day trip from town, and the gondola up Sulphur Mountain runs year round.

Lake Louise, Moraine Lake and the Icefields Parkway are a day trip from town, and the gondola up Sulphur Mountain runs year round.

import { AppBar, Icon, IconButton } from '@material-web/react'
import { Heading, Text } from 'react-aria-components'

const paragraphs = Array.from({ length: 12 }, (_, index) => (
  <p key={index} className="m-0 px-space-200 py-space-100 text-body-lg">
    Lake Louise, Moraine Lake and the Icefields Parkway are a day trip from town, and the gondola up
    Sulphur Mountain runs year round.
  </p>
))

export default function Basic() {
  return (
    <div className="h-96 w-full overflow-y-auto">
      <AppBar variant="medium-flexible" scrollBehavior="exit-until-collapsed">
        <IconButton slot="leading" aria-label="Back">
          <Icon name="arrow_back" />
        </IconButton>
        <Heading slot="headline" level={2}>
          Explore Banff
        </Heading>
        <Text slot="subtitle">Hiking trails, gondolas, wildlife, and more</Text>
        <IconButton slot="trailing" variant="tonal" aria-label="Share">
          <Icon name="share" />
        </IconButton>
      </AppBar>
      {paragraphs}
    </div>
  )
}

The AppBar comes in three variants. Set variant to small (the default), medium-flexible or large-flexible.

Small app bar

Use a small app bar in dense layouts, or when a page is scrolled. A small bar is one 64dp row, with its text between the leading and trailing elements and the headline on one line.

Hiking trips with Elie in Santa Monica and Joshua Tree

import { AppBar, Icon, IconButton } from '@material-web/react'
import { Heading } from 'react-aria-components'

export default function Small() {
  return (
    <AppBar>
      <IconButton slot="leading" aria-label="Back">
        <Icon name="arrow_back" />
      </IconButton>
      <Heading slot="headline" level={2}>
        Hiking trips with Elie in Santa Monica and Joshua Tree
      </Heading>
      <IconButton slot="trailing" aria-label="Map">
        <Icon name="map" />
      </IconButton>
      <IconButton slot="trailing" aria-label="More options">
        <Icon name="more_vert" />
      </IconButton>
    </AppBar>
  )
}

Medium flexible app bar

Use a medium flexible app bar to display a larger headline. A flexible bar shows its text under the row, in a larger type style. The headline wraps to two lines at most, and the bar is as tall as its text.

Hiking trips with Elie in Santa Monica and Joshua Tree

import { AppBar, Icon, IconButton } from '@material-web/react'
import { Heading } from 'react-aria-components'

export default function MediumFlexible() {
  return (
    <AppBar variant="medium-flexible">
      <IconButton slot="leading" aria-label="Back">
        <Icon name="arrow_back" />
      </IconButton>
      <Heading slot="headline" level={2}>
        Hiking trips with Elie in Santa Monica and Joshua Tree
      </Heading>
      <IconButton slot="trailing" aria-label="Map">
        <Icon name="map" />
      </IconButton>
      <IconButton slot="trailing" aria-label="More options">
        <Icon name="more_vert" />
      </IconButton>
    </AppBar>
  )
}

Large flexible app bar

Use a large flexible app bar to emphasize the headline of the page. It lays out its text as a medium flexible bar does, in a type style larger still.

Hiking trips with Elie in Santa Monica and Joshua Tree

import { AppBar, Icon, IconButton } from '@material-web/react'
import { Heading } from 'react-aria-components'

export default function LargeFlexible() {
  return (
    <AppBar variant="large-flexible">
      <IconButton slot="leading" aria-label="Back">
        <Icon name="arrow_back" />
      </IconButton>
      <Heading slot="headline" level={2}>
        Hiking trips with Elie in Santa Monica and Joshua Tree
      </Heading>
      <IconButton slot="trailing" aria-label="Map">
        <Icon name="map" />
      </IconButton>
      <IconButton slot="trailing" aria-label="More options">
        <Icon name="more_vert" />
      </IconButton>
    </AppBar>
  )
}

A flexible bar can collapse into a small app bar as the page scrolls. See Collapse app bar.

Slots

  1. leading
  2. headline
  3. subtitle
  4. search
  5. trailing
SlotChildUse
leadingOne element: an IconButton, a Button, a Link, an Icon or an element of your ownThe start of the row
headlineA HeadingIn the row of a small bar, under the row of a flexible bar
subtitleA TextUnder the headline
searchA Button or a Link, in place of the headlineIn the row, between the leading and trailing elements
trailingUp to three elements, of the same kindsThe end of the row
  • Checked slots: A Heading, Text, Button, Link or Icon with a slot the bar does not have throws an Invalid slot error. A Heading or a Text with no slot throws an error too.
  • Your own elements: An element of your own is placed by its slot attribute, which is not checked. Always give it one: without a slot, it is placed under the row.

Import Heading, Text, Button and Link from react-aria-components. See Slots.

Headline and subtitle

Put a Heading in the headline slot and a Text in the subtitle slot. The subtitle is shown under the headline. Keep the headline brief enough to fit in the bar, and use the subtitle to add context to the page.

Recap from June 12-19

8 photos

Recap from June 12-19

8 photos

Recap from June 12-19

8 photos
import { AppBar, Icon, IconButton } from '@material-web/react'
import { Heading, Text } from 'react-aria-components'

export default function HeadlineAndSubtitle() {
  return (
    <div className="flex flex-col gap-space-300">
      <AppBar>
        <IconButton slot="leading" aria-label="Back">
          <Icon name="arrow_back" />
        </IconButton>
        <Heading slot="headline" level={2}>
          Recap from June 12-19
        </Heading>
        <Text slot="subtitle">8 photos</Text>
        <IconButton slot="trailing" aria-label="Favorite">
          <Icon name="favorite" />
        </IconButton>
      </AppBar>
      <AppBar className="text-center">
        <IconButton slot="leading" aria-label="Back">
          <Icon name="arrow_back" />
        </IconButton>
        <Heading slot="headline" level={2}>
          Recap from June 12-19
        </Heading>
        <Text slot="subtitle">8 photos</Text>
        <IconButton slot="trailing" aria-label="Favorite">
          <Icon name="favorite" />
        </IconButton>
      </AppBar>
      <AppBar variant="large-flexible" className="text-center">
        <IconButton slot="leading" aria-label="Back">
          <Icon name="arrow_back" />
        </IconButton>
        <Heading slot="headline" level={2}>
          Recap from June 12-19
        </Heading>
        <Text slot="subtitle">8 photos</Text>
        <IconButton slot="trailing" aria-label="Favorite">
          <Icon name="favorite" />
        </IconButton>
      </AppBar>
    </div>
  )
}
  • Heading level: The headline is a level 1 heading. To change that, set level on the Heading.
  • Alignment: The text starts at the leading edge. Set className="text-center" on the bar to center it.
  • Image: To show an image or a logo in place of the headline text, put it inside the Heading and give it an alt, which names the headline.

Leading and trailing elements

Give one element the leading slot, and up to three elements the trailing slot: an IconButton, an Icon, or an element of your own, such as an avatar. An Icon in either slot is sized by the bar.

Inbox

Inbox

A

New message

import { AppBar, Icon, IconButton } from '@material-web/react'
import { Heading } from 'react-aria-components'

export default function LeadingAndTrailing() {
  return (
    <div className="flex flex-col gap-space-300">
      <AppBar>
        <Heading slot="headline" level={2}>
          Inbox
        </Heading>
        <IconButton slot="trailing" aria-label="Search">
          <Icon name="search" />
        </IconButton>
      </AppBar>
      <AppBar>
        <IconButton slot="leading" aria-label="Menu">
          <Icon name="menu" />
        </IconButton>
        <Heading slot="headline" level={2}>
          Inbox
        </Heading>
        <IconButton slot="trailing" aria-label="Search">
          <Icon name="search" />
        </IconButton>
        <IconButton slot="trailing" aria-label="Today">
          <Icon name="event" />
        </IconButton>
        <span
          slot="trailing"
          role="img"
          aria-label="Account"
          className="grid size-8 place-items-center rounded-full bg-primary text-title-md text-on-primary"
        >
          A
        </span>
      </AppBar>
      <AppBar>
        <IconButton slot="leading" aria-label="Back">
          <Icon name="arrow_back" />
        </IconButton>
        <Heading slot="headline" level={2}>
          New message
        </Heading>
        <IconButton slot="trailing" variant="filled" aria-label="Send">
          <Icon name="send" className="icon-filled" />
        </IconButton>
      </AppBar>
    </div>
  )
}
  • Leading button: Use the leading button for navigating the product. It is typically a menu icon, or a back arrow that returns to the previous screen.
  • Trailing buttons: Place the most used actions closest to the leading edge.
  • Filled and tonal buttons: If you change a trailing icon button to the filled or tonal variant, use only one icon button.

Placement

The bar stays at the top of its nearest scrolling ancestor, or of the page, above the content. It keeps its own room in the layout, so the content starts under it and needs no offset.

Write the bar inside the element that scrolls, before the content. With no scrolling ancestor, the bar follows the scroll of the page.

Top stories

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

import { AppBar, Icon, IconButton } from '@material-web/react'
import { Heading } from 'react-aria-components'

const paragraphs = Array.from({ length: 12 }, (_, index) => (
  <p key={index} className="m-0 px-space-200 py-space-100 text-body-lg">
    Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it
    looks absolutely incredible from what I can see.
  </p>
))

export default function Pinned() {
  return (
    <div className="h-80 overflow-y-auto">
      <AppBar>
        <IconButton slot="leading" aria-label="Back">
          <Icon name="arrow_back" />
        </IconButton>
        <Heading slot="headline" level={2}>
          Top stories
        </Heading>
        <IconButton slot="trailing" aria-label="More options">
          <Icon name="more_vert" />
        </IconButton>
      </AppBar>
      {paragraphs}
    </div>
  )
}

Scrolling

Set scrollBehavior to choose what the bar does as the content scrolls:

scrollBehaviorAs the content scrolls
pinned (the default)The bar stays in place.
enter-alwaysThe bar collapses as the content scrolls down, and expands as soon as the content scrolls back up, anywhere in the page.
exit-until-collapsedThe bar collapses the same way, and expands only when the content is scrolled all the way back to the top.

When a scroll stops with the bar part way collapsed, the bar settles on the nearer end and scrolls the content with it.

Hide app bar

A small bar collapses completely, which leaves the whole screen to the content.

Aki Aro

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

import { AppBar, Icon, IconButton } from '@material-web/react'
import { Heading } from 'react-aria-components'

const paragraphs = Array.from({ length: 12 }, (_, index) => (
  <p key={index} className="m-0 px-space-200 py-space-100 text-body-lg">
    Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it
    looks absolutely incredible from what I can see.
  </p>
))

export default function EnterAlways() {
  return (
    <div className="h-80 overflow-y-auto">
      <AppBar scrollBehavior="enter-always">
        <IconButton slot="leading" aria-label="Back">
          <Icon name="arrow_back" />
        </IconButton>
        <Heading slot="headline" level={2}>
          Aki Aro
        </Heading>
        <IconButton slot="trailing" aria-label="More options">
          <Icon name="more_vert" />
        </IconButton>
      </AppBar>
      {paragraphs}
    </div>
  )
}

Collapse app bar

A flexible bar collapses into a small app bar, with its headline and subtitle in the row. The row shows a copy of their content, without its event handlers, so keep links and buttons out of a headline that collapses. Use exit-until-collapsed to keep it small until the page is scrolled back to the top.

Recap from June 12-19

8 photos

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it looks absolutely incredible from what I can see.

import { AppBar, Icon, IconButton } from '@material-web/react'
import { Heading, Text } from 'react-aria-components'

const paragraphs = Array.from({ length: 12 }, (_, index) => (
  <p key={index} className="m-0 px-space-200 py-space-100 text-body-lg">
    Hey! I’ve got pics and more info on our cabin for the weekend. Get ready to be impressed: it
    looks absolutely incredible from what I can see.
  </p>
))

export default function ExitUntilCollapsed() {
  return (
    <div className="h-96 overflow-y-auto">
      <AppBar variant="large-flexible" scrollBehavior="exit-until-collapsed">
        <IconButton slot="leading" aria-label="Back">
          <Icon name="arrow_back" />
        </IconButton>
        <Heading slot="headline" level={2}>
          Recap from June 12-19
        </Heading>
        <Text slot="subtitle">8 photos</Text>
        <IconButton slot="trailing" aria-label="Search">
          <Icon name="search" />
        </IconButton>
        <IconButton slot="trailing" aria-label="Favorite">
          <Icon name="favorite" />
        </IconButton>
      </AppBar>
      {paragraphs}
    </div>
  )
}

Fill on scroll

Once the content has scrolled under it, the bar and its search bar change to a contrasting fill color, which separates them from the content. Scroll the pinned bar above to see it.

Set isScrolled to control the fill yourself.

Flat

On scroll

import { AppBar, Icon, IconButton } from '@material-web/react'
import { Button, Heading } from 'react-aria-components'

export default function OnScroll() {
  return (
    <div className="flex flex-col gap-space-300">
      {[false, true].map((isScrolled) => (
        <AppBar key={String(isScrolled)} isScrolled={isScrolled}>
          <IconButton slot="leading" aria-label="Back">
            <Icon name="arrow_back" />
          </IconButton>
          <Heading slot="headline" level={2}>
            {isScrolled ? 'On scroll' : 'Flat'}
          </Heading>
          <IconButton slot="trailing" aria-label="Search">
            <Icon name="search" />
          </IconButton>
        </AppBar>
      ))}
      <AppBar isScrolled className="text-center">
        <IconButton slot="leading" aria-label="Menu">
          <Icon name="menu" />
        </IconButton>
        <Button slot="search">Search product</Button>
      </AppBar>
    </div>
  )
}

App bar with menu

To open a menu from the bar, wrap a trailing IconButton and its MenuPopover in a MenuTrigger. The button keeps its slot.

Photos

import { AppBar, Icon, IconButton, Menu, MenuItem, MenuPopover } from '@material-web/react'
import { Heading, MenuTrigger } from 'react-aria-components'

export default function AppBarWithMenu() {
  return (
    <AppBar>
      <IconButton slot="leading" aria-label="Menu">
        <Icon name="menu" />
      </IconButton>
      <Heading slot="headline" level={2}>
        Photos
      </Heading>
      <MenuTrigger>
        <IconButton slot="trailing" aria-label="Account">
          <Icon name="account_circle" />
        </IconButton>
        <MenuPopover>
          <Menu>
            <MenuItem>Profile</MenuItem>
            <MenuItem>My account</MenuItem>
            <MenuItem>Sign out</MenuItem>
          </Menu>
        </MenuPopover>
      </MenuTrigger>
    </AppBar>
  )
}

Note: Avoid a trailing button that opens a menu with more actions. If the page needs more actions, place them in a toolbar instead.

Search app bar

Use a search app bar on home pages when search is key to the product. Put a Button in the search slot in place of the headline, and open your search view in its onPress. The slot also takes a Link with an href.

Write the hinted search text as its children, with an Icon in its leading or trailing slot to show an icon before or after the text. The search bar sizes itself to the space between the leading and trailing elements.

A
import { AppBar, Icon, IconButton } from '@material-web/react'
import { Button } from 'react-aria-components'

export default function SearchAppBar() {
  return (
    <AppBar className="text-center">
      <IconButton slot="leading" aria-label="Menu">
        <Icon name="menu" />
      </IconButton>
      <Button slot="search">
        <Icon slot="leading" name="search" />
        Search product
        <Icon slot="trailing" name="mic" className="icon-filled" />
      </Button>
      <span
        slot="trailing"
        role="img"
        aria-label="Account"
        className="grid size-8 place-items-center rounded-full bg-primary text-title-md text-on-primary"
      >
        A
      </span>
    </AppBar>
  )
}

Note: Leave variant at small for a search app bar.

Customization

Pass classes in className to restyle one bar. They go on its <header> element, with style and the rest of the props. See Styling for the classes and the theme.

  • States: To style the bar by its state, target its data-scrolled and data-collapsed attributes. A bar has data-scrolled while it shows its fill on scroll, and a flexible bar has data-collapsed while it is collapsed into a small app bar.
  • Functions: The children of the search bar can be a function of its state. The children of the AppBar cannot. See Children as a function.
  • Every app bar: To restyle all the app bars at once, change the theme.