Skip to content

Overlays

Sheet

tsx
"use client";
import { useState } from "react";
import { Button, Sheet, SheetBody } from "@cherry-design-system/react";

export function Filters() {
  const [isOpen, setIsOpen] = useState(false);
  return (
    <>
      <Button variant="outline" onClick={() => setIsOpen(true)}>Filters</Button>
      <Sheet open={isOpen} onClose={() => setIsOpen(false)} side="right" title="Filters">
        <SheetBody>Filter controls</SheetBody>
      </Sheet>
    </>
  );
}

Sheet is a modal panel that slides in from an edge of the screen, on the native <dialog> element (showModal). Use it for filters, details or forms that need more room than a Modal. Compose it with SheetBody (scrolls) and SheetFooter (pinned to the bottom).

Examples

tsx
"use client";
import { useState } from "react";
import { Button, Sheet, SheetBody, SheetFooter } from "@cherry-design-system/react";

export function EditOrder() {
  const [isOpen, setIsOpen] = useState(false);
  return (
    <>
      <Button onClick={() => setIsOpen(true)}>Edit order</Button>
      <Sheet
        open={isOpen}
        onClose={() => setIsOpen(false)}
        title="Order #1042"
        description="Changes apply to the next shipment."
      >
        <SheetBody>Order form</SheetBody>
        <SheetFooter>
          <Button variant="outline" onClick={() => setIsOpen(false)}>Cancel</Button>
          <Button onClick={() => setIsOpen(false)}>Save</Button>
        </SheetFooter>
      </Sheet>
    </>
  );
}

Bottom sheet

side="bottom" slides the panel up from the bottom edge and shows a drag handle at the top.

tsx
"use client";
import { useState } from "react";
import { Button, Sheet, SheetBody } from "@cherry-design-system/react";

export function Share() {
  const [isOpen, setIsOpen] = useState(false);
  return (
    <>
      <Button onClick={() => setIsOpen(true)}>Share</Button>
      <Sheet open={isOpen} onClose={() => setIsOpen(false)} side="bottom" title="Share">
        <SheetBody>Share options</SheetBody>
      </Sheet>
    </>
  );
}

Properties

Sheet

openbooleanrequired

Controlled open state.

onClose() => voidrequired

Called on Escape, a backdrop click or the close button. Set open to false here.

side"left" | "right" | "bottom"

Edge it slides from. Defaults to "right".

titleReactNode

Heading; also the dialog's accessible name.

descriptionReactNode

Line under the title; wired as the accessible description.

hideCloseboolean

Hide the close button in the header.

closeLabelstring

Accessible name of the close button. Defaults to "Close".

dismissibleboolean

Escape and backdrop clicks close it. Defaults to true.

Sheet renders a <dialog>, forwards its ref to it and passes other <dialog> attributes through. It is a Client Component.

SheetBody

SheetBody has no props of its own. It renders a scrolling <div>, forwards its ref and passes <div> attributes through.

SheetFooter

SheetFooter has no props of its own. It renders an action row pinned to the bottom above a divider, forwards its ref and passes <div> attributes through.

Styling

HookValues
Classcherry-sheet
data-sideright, left, bottom
States[open], ::backdrop
Partscherry-sheet__handle, cherry-sheet__header, cherry-sheet__title, cherry-sheet__description, cherry-sheet__close, cherry-sheet__body, cherry-sheet__footer

The panel reads --cherry-bg-elevated, --cherry-radius-2xl and --cherry-elevation-xl; the backdrop uses --cherry-bg-overlay.

Accessibility

Sheet is a native modal <dialog>: the page behind is inert, focus moves in and stays in, Escape closes it and focus returns to the trigger. title names it; give it a title, or an aria-label when there is no visible heading.