Sheet
Dialog pinned to an edge of the screen, for content that complements the page rather than interrupting it.
c2-sheet is a dialog that spans one edge of the screen and slides in from it — filters, details, a form beside the record it edits. It is built on the native <dialog> like c2-modal, so focus is trapped and restored, the page behind is inert and covered by a backdrop, and Escape closes. side picks the edge (right by default), and --c2-sheet--size is the width of a left/right sheet or the height of a top/bottom one while the other axis fills the screen. Open it with the open attribute or show(), close it with close(returnValue), the × button, a backdrop click or Escape — hide-close, no-backdrop-close and no-escape turn those off. The heading goes in title (it labels the sheet; use label when there is none), the content in the default slot, the actions in footer; only the body scrolls, so the header and footer stay put.
Installation
npm install @c2n/sheetUsage
The default edge: a panel that complements the page without replacing it.
FiltersThe default edge: a panel that complements the page without replacing it.
FiltersSlides in from the left.
NavigationSlides in from the left.
NavigationFull width, pinned to the top; --c2-sheet--size is its height.
Full width, pinned to the top; --c2-sheet--size is its height.
The phone pattern: a bottom sheet for actions on the current screen.
ShareThe phone pattern: a bottom sheet for actions on the current screen.
SharePut the form in the body and the actions in the footer. Only the body scrolls, so Save never leaves the screen.
Put the form in the body and the actions in the footer. Only the body scrolls, so Save never leaves the screen.
--c2-sheet--border-radius rounds the two corners facing the page; the edge stays square.
--c2-sheet--border-radius rounds the two corners facing the page; the edge stays square.
A detail panel that needs room for a table or a diff.
WideA detail panel that needs room for a table or a diff.
WideReach for a sheet when the content belongs beside the page: filters over a list, a record’s details, a form the user fills in without losing their place. Reach for c2-modal when the page must stop for a decision, and for c2-side-nav when the panel is navigation that is part of the layout rather than a transient overlay.
Keep the trigger and the sheet next to each other in the markup, and give the sheet a name — a title slot labels it automatically, label names one without a visible heading. Focus moves into the panel on open and returns to the trigger on close, so a sheet opened from a toolbar button lands the user back where they were.
A sheet can hold another overlay: a confirm dialog opened from inside a sheet keeps the page locked until both have closed, and closing the inner one leaves the sheet standing.
--c2-sheet--size is the only geometry variable you normally need; the sheet fills the other axis. --c2-sheet--border-radius rounds the inner corners, --c2-sheet--transition-duration sets the slide (0ms disables it, and reduced motion drops it automatically), and the __header, __body, __footer, __close and __backdrop groups match c2-modal’s so a dialog and a sheet can be themed together.