Sheet

A panel that slides over the page from a side or the bottom.

Showing every issue.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/sheet

Usage

import { buttonStyle } from "./ui/uicontext/components/Button.ts"import { Sheet } from "./ui/uicontext/components/Sheet.ts"import { sx } from "./ui/uicontext/components/Sx.ts"
const Message = UiSchema.TaggedEnum({ RequestedOpen: {}, RequestedClose: {} })// `open` lives in your Model: RequestedOpen sets it, RequestedClose clears itexport const DetailsSheet = (h: Html.H<typeof Message.Type>, open: boolean) =>	Sheet(h, {		open,		title: "Invoice INV-2041",		onRequestedOpen: Message.RequestedOpen(),		onRequestedClose: Message.RequestedClose(),		trigger: (sheet) => sheet.trigger(h.button).attrs(sx(...buttonStyle())).children("Details"),		children: [h.p.children("Due on March 3. Sent to [email protected].")],	})

Examples

Bottom and left

side picks the edge: bottom for a quick look on a phone, left for navigation. On touch, swipe it back toward its edge to close it.

API reference

SheetPreviewView function

Options

SheetPreview options
NameTypeDefaultDescription
side"right" | "left" | "bottom"rightThe edge it's drawn against; right by default
size"sm" | "md" | "lg"—The width of a side sheet
titlerequiredstring—The sheet's heading
descriptionstring—A sentence under the heading
childrenrequiredView.Children—The sheet's body
footerView.Children—Actions at the bottom, the primary one last
styleStyle—Extra StyleX styles for the panel

SheetView function

Options

Sheet options
NameTypeDefaultDescription
keystring—Names the sheet among others in the same view; needed for more than one
openrequiredboolean—Whether the sheet shows; the caller keeps it
side"right" | "left" | "bottom"rightThe edge it slides in from; right by default
size"sm" | "md" | "lg"—The width of a side sheet
titlerequiredstring—The sheet's heading and accessible name
descriptionstring—A sentence under the heading, read with it as the sheet's description
onRequestedOpenMessage—A trigger asked to open it
onRequestedCloserequiredMessage—Escape, a press outside, a swipe or the close button asked to close it
trigger(sheet: SheetParts<Message>) => View.Input—The button that opens it: apply sheet.trigger to a button builder, so focus comes back to it
childrenrequiredView.Children—The sheet's body
footerView.Children—Actions at the bottom, the primary one last
onKeyDown(press: SheetKeyPress) => Message—Keys the sheet itself answers, wherever focus is inside it (its close button included): a message, or undefined to let the key through. Keys typed into a text field never reach it.
styleStyle—Extra StyleX styles for the panel

Accessibility

  • A modal dialog named by its title: focus moves in and stays, and goes back to what opened it when it closes.
  • Escape, a press on the dimmed page, a swipe toward its edge or the Close button ask to close; your Model decides whether it does.

Source