组件

Dialog

A modal window that is a sheet of paper dropped on the desk: it lands with a small tilt that settles, the page behind goes dim under a lamp, and the close button is a doodled x. Tape it, pin it, tear its edge; on a phone it becomes a sheet at the bottom of the screen.

安装

terminal
npx shadcn@latest add @wobko/dialog

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

示例

Edit profile

The classic: a form in a dialog. Washi tape across the top corners, the doodled x, and a sheet that drops onto the dimmed page.

Paper, edges and props

The sheet is a Paper: any stock, any edge, held down by tape, a clip or a pin. A torn edge is drawn once, when the dialog opens.

Long content

The sheet never scrolls (its shadow and tape would be clipped): put tall content in DialogBody, and the header and footer stay put. Very tall dialogs scroll under the lamp.

Invite a teammate (controlled)

A real flow: a controlled dialog around a form. Submitting closes it and the page answers; the field is cleared for next time. Focus returns to the trigger.

Share link

shadcn's `dialog-close-button`, written the same way: a read-only field, a footer aligned to the start and a Close button inside DialogClose. The corner x is still there; this one is the labeled way out.

API 参考

DialogContent

The sheet itself: a Paper that is also the Radix dialog (role=dialog, focus trap, scroll lock, Escape, focus return). It takes every Radix Content prop and these Paper props.

属性类型默认值说明
showCloseButtonbooleantrueThe doodled x in the top corner.
stockStockName"paper"What the sheet is made of: paper, card, slip, index-card, graph, kraft, sticky-* ...
edgeEdgeSpec"cut"Cut (pure CSS, no svg), torn, deckle, crimp, zig, perf, scallop, or one per side.
tiltboolean | numbertrueThe sheet turns by a small seeded angle; the text never does. Phones lay it flat.
tape"corner" | "top" | "both" | falsefalseTape strips across the top corners or edge.
tapeKindTapeKind"masking"masking, washi-dots, washi-stripes, washi-zigzag, washi-gingham, kraft, clear.
fastener"clip" | "pin" | "staple" | "binder-clip" | falsefalseHold the sheet with a drawn prop.
rulesRuleName"none"Printed rules (ruled, graph, dots ...). Off by default: arbitrary content does not sit on ruled lines.
shadowSheetShadowKind | 'none'-Which umber shadow the sheet casts. Default: its stock's.
seedstring | number-Pins the hand: the same seed cuts, tilts and draws the same way.

DialogFooter

Buttons, stacked on phones and right-aligned from `sm`.

属性类型默认值说明
showCloseButtonbooleanfalseAdds an outline Close button after the children.

无障碍

  • Radix Dialog: role=dialog with `aria-labelledby` (the title) and `aria-describedby` (the description); give every dialog both. Focus moves into the sheet, Tab and Shift+Tab cycle inside it, Escape closes it, and focus returns to the trigger.
  • The page behind is inert while the dialog is open (pointer events off, aria-hidden on siblings) and scroll is locked.
  • The close button is a real button named "Close"; the x is decorative ink. In Windows high contrast the ink hides and a plain × takes its place.
  • The drop-in, the fade and the hover blot follow `--ll-motion`: with reduced motion the dialog simply appears. In `calm` density the sheet is flat, untilted and untaped.
  • Portalled content repeats the InkProvider's `data-density`, `data-motion` and `data-theme`, so density and reduced motion work inside the dialog too.
  • `modal={false}` works as in Radix: no dim (the sheet sits in a frame that lets clicks through), the page stays interactive and scroll is not locked. Clicking a Sonner toast never counts as "outside", so a toast action pressed over a dialog does not dismiss it. On a phone the bottom sheet pads its foot by `env(safe-area-inset-bottom)`, and the dim reserves its scrollbar gutter so the drop-in cannot make a classic scrollbar shove the sheet sideways.

源码

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

正在加载源码