Overlay · astro-ui · Sheet

SheetJS

Dialog panel that slides in from a screen edge.

Sheet is a dialog panel that slides in from a screen edge — built on the same native <dialog> foundation as Dialog: modality, ::backdrop, Escape-to-close, and focus containment come from the platform and the component ships zero JS. Closing needs no JS: any <form method=“dialog”> button, the optional built-in close button, or Escape dismisses natively. When id is set, the title slot gets {id}-title and the sheet points aria-labelledby at it.

Features

  • Slides from any edge: left / right / top / bottom
  • Native <dialog> modality, backdrop, Escape — zero JS in the component
  • Backdrop-click dismiss (opt-out with closeOnBackdrop={false})
  • Built-in zero-JS close button (showClose, closeLabel)
  • sm / md / lg / xl panel sizes (width for sides, height for top/bottom)

Usage

---
import { Button, Sheet } from "astro-ui";
---

<Button id="open-menu">Menu</Button>
<Sheet id="menu" side="left">
  <h2 slot="title">Menu</h2>
  <p>Sheet body…</p>
</Sheet>

<script>
  document.getElementById("open-menu")?.addEventListener("click", () => {
    document.getElementById("menu")?.showModal();
  });
</script>

Demos

Slide-in panel

Sheet title

Modality, backdrop, Escape-to-close, and focus containment come from native <dialog>. The × button closes with zero JS.

<Button id="open-sheet">Open sheet</Button>
<Sheet id="sheet">
  <h2 slot="title">Sheet title</h2>
  <p>Sheet body…</p>
</Sheet>

From any edge

Left

Slides in from the start edge.

Right

Slides in from the end edge.

Top

Drops in from the top — capped at 85vh.

Bottom

Rises from the bottom — capped at 85vh.

<Button id="open-left">Left</Button>
<Sheet id="left" side="left"><h2 slot="title">Left</h2></Sheet>
<Button id="open-top">Top</Button>
<Sheet id="top" side="top"><h2 slot="title">Top</h2></Sheet>
<!-- sides: left | right | top | bottom -->

Backdrop dismiss

Default

Click the dark layer to close — Escape works too.

Locked

Stays open when clicking the dark layer — close with × or Escape.

{/* Default: click the dark layer to close (Escape too) */}
<Button id="open-sheet">Open sheet</Button>
<Sheet id="sheet">…</Sheet>

{/* Opt out: force an explicit close action */}
<Sheet id="critical" closeOnBackdrop={false}
  ariaLabel="Critical settings">…</Sheet>

API

Props

PropTypeDefaultDescription
side"left" | "right" | "top" | "bottom""right"Which screen edge the panel slides in from.
size"sm" | "md" | "lg" | "xl""md"Panel scale (width for left/right, height for top/bottom).
idstring—Required for automatic title labelling (and the trigger script).
showClosebooleantrueRender the native (zero-JS) close button.
closeLabelstring"Close sheet"Accessible label for the built-in close button.
closeOnBackdropbooleantrueClose when the dark backdrop layer is clicked.
classstring—Merged via cn(); Tailwind classes welcome.
idstring—Element id.

Slots

SlotDescription
titleHeading (auto-wired to aria-labelledby).
defaultPanel body content.

Accessibility

Implemented accessibility features — semantics, ARIA wiring, and keyboard behavior that ship with the component.

  • Native <dialog>: focus containment, Escape, and modality from the platform
  • aria-labelledby auto-wired to the title slot ({id}-title); aria-label alternative
  • Built-in close button is a real button with closeLabel

FAQ

How do I open it?

One line: document.getElementById("open-menu") triggers showModal() on the sheet with a matching id — same trigger recipe as Dialog.

Does clicking the dark backdrop close it?

Yes by default. Set closeOnBackdrop={false} for flows where an accidental dismiss would lose work — the user then closes via the × button, a <form method="dialog"> action, or Escape.

Can the panel overflow the screen?

No — left/right panels are width: min(100%, 100vw) and top/bottom panels cap at max-height: 85vh; the size prop just tunes the base scale.

Changelog

Version history mentioning Sheet.

v0.1.0 — 2026-11-11
added
  • Overlay (8): Dialog, AlertDialog, Sheet, Tooltip, Popover, HoverCard, Lightbox, Menu.
  • Native-first interactive behavior: Dialog, AlertDialog, and Sheet on <dialog>; Accordion and Collapsible on <details>; Tabs, Menu, Tree, and Combobox with WAI-ARIA roles and scoped keyboard scripts.
fixed
  • Dialog, Lightbox, Sheet, and AlertDialog backdrops, Progress stripes, Carousel shadows, and Chart SVG shadows resolve through tokens instead of hard-coded colors.