Types
Six kinds of paper: a plain slip, a green guest check for success, a pink sticky for errors, yellow for warnings, blue for news, and a slip with a spinning loader. Each has its own drawn icon and a slightly different tilt.
Toasts as slips of paper tossed onto the desk. A guest check for success, a pink sticky for errors, yellow for warnings, blue for news; stacked, swipeable, with drawn icons, action buttons, promise toasts and tape or a pin to hold them down. Built on the sonner package: you keep its `toast()` API.
npx shadcn@latest add @wobko/sonner第一次使用?先把 registry 加进 components.json。 如何安装
Six kinds of paper: a plain slip, a green guest check for success, a pink sticky for errors, yellow for warnings, blue for news, and a slip with a spinning loader. Each has its own drawn icon and a slightly different tilt.
toast.promise follows a request: one slip that starts as a loader, then turns into a success (or an error) paper when the promise settles. Pass a function for the message to use the result.
The real pattern: do the thing at once, then offer to take it back. The action is a highlighter-marked button (a Wobko Button also works as the label); the page updates when you press it.
Six places to stack toasts (slips not on the right are dropped from above instead of tossed from the corner), and two ways to hold them down: masking tape or a push-pin.
Official `sonner-demo`: one button, one toast with a description and an Undo action. The slip is tossed onto the desk; Undo is a highlighted word, not a filled button. Official code mounts `<Toaster />` once at the app root; here the example mounts its own so it works on its own.
Official `sonner-types`: default, success, info, warning, error and a promise that goes from loading to success after two seconds. Each type is a different stock of paper (guest check, blue, yellow and pink stickies), so meaning never rests on color alone.
Mount it once near the root of the app. It wraps sonner's Toaster in unstyled mode and gives each toast the paper look with classes on sonner's own elements, so stacking, swiping, timers, hover-to-expand and the aria-live region are all sonner's. Every sonner prop works (`position`, `expand`, `visibleToasts`, `duration`, `gap`, `offset`, `closeButton`, `dir`, `hotkey`, `toastOptions`, `icons`, `id` ...).
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| decoration | "none" | "tape" | "pin" | "none" | Hold every slip to the page with a strip of masking tape or a push-pin (drawn with CSS on the content box; hidden in calm density). |
| portal | boolean | false | Render the stack into `document.body`. The stack is `position: fixed`, so an ancestor with `container-type` (Tailwind's `@container`), `transform`, `filter` or `contain: layout` becomes its containing block and pins the toasts to that box instead of the window. Mount `<Toaster />` at the app root and you never need this; pass `portal` when it has to live inside such a wrapper. The stack appears after the first client render, and repeats the InkProvider's density, motion and theme. |
| theme | "light" | "dark" | "system" | "light" | Passed to sonner. There is no next-themes here; Wobko themes come from CSS variables and the InkProvider, so the slips follow them without a prop. |
| icons | ToastIcons | - | Override the drawn icons: success (circle-check), info, warning (triangle-alert), error (octagon-x), loading (loader-circle, spinning), close. |
| toastOptions | ToastOptions | - | Sonner's options. `classNames` are merged with ours (yours come last); `unstyled` stays on. |
CLI 会复制进你项目的文件。
正在加载源码