组件

Sheet

A notebook page that slides in from the edge of the screen. It is bound along the edge that faces the middle: spiral wire through punched holes, three binder holes, a perforated tear line, or torn out of a pad. Good for settings, filters, carts and mobile navigation.

安装

terminal
npx shadcn@latest add @wobko/sheet

第一次使用?先把 registry 加进 components.json。 如何安装

示例

Four sides

The page is bound along whichever edge faces the middle of the screen: the coils hang on the left of a right-hand page, along the bottom of a page that comes from the top.

Bindings

Five ways to finish the inner edge: spiral coils, three binder holes, a perforated tear line, a torn pad edge, or nothing. Perf and torn are drawn when the page opens; the others are cheap strips.

Edit profile

The shadcn demo: a form in a side sheet with the footer pushed to the bottom.

Mobile navigation

A menu page from the left with holes for a binder. The list scrolls inside the page (`overflow-y-auto` on the list, never on the sheet) and every link closes it.

Demo

Official `sheet-demo`, same parts and layout: header, two fields on a grid that fills the height, a footer with Save and Close. The page slides in from the right, bound with a wire coil along its left edge. Escape, the x and a click outside all put it away.

Side

Official `sheet-side`: four triggers in a two-column grid, one page per edge. Three fixes to the original: its inputs were controlled with no `onChange` (frozen), so they take `defaultValue`; its ids repeated four times, so each carries its side; and the field grid gets `px-4` to line up with the header.

API 参考

SheetContent

The page: a Paper that is also the Radix dialog. Flush to its edge, never tilted, with its shadow cast toward the page underneath. It does not scroll itself (the shadow and coils would be clipped): put long content in a child with `overflow-y-auto`.

属性类型默认值说明
side"top" | "right" | "bottom" | "left""right"The edge it slides in from.
binding"spiral" | "holes" | "perf" | "torn" | "none""spiral"How the inner edge is finished. `spiral`: wire coils through punched holes, crossing onto the dimmed page. `holes`: three binder holes with reinforcement rings. `perf`: a perforated tear line. `torn`: torn out of a pad. `none`: a plain cut edge.
showCloseButtonbooleantrueThe doodled x. It moves clear of the coils when they run along its corner.
stockStockName"paper"What the page is made of (paper, pad, graph, kraft, ...).
rulesRuleName"none"Printed rules (`ruled`, `graph`, `dots` ...). Off by default.
seedstring | number-Pins the hand: the same seed draws the same coils and edge.

无障碍

  • Radix Dialog: role=dialog named by SheetTitle and described by SheetDescription. Focus moves in, Tab cycles inside, Escape closes, focus returns to the trigger; the page behind is inert and scroll is locked.
  • A click on a Sonner toast does not count as "outside" and does not dismiss the sheet. In a right-to-left page the x steps in from the corner when the coils are on the physical left edge; the coils themselves are physical, like the `side` prop. A top or bottom page is capped at 85dvh: give tall content a `min-h-0 flex-1 overflow-y-auto` child.
  • The coils, holes and torn or perforated edge are aria-hidden decoration with no pointer events; the close button is a real button named "Close" (a plain × in Windows high contrast).
  • Slide and fade durations follow `--ll-motion`, so with reduced motion the page just appears. In `calm` density the coils are hidden and the page is a plain cut sheet.
  • Side sheets are physical (`right` is the right edge) as upstream; pass `side="left"` for right-to-left layouts.

源码

CLI 会复制进你项目的文件。

正在加载源码