Skip to content

Material 3

Components

Side sheet

Side sheets show secondary content anchored to the side of the screen.

Chairs

Filters

Side sheets show secondary content anchored to the side of the screen. Use a side sheet to provide optional content and actions without interrupting the main content, from a list of actions to supplemental content in a table.

A SideSheet comes in two variants:

  • Standard (the default): The sheet sits beside the page's body, at the end of a row that makes room for it, and the page remains in use. Standard sheets are used mostly in medium to expanded windows, like tablet and desktop.
  • Modal, with isModal: The sheet opens in front of the page over a scrim and stays until it is closed. Modal sheets are preferred in compact windows, like mobile.

In compact windows, consider a bottom sheet instead.

A side sheet is composed of these parts:

PartUse
SheetTriggerThe trigger. Wraps the button that opens the sheet and the SideSheet, with the button first. Without it, control the sheet with isOpen and onOpenChange.
SideSheetThe sheet: a standard sheet (the default) or, with isModal, a modal sheet
SideSheetHeaderThe header, first in the sheet. It holds the headline and the icon buttons. See Header, content and actions.
import { SheetTrigger, SideSheet, SideSheetHeader } from '@material-web/react'
import { Heading } from 'react-aria-components'

Basic side sheet

Wrap the button that opens the sheet and the sheet in a SheetTrigger. Write the sheet's content as its children: a SideSheetHeader first, then the rest, as described under Header, content and actions. This sheet is a modal sheet.

import {
  Button,
  Checkbox,
  Divider,
  Icon,
  IconButton,
  SheetTrigger,
  SideSheet,
  SideSheetHeader,
} from '@material-web/react'
import { Heading } from 'react-aria-components'

const labels = ['Events', 'Personal', 'Projects', 'Reminders', 'Family', 'Travel', 'Work']

export default function Basic() {
  return (
    <SheetTrigger>
      <Button variant="tonal">Show filters</Button>
      <SideSheet isModal>
        <SideSheetHeader>
          <Heading slot="title">Filters</Heading>
          <IconButton aria-label="Close" slot="close">
            <Icon name="close" />
          </IconButton>
        </SideSheetHeader>
        <div className="flex min-h-0 grow flex-col items-start overflow-y-auto px-space-300 py-space-200 text-body-lg">
          {labels.map((label) => (
            <Checkbox key={label} className="h-14 shrink-0">
              {label}
            </Checkbox>
          ))}
        </div>
        <Divider />
        <div className="flex gap-space-100 px-space-300 pt-space-200 pb-space-300">
          <Button variant="filled" slot="close">
            Save
          </Button>
          <Button variant="outlined" slot="close">
            Cancel
          </Button>
        </div>
      </SideSheet>
    </SheetTrigger>
  )
}

Set isModal for a modal sheet. It is at the end edge of the window and as tall as the window. Without a trigger, control the sheet with isOpen and onOpenChange, or set defaultOpen to start with it open, as with React Aria's Sheet.

While a modal sheet is open, the page behind it cannot be used or scrolled, and the focus stays in the sheet. A menu in a modal sheet opens in front of it. Another dialog or modal sheet opened from it shows in front of it, and Escape closes the one in front.

Dismissal

A click on the scrim, Escape, and a swipe toward the end edge of the window close a modal sheet. Set preventDismissal to turn all of these off. Every side sheet needs a close icon button: put one in the header with slot="close". Any other button in the sheet with slot="close", such as an action, closes it too.

import {
  Button,
  Divider,
  Icon,
  IconButton,
  SheetTrigger,
  SideSheet,
  SideSheetHeader,
  TextField,
} from '@material-web/react'
import { Heading } from 'react-aria-components'

export default function PreventDismissal() {
  return (
    <SheetTrigger>
      <Button variant="tonal">Edit profile</Button>
      <SideSheet isModal preventDismissal>
        <SideSheetHeader>
          <Heading slot="title">Edit profile</Heading>
          <IconButton aria-label="Close" slot="close">
            <Icon name="close" />
          </IconButton>
        </SideSheetHeader>
        <div className="min-h-0 grow overflow-y-auto px-space-300 py-space-200">
          <TextField label="Display name" variant="outlined" className="w-full" />
        </div>
        <Divider />
        <div className="flex gap-space-100 px-space-300 pt-space-200 pb-space-300">
          <Button variant="filled" slot="close">
            Save
          </Button>
          <Button variant="outlined" slot="close">
            Cancel
          </Button>
        </div>
      </SideSheet>
    </SheetTrigger>
  )
}

To decide for each press outside the sheet whether it closes the sheet, pass a function as shouldCloseOnInteractOutside. It receives the pressed element, and the sheet stays open when it returns false.

Swiping

A swipe toward the end edge of the window closes a modal sheet. A swipe released part way either returns the sheet to its place or closes it. With preventDismissal, a swipe does not move the sheet. A finger swipes the sheet, and a mouse does not drag it.

A side sheet has no snapPoints, and a standard sheet cannot be swiped.

Standard side sheet

Without isModal, a sheet is a standard sheet. It has no scrim, and the page beside it remains in use.

A standard sheet is a flex item. Write it after the body, in a row as tall as the sheet should be (flex h-dvh, for example), and give the body min-w-0 grow. The sheet stretches to the row's height at the end of the row.

<div className="flex h-dvh">
  <main className="min-w-0 grow">…</main>
  <SideSheet isOpen={info} onOpenChange={setInfo}>
    …
  </SideSheet>
</div>

A standard sheet shows unless isOpen is false. Pass onOpenChange to let it be dismissed: Escape in the sheet and a button with slot="close" each call onOpenChange with false. The sheet stays until you set isOpen to false. Without onOpenChange, Escape does nothing in the sheet.

When a standard sheet is shown, the focus moves to the first focusable element in it, such as the close button. Tab then moves the focus out to the page. When the sheet is hidden, the focus returns to where it was.

In this example, a box stands in for the row. The info button shows and hides the sheet, and the body shrinks and grows to make room for it. The close button and Escape hide the sheet too.

Cassette Futurism
import { Icon, IconButton, SideSheet, SideSheetHeader } from '@material-web/react'
import { useState } from 'react'
import { Heading } from 'react-aria-components'

export default function Standard() {
  const [isOpen, setOpen] = useState(false)
  return (
    <div className="flex h-96 w-full bg-surface">
      <div className="box-border min-w-0 grow overflow-y-auto p-space-300">
        <div className="flex items-center justify-between pb-space-200">
          <span className="text-title-lg">Cassette Futurism</span>
          <IconButton aria-label="Info" onPress={() => setOpen(!isOpen)}>
            <Icon name="info" />
          </IconButton>
        </div>
        <div className="h-40 rounded-shape-md bg-tertiary-container" />
      </div>
      <SideSheet isOpen={isOpen} onOpenChange={setOpen}>
        <SideSheetHeader>
          <Heading slot="title">Info</Heading>
          <IconButton aria-label="Close" slot="close">
            <Icon name="close" />
          </IconButton>
        </SideSheetHeader>
        <dl className="m-0 grid min-h-0 grow grid-cols-2 content-start gap-space-100 overflow-y-auto px-space-300 py-space-200">
          <dt className="text-on-surface-variant">Artist</dt>
          <dd className="m-0">Various artists</dd>
          <dt className="text-on-surface-variant">Tracks</dt>
          <dd className="m-0">12</dd>
          <dt className="text-on-surface-variant">Length</dt>
          <dd className="m-0">48 min</dd>
        </dl>
      </SideSheet>
    </div>
  )
}

Slots

  1. title
  2. close
SlotChildUse
titleA Heading, in the headerThe sheet's headline, which names the sheet. It is an <h2> unless you set its level.
closeAny buttonCloses the sheet after its own onPress

Write a back icon button before the headline if the sheet needs one, and the close icon button after the headline, following any other icon buttons. With no headline, the last button is still at the end of the header.

Header, content and actions

A side sheet is composed of these parts, from top to bottom:

PartUse
SideSheetHeaderThe header, first in the sheet. It holds the headline and the icon buttons.
ContentThe rest of the sheet's content, laid out in a column, which scrolls vertically as a whole when it is taller than the sheet
ActionsFor bottom actions, a row of Buttons under a Divider

Give the content its side padding, and lay out the actions, with the theme's classes:

<SideSheet>
  <SideSheetHeader>…</SideSheetHeader>
  <div className="px-space-300">…</div>
  <Divider />
  <div className="flex gap-space-100 px-space-300 pt-space-200 pb-space-300">…</div>
</SideSheet>

To scroll the content on its own instead of with the sheet, between the header and the actions, give it min-h-0 grow overflow-y-auto.

A sheet can hold more than one region. In this example, a section opened from the list shows a back icon button before its headline, which returns to the list.

import {
  Button,
  Icon,
  IconButton,
  List,
  ListItem,
  SheetTrigger,
  SideSheet,
  SideSheetHeader,
} from '@material-web/react'
import { useState } from 'react'
import { Heading, Text } from 'react-aria-components'

const sections = ['Labels', 'Format', 'Last modified']

function Filters() {
  const [section, setSection] = useState<string | null>(null)
  return (
    <>
      <SideSheetHeader>
        {section && (
          <IconButton aria-label="Back" onPress={() => setSection(null)}>
            <Icon name="arrow_back" className="rtl:icon-mirrored" />
          </IconButton>
        )}
        <Heading slot="title">{section ?? 'Filters'}</Heading>
        <IconButton aria-label="Close" slot="close">
          <Icon name="close" />
        </IconButton>
      </SideSheetHeader>
      {section ? (
        <p className="m-0 px-space-300 py-space-200 text-on-surface-variant">
          Choose what to filter by {section.toLowerCase()}.
        </p>
      ) : (
        <List aria-label="Filters" className="grow overflow-y-auto">
          {sections.map((name) => (
            <ListItem
              key={name}
              id={name}
              textValue={name}
              className="bg-transparent"
              onAction={() => setSection(name)}
            >
              <Text slot="label">{name}</Text>
              <Icon slot="trailing" name="chevron_right" className="rtl:icon-mirrored" />
            </ListItem>
          ))}
        </List>
      )}
    </>
  )
}

export default function BackButton() {
  return (
    <SheetTrigger>
      <Button variant="tonal">Filter files</Button>
      <SideSheet isModal>
        <Filters />
      </SideSheet>
    </SheetTrigger>
  )
}

Detached side sheet

Set isDetached to inset either sheet 16dp from the edges of the window, or of its row, with rounded corners all around.

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

export default function ModalDetached() {
  return (
    <SheetTrigger>
      <Button variant="tonal">Show details</Button>
      <SideSheet isModal isDetached>
        <SideSheetHeader>
          <Heading slot="title">Details</Heading>
          <IconButton aria-label="Close" slot="close">
            <Icon name="close" />
          </IconButton>
        </SideSheetHeader>
        <p className="m-0 px-space-300 py-space-200 text-on-surface-variant">
          Twelve tracks by various artists, 48 minutes.
        </p>
      </SideSheet>
    </SheetTrigger>
  )
}

A detached standard sheet keeps the same margin from the body. In this example, the sheet's className sets bg-surface-container to set it off from the body.

Cassette Futurism
import { Icon, IconButton, SideSheet, SideSheetHeader } from '@material-web/react'
import { useState } from 'react'
import { Heading } from 'react-aria-components'

export default function Detached() {
  const [isOpen, setOpen] = useState(false)
  return (
    <div className="flex h-96 w-full bg-surface">
      <div className="box-border min-w-0 grow overflow-y-auto p-space-300">
        <div className="flex items-center justify-between pb-space-200">
          <span className="text-title-lg">Cassette Futurism</span>
          <IconButton aria-label="Info" onPress={() => setOpen(!isOpen)}>
            <Icon name="info" />
          </IconButton>
        </div>
        <div className="h-40 rounded-shape-md bg-tertiary-container" />
      </div>
      <SideSheet isDetached className="bg-surface-container" isOpen={isOpen} onOpenChange={setOpen}>
        <SideSheetHeader>
          <Heading slot="title">Info</Heading>
          <IconButton aria-label="Close" slot="close">
            <Icon name="close" />
          </IconButton>
        </SideSheetHeader>
        <p className="m-0 px-space-300 py-space-200 text-on-surface-variant">
          Twelve tracks by various artists, 48 minutes.
        </p>
      </SideSheet>
    </div>
  )
}

Responsive

A modal sheet in a compact window can become a standard sheet in a wider one. Set isModal from your own breakpoint, and control the sheet with isOpen and onOpenChange, which both variants take.

In this example, the sheet is modal in a window narrower than 600dp, the theme's medium breakpoint, and standard in a wider one.

Cassette Futurism
import { Icon, IconButton, SideSheet, SideSheetHeader } from '@material-web/react'
import { useState, useSyncExternalStore } from 'react'
import { Heading } from 'react-aria-components'

// A compact window: one narrower than the theme's medium breakpoint.
const compact = '(width < 600px)'

function subscribe(onChange: () => void) {
  const query = window.matchMedia(compact)
  query.addEventListener('change', onChange)
  return () => query.removeEventListener('change', onChange)
}

export default function Responsive() {
  const isCompact = useSyncExternalStore(
    subscribe,
    () => window.matchMedia(compact).matches,
    () => false,
  )
  const [isOpen, setOpen] = useState(false)
  return (
    <div className="flex h-96 w-full bg-surface">
      <div className="box-border min-w-0 grow overflow-y-auto p-space-300">
        <div className="flex items-center justify-between pb-space-200">
          <span className="text-title-lg">Cassette Futurism</span>
          <IconButton aria-label="Info" onPress={() => setOpen(!isOpen)}>
            <Icon name="info" />
          </IconButton>
        </div>
        <div className="h-40 rounded-shape-md bg-tertiary-container" />
      </div>
      <SideSheet isModal={isCompact} isOpen={isOpen} onOpenChange={setOpen}>
        <SideSheetHeader>
          <Heading slot="title">Info</Heading>
          <IconButton aria-label="Close" slot="close">
            <Icon name="close" />
          </IconButton>
        </SideSheetHeader>
        <p className="m-0 px-space-300 py-space-200 text-on-surface-variant">
          Twelve tracks by various artists, 48 minutes.
        </p>
      </SideSheet>
    </div>
  )
}

Note: Changing isModal while a sheet is shown remounts its content, so the content's scroll position and state are lost.

Right to left

A standard sheet follows the page's dir, and a modal sheet follows the locale, which I18nProvider sets. For a right-to-left language, set both: either sheet is then at the left edge, with its layout mirrored. See Internationalization.

Customization

Pass classes in className to restyle one sheet. className, style and ref apply to the sheet's container. See Styling for the classes, the states and the theme.

  • States: While a standard sheet appears and leaves, it has data-entering and data-exiting. See States.
  • Functions: className, style and children can be functions of the sheet's state, on a standard sheet and a modal one alike: state, whose close() closes the sheet, isEntering, isExiting, isExpanded (true once the whole sheet shows), position, swipeDirection, stackIndex and hasDescendants. See Children as a function.
  • Ancestors: A modal sheet is rendered at the end of the page, not inside the element it is written in. A class or a data-theme on an element around it does not reach it: set it on the SideSheet itself, or on the root element. A standard sheet is rendered where it is written. See Theme.
  • Attributes: A SideSheet also takes attributes and events of its <div>, such as id and onClick.

Width

A sheet is 256dp wide by default. To set another width, add a side-sheet-width-* class to its className. The value is a number on Tailwind's spacing scale (side-sheet-width-90), a spacing token (side-sheet-width-space-900) or any length (side-sheet-width-[22rem]). A sheet is no wider than 400dp, and a modal sheet no wider than the window less its margins.

Note: Set the width with side-sheet-width-*, not with w-*.

import {
  Button,
  Icon,
  IconButton,
  Radio,
  RadioGroup,
  SheetTrigger,
  SideSheet,
  SideSheetHeader,
} from '@material-web/react'
import { Heading } from 'react-aria-components'

export default function Width() {
  return (
    <SheetTrigger>
      <Button variant="tonal">Open settings</Button>
      <SideSheet isModal className="side-sheet-width-90">
        <SideSheetHeader>
          <Heading slot="title">Settings</Heading>
          <IconButton aria-label="Close" slot="close">
            <Icon name="close" />
          </IconButton>
        </SideSheetHeader>
        <RadioGroup
          aria-label="Density"
          defaultValue="default"
          className="flex flex-col items-start px-space-300 py-space-200 text-body-lg"
        >
          {['Default', 'Comfortable', 'Compact'].map((name) => (
            <Radio key={name} className="h-14" value={name.toLowerCase()}>
              {name}
            </Radio>
          ))}
        </RadioGroup>
      </SideSheet>
    </SheetTrigger>
  )
}

Divider

To show a divider at the start of a standard sheet that is not detached, set className="border-s border-outline-variant". Without Tailwind's Preflight, add border-0 border-solid as well.

Cassette Futurism
import { Icon, IconButton, SideSheet, SideSheetHeader } from '@material-web/react'
import { useState } from 'react'
import { Heading } from 'react-aria-components'

export default function WithDivider() {
  const [isOpen, setOpen] = useState(false)
  return (
    <div className="flex h-96 w-full bg-surface">
      <div className="box-border min-w-0 grow overflow-y-auto p-space-300">
        <div className="flex items-center justify-between pb-space-200">
          <span className="text-title-lg">Cassette Futurism</span>
          <IconButton aria-label="Info" onPress={() => setOpen(!isOpen)}>
            <Icon name="info" />
          </IconButton>
        </div>
        <div className="h-40 rounded-shape-md bg-tertiary-container" />
      </div>
      <SideSheet
        className="border-0 border-s border-solid border-outline-variant"
        isOpen={isOpen}
        onOpenChange={setOpen}
      >
        <SideSheetHeader>
          <Heading slot="title">Info</Heading>
          <IconButton aria-label="Close" slot="close">
            <Icon name="close" />
          </IconButton>
        </SideSheetHeader>
        <p className="m-0 px-space-300 py-space-200 text-on-surface-variant">
          Twelve tracks by various artists, 48 minutes.
        </p>
      </SideSheet>
    </div>
  )
}