Stick things down
Drag a sticker anywhere. Pick one and a dashed frame appears with a ring to turn it by and a square to size it; the toolbar and the keyboard do the same.
A page you can stick stickers on: drag them anywhere, turn them, size them, stack them, with the pointer or the keyboard. The value is plain JSON ({ id, name, x, y, rot, scale, z }) and it exports to one standalone SVG.
npx shadcn@latest add @wobko/sticker-board第一次使用?先把 registry 加进 components.json。 如何安装
Drag a sticker anywhere. Pick one and a dashed frame appears with a ring to turn it by and a square to size it; the toolbar and the keyboard do the same.
The board keeps no secrets: every sticker is { id, name, x, y, rot, scale, z }. Store it, send it, restore it. addSticker puts a new one on top of the pile.
A read-only board is a display: the stickers a student has earned, lying where the teacher stuck them. No handles, no tab stops, no toolbar.
The picker chooses, addSticker sticks: the new sticker lands in the middle of the page, already picked, so it can be turned and sized straight away. Export downloads the whole page as one SVG.
The state and the layout: a column holding the canvas and the toolbar (pass children to arrange them yourself). Owns the stickers, the picked one, the live region and the export.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| value / defaultValue | StickerBoardItem[] | - | The stickers. x and y are the center of the visible sticker in px from the canvas's top-left; rot is degrees clockwise (-180 to 180); scale 1 is the drawn size; a higher z lies on top. Ids must be unique. JSON that lacks a rot, scale or z (written by hand, or by an older version) is completed on the way in (0, 1, its position in the list), and what comes out through onValueChange is always whole. Built for tens of stickers: each is about 35 KB of markup at 96 px. |
| onValueChange | (value: StickerBoardItem[]) => void | - | Called once when a drag ends, and on every key press, toolbar action or removal. The pointer writes styles while it drags and does not render per move. |
| selectedId / defaultSelectedId / onSelectedIdChange | string | null | - | The picked sticker. Focusing or pressing a sticker picks it; pressing the bare page or Escape lets go. |
| size | number | 96 | Drawn size of a sticker at scale 1, px. Below 80 the 64 px redraw is used. |
| minScale / maxScale | number | 0.3 / 3 | The limits of sizing. |
| bounds | "center" | "inside" | "none" | "center" | Where a sticker may go: its center stays on the canvas, all of it stays on the canvas, or anywhere (the canvas clips). |
| readOnly / disabled | boolean | false | Look but do not touch: no tab stops, no handles, toolbar actions off (Export still works when read-only). |
| label | string | "Sticker board" | Accessible name of the canvas group. |
| onExport | (data: StickerBoardExport) => void | - | Receives { items, json, svg, width, height, png() } when Export is pressed. Without it, Export downloads stickers.svg. |
The page the stickers lie on: a Paper (dot grid by default; any stock and edge work) whose stickers are clipped to it while its shadow and tape are not. Shows a hint while the board is empty.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| empty | ReactNode | "Nothing stuck down yet." | What the empty board says. |
| stock / edge / tape / … | PaperProps | - | Everything Paper takes. |
Buttons for what the keyboard does, acting on the picked sticker: turn left and right, smaller and larger, send to back, backward, forward and to front, duplicate, delete and export. One row; every enabled button is a tab stop and left and right arrows also move along it.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| actions | ("turn" | "size" | "layer" | "duplicate" | "delete" | "export")[] | - | Which groups to show, in order. Default all. |
CLI 会复制进你项目的文件。
正在加载源码