Default
Click the button. Pieces leave it in a cone, slow down like paper, sway and fade.
Paper confetti for the small victories. Strips, punched dots, stars, triangles, streamers and torn scraps, each a tiny drawing from the ink engine, thrown from a click, a state change or a function call. Nothing moves with reduced motion.
npx shadcn@latest add @wobko/confetti第一次使用?先把 registry 加进 components.json。 如何安装
Click the button. Pieces leave it in a cone, slow down like paper, sway and fade.
spread 360 sends a ring; shapes and colors narrow the pieces. A Valentine's burst of pink dots and stars.
A real use: confetti stays inside the card and goes off when the last task is ticked. Untick one and tick it again for another go.
A button (or, with asChild, any element) that throws confetti from itself when clicked. It renders no layer of its own: the pieces fly in a click-through layer on the page.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| asChild | boolean | - | Wrap your own element (a Button) instead of rendering a <button>. |
| …ConfettiOptions | count, spread, angle, velocity, gravity, drift, duration, colors, shapes, scalar, seed, origin, onDone | - | See the options below. The origin defaults to the trigger. |
A decorative layer that fills its positioned parent and throws inside it: when `active` turns true, whenever `burstKey` changes, or from `apiRef.burst()`. Use it to keep a burst inside a card or a dialog.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| active | boolean | - | Throw a burst when it turns true (or is true on mount). |
| burstKey | number | string | - | Throw again whenever it changes: bump a counter. |
| apiRef | Ref<{ burst(options?) => () => void }> | - | Imperative handle. |
| count | number | 70 | Pieces, at most 400. |
| spread / angle | number | 70 / 90 | The cone in degrees and its direction (90 up, 0 right, spread 360 for a ring). |
| velocity / gravity / drift | number | 1100 / 520 / 0 | Launch speed of the fastest piece (px/s), fall (px/s²) and wind (px/s²). |
| duration | number | 2600 | ms until the last piece has faded. |
| colors / shapes | ConfettiColor[] / ConfettiKind[] | - | Stationery accents (tomato … bubblegum) and shapes (strip, dot, star, triangle, curl, scrap). |
| scalar | number | 1 | Size multiplier. |
| seed | number | - | Same seed, same burst. Default: a counter, so every burst is different. |
| onDone | () => void | - | Called once when the last piece has landed, or when the burst was cleared. A Confetti layer forgets a burst the moment it is over. |
CLI 会复制进你项目的文件。
正在加载源码