WebberUI

便利貼牆

軟木板上的彩色便利貼:拖曳、新增、揉掉刪除。

一面 CSS 紋理軟木板,貼滿帶著微旋轉與膠帶/圖釘裝飾的彩色便利貼:可自由拖曳移動、雙擊編輯文字、按下 ✕ 便揉成一團紙球丟出,右下角一鍵新增自動配色的新便利貼,適合待辦牆、腦力激盪板等趣味場景。

載入預覽⋯

Playground

即時調整 props、程式碼片段同步更新——直接試出你要的樣子再複製。

300
<StickyNoteBoard />

安裝

npx shadcn@latest add https://webberui.com/r/sticky-note-board.json

或在 components.json 設定 registries 後,改用 @webberui/sticky-note-board 安裝。

安裝依賴後,從 registry JSON(/r/sticky-note-board.jsonfiles[0].content)複製 sticky-note-board.tsx 原始碼到你的 components/ui/ 目錄:

npm install motion lucide-react clsx tailwind-merge

使用

import { StickyNoteBoard, type StickyNote } from "@/components/ui/sticky-note-board";

const notes: StickyNote[] = [
  { id: "milk", text: "下班買牛奶 🥛", x: 24, y: 22, color: 0 },
  { id: "gym", text: "週三 19:00 健身房", x: 200, y: 120, color: 2 },
];

<StickyNoteBoard notes={notes} height={400} onChange={(next) => console.log(next)} />

Props

Prop型別預設值說明
notesStickyNote[][]初始便利貼資料;之後由元件內部管理,異動經 onChange 回報
onChange(notes: StickyNote[]) => void拖曳、編輯、新增、揉掉任一異動後,回傳最新的便利貼陣列
heightnumber380軟木板高度(px)
addLabelstring"新增便利貼"新增按鈕的文字
showAddbooleantrue是否顯示右下角的新增按鈕
classNamestring透傳到最外層(木框)容器

StickyNote 型別

欄位型別說明
idstring唯一識別碼,同時作為旋轉角度與圖釘/膠帶樣式的決定性雜湊種子
textstring便利貼上的文字內容
xnumber相對板面左上角的 X 座標(px)
ynumber相對板面左上角的 Y 座標(px)
colornumber色票索引 05(黃/粉/綠/藍/橘/紫),未指定時依 id 雜湊自動配色

可及性

  • 每張便利貼皆可鍵盤聚焦:Enter 進入編輯、方向鍵移動(Shift 加速)、Delete / Backspace 揉掉刪除
  • 便利貼以 role="group" 搭配 aria-label 朗讀內容,揉掉按鈕有明確的 aria-label
  • 編輯中 Esc 取消還原原文、Cmd/Ctrl + Enter 或失焦即提交
  • 使用者系統開啟「減少動態效果」時,進場、拖起放大與揉紙動畫皆改為單純淡入淡出
  • 旋轉角度與裝飾樣式由 id 決定性雜湊產生,SSR 與 client 渲染結果一致

On this page