MIXXIN Design System

全公司子系統共用的 UI 基礎。Code(tokens/ + registry/)是唯一真相來源,Figma 是它的 digital twin——由 code 生成,回寫也回到 code。

M1 Tokens + Registry 骨架 — 完成M2 核心元件移植 — 延後M3 Code → Figma 管線 — 完成M4 Twin 頁面管線 — 完成M5 JSON Render — 未開

架構圖

兩條流共用同一份 tokens/tokens.json:分發流把它變成下游可裝的 registry item,twin 流把它變成 Figma 裡可對照、可回寫的 digital twin。

分發流
tokens/tokens.json
build-tokens.ts
tokens.css (Tailwind v4 @theme + shadcn 32 變數)
registry.json + registry/mixxin/ui/*
shadcn build
public/r/*.json
下游 npx shadcn add @mixxin/*
Twin 流
tokens/tokens.json
tokens.figma.json
gen-variables
Figma variables (Primitives / Semantic 雙 mode / Motion)
figma/specs/*.figma.ts
gen-components
Figma component sets
figma/pages/*.twin.ts
React renderer (lib/twin-render.tsx) → /twin/<name>
同一份 spec
gen-twin
Figma twin/<name> frame
設計師改 Figma
publish library人手
readback (use_figma 倒出)
落地核對行數人手
diff / diff --twin <name>
--write 回寫 tokens.json / spec

Coverage 盤點

以下數字在 build 期從 tokens / registry / 檔案系統讀出,不是手寫的。

Tokens
338Primitives(單 mode)
199Semantic(Light + Dark,含 shadcn 相容層 32)
9Motion(單 mode)
546變數總數

Semantic collection 兩個 mode(Light / Dark)雙軌對映到 shadcn 32 個語意變數(31 色彩 + --radius);shadow/gradient 不是變數型別,各自落在 effect styles/paint styles。

Registry 元件(37 個 registry:ui item)
元件Figma specDemo 頁
Button@mixxin/button
✓查看 →
Card@mixxin/card
✓查看 →
Input@mixxin/input
✓查看 →
Label@mixxin/label
✓查看 →
Table@mixxin/table
✓查看 →
Dialog@mixxin/dialog
✓查看 →
Alert Dialog@mixxin/alert-dialog
✓查看 →
Select@mixxin/select
✓查看 →
Checkbox@mixxin/checkbox
✓查看 →
Radio Group@mixxin/radio-group
✓查看 →
Switch@mixxin/switch
✓查看 →
Textarea@mixxin/textarea
✓查看 →
Tabs@mixxin/tabs
✓查看 →
Dropdown Menu@mixxin/dropdown-menu
✓查看 →
Tooltip@mixxin/tooltip
✓查看 →
Badge@mixxin/badge
✓查看 →
Separator@mixxin/separator
✓查看 →
Skeleton@mixxin/skeleton
✓查看 →
Sonner@mixxin/sonner
✓查看 →
Sidebar@mixxin/sidebar
✓查看 →
Form@mixxin/form
–查看 →
Field@mixxin/field
✓查看 →
Combobox@mixxin/combobox
✓查看 →
Calendar@mixxin/calendar
✓查看 →
Popover@mixxin/popover
✓查看 →
Pagination@mixxin/pagination
✓查看 →
Breadcrumb@mixxin/breadcrumb
✓查看 →
Avatar@mixxin/avatar
✓查看 →
Alert@mixxin/alert
✓查看 →
Sheet@mixxin/sheet
✓查看 →
Drawer@mixxin/drawer
✓查看 →
Progress@mixxin/progress
✓查看 →
Scroll Area@mixxin/scroll-area
✓查看 →
Command@mixxin/command
✓查看 →
Input Group@mixxin/input-group
✓–
Spinner@mixxin/spinner
✓查看 →
Accordion@mixxin/accordion
✓查看 →
shadcn 官方 ui 目錄覆蓋率 — 37 / 63
✓accordion
✓alert
✓alert-dialog
–aspect-ratio
✓avatar
✓badge
✓breadcrumb
✓button
–button-group
✓calendar
✓card
–carousel
–chart
✓checkbox
–collapsible
✓combobox
✓command
–context-menu
✓dialog
✓drawer
✓dropdown-menu
–empty
✓field
✓form
–hover-card
✓input
✓input-group
–input-otp
–item
✓label
–menubar
–navigation-menu
✓pagination
✓popover
✓progress
✓radio-group
–resizable
✓scroll-area
✓select
✓separator
✓sheet
✓sidebar
✓skeleton
–slider
✓sonner
✓spinner
✓switch
✓table
✓tabs
✓textarea
–toast
–toggle
–toggle-group
✓tooltip
–kbd
–native-select
–direction
–attachment
–bubble
–message-scroller
–questionnaire
–marker
–message
Twin 頁(7)
  • 登入(twin/login)

    MIXXIN Design System 的第一個 twin 頁:Card + Label/Input + Button 組成的登入表單。

    View twin →
  • 訂單總覽(twin/order-overview)

    mixxims-next 從零重寫的第一頁:Sidebar + 篩選列 + 9 欄表格 + 分頁列。

    View twin →
  • 訂單詳情(twin/order-detail)

    mixxims-next 的第二個 twin 頁:Sidebar + 標頭 + 三欄(訂單詳情/物流設定/內容商品+管理)+ 底部按鈕。

    View twin →
  • 數據儀表板・單一專案(twin/dashboard-project)

    MIXXIN 數據儀表板的單一集資專案頁(前測期 W4):無 Sidebar 的長捲動滿版儀表板,KPI 雙欄 + 5 個編號章節。

    View twin →
  • CommandBar 萬用輸入框(twin/command-bar)

    Patterns 頁第一個 pattern:L0 搜尋/L1 命令面板/L2 AI 意圖,8 個狀態。

    View twin →
  • App Shell 側欄三態(twin/app-shell)

    Patterns 頁第二個 pattern:側欄展開/收合/緊湊收合三態與切換規則。

    View twin →
  • DatePicker 範式(twin/date-picker)

    Patterns 頁第三個 pattern:DateField/DatePicker/DateRangePicker 的八個狀態與 UI 實踐。

    View twin →

管線 runbook 摘要

yarn build

build-tokens → build-registry(注入 CSS 變數、跑 shadcn build)→ next build,產出純靜態 out/(含 out/r/*.json)。

yarn figma:gen

build-tokens + gen-variables + gen-components + gen-twin,產生要送進 Figma 的 chunk——chunk 不會自己跑進去,要 agent 逐支用 use_figma 送出(人手)。

yarn figma:diff [--twin <name>]

比對 readback JSON 與 tokens.figma.json/twin spec,0 差異才算過;加 --write 才回寫 tokens.json 或 spec 檔。

人手步驟:Figma UI 按 publish library、readback JSON 落地後核對行數、決定要不要下 --write。

不承諾清單

  • –CSS 互動狀態:hover / focus-visible / active / disabled / aria-* 一律沒有,component set 只有靜態態。
  • –Button 的 icon size(icon / icon-xs / icon-sm / icon-lg)不進 component set,等 icon 管線(PRD D9)。
  • –arbitrary value 無法表達:sm size 的字級、rounded 的 min() clamp,Figma 端寫死或退化綁最近的 token。
  • –字型 fallback stack 與非法字型值(font.family.mono):只當字串存著,不套用實際字型。
  • –shadow 的 dark 值、gradient 角度:只近似呈現,沒有做逐像素比對。
  • –responsive / 斷點:breakpoint/* 只是變數,畫布上沒有對應表現。
  • –twin 頁只出桌機一個斷點,不含 hover/focus 狀態、不含 icon 元件。
  • –twin 的幂等策略是清 children 重建:設計師手動改的子節點會被下一次 gen 蓋掉,要保留就先 readback 回寫 spec。

決策摘要

  • 2026-09-03primitives 走 Base UI(@base-ui/react),非 Radix — shadcn CLI 4.20.1 預設 style base-nova,PRD 提到的「Radix」應讀作 Base UI。
  • 2026-09-03shadcn 語意變數以 32 個為準(31 色彩 + radius),tokens 對映層依此收斂。
  • 2026-09-03部署形態:Next.js output: export 純靜態,Cloudflare Pages 直接託管 out/,不用 OpenNext / Workers。
  • 2026-09-03O2 網域與 GitHub:先全部本地,不建 GitHub repo、不綁 ui.mixxin.tw,骨架長出來 q 看過再建。
  • 2026-09-04不做 Figma Code Connect(原 PRD D5):需 Organization/Enterprise 方案,非「Figma 改動 diff 回寫 code」路線的必要件;Figma 對接全走 MCP(use_figma)。
  • 2026-09-04Figma → code 回寫機制:agent 讀 diff 回寫 tokens 值/頁面元件改動,Figma 永不直接 commit;同時用 Figma publish library 做設計端版本控管。
  • 2026-09-04Plugin API 讀不到 version history,diff 的版本真相是 repo 裡的 tokens.resolved.json,不是「上一版 library」。
  • 2026-09-04M2(核心元件移植)延後:等有舊系統要遷徙到 DS 時再盤點 icon 庫與首波元件清單;M3 直接以 button 當管線樣本。
  • 2026-09-04twin 頁的資料模型:一份 spec 同時餵 React renderer 與 Figma gen-twin,token path → Tailwind class 走字面對照表,不做字串拼接。
  • 2026-09-04Card 在 twin 裡是 Auto Layout frame 不是 instance(instance 不能塞任意 children);chrome 的值與 Components 頁的 Card component set 共用同一組變數。
  • 2026-09-03A2 Storybook 未決:M1–M2 不做,元件檔維持純 shadcn 檔案,M3 前再議。
  • 2026-09-03A3 JSON Render / tools.mixxin.tw 排 M5:M1–M4 不為它做額外設計,只要求元件 props 維持可序列化的簡單型別。

安裝與本地測試

在下游專案的 components.json 註冊 @mixxin registry,先裝 base 再裝元件:

npx shadcn registry add @mixxin=https://ui.mixxin.tw/r/{name}.jsonnpx shadcn add @mixxin/base

本地驗證:yarn registry:build && yarn dev,把下游測試專案的 components.json 指向 http://localhost:3100/r/{name}.json,測完改回正式網址。

  • MIXXIN Baseregistry:base

    MIXXIN design system base: config, CSS variables and dependencies for a new project.

    npx shadcn add @mixxin/base
  • Buttonregistry:ui

    Displays a button or a component that looks like a button.

    npx shadcn add @mixxin/buttonView demo →
  • Cardregistry:ui

    Displays a card with header, content and footer slots.

    npx shadcn add @mixxin/cardView demo →
  • Inputregistry:ui

    Displays a form input field or a component that looks like an input field.

    npx shadcn add @mixxin/inputView demo →
  • Labelregistry:ui

    Renders an accessible label associated with controls.

    npx shadcn add @mixxin/labelView demo →
  • Tableregistry:ui

    以表格顯示結構化資料,含表頭、列與合計列。

    npx shadcn add @mixxin/tableView demo →
  • Dialogregistry:ui

    彈出視窗,用於聚焦單一任務或訊息。

    npx shadcn add @mixxin/dialogView demo →
  • Alert Dialogregistry:ui

    需要使用者明確確認才能關閉的警示對話框。

    npx shadcn add @mixxin/alert-dialogView demo →
  • Selectregistry:ui

    從清單中選擇單一選項的下拉選單。

    npx shadcn add @mixxin/selectView demo →
  • Checkboxregistry:ui

    可勾選的核取方塊,支援不確定狀態。

    npx shadcn add @mixxin/checkboxView demo →
  • Radio Groupregistry:ui

    一組互斥的單選按鈕。

    npx shadcn add @mixxin/radio-groupView demo →
  • Switchregistry:ui

    切換開關,用於布林值設定。

    npx shadcn add @mixxin/switchView demo →
  • Textarearegistry:ui

    多行文字輸入欄位。

    npx shadcn add @mixxin/textareaView demo →
  • Tabsregistry:ui

    以頁籤切換多組相關內容。

    npx shadcn add @mixxin/tabsView demo →
  • Dropdown Menuregistry:ui

    點擊觸發的下拉操作選單。

    npx shadcn add @mixxin/dropdown-menuView demo →
  • Tooltipregistry:ui

    滑鼠移入或聚焦時顯示的輔助說明。

    npx shadcn add @mixxin/tooltipView demo →
  • Badgeregistry:ui

    顯示狀態或計數的小型標籤。

    npx shadcn add @mixxin/badgeView demo →
  • Separatorregistry:ui

    區隔內容區塊的分隔線。

    npx shadcn add @mixxin/separatorView demo →
  • Skeletonregistry:ui

    內容載入中的骨架佔位效果。

    npx shadcn add @mixxin/skeletonView demo →
  • Sonnerregistry:ui

    顯示即時通知的 toast 元件。

    npx shadcn add @mixxin/sonnerView demo →
  • Sidebarregistry:ui

    可收合的應用程式側邊導覽列。

    npx shadcn add @mixxin/sidebarView demo →
  • Formregistry:ui

    搭配 react-hook-form 與 Field 建立表單的組合模式(base-nova 官方無獨立 Form 元件本體,改用 Controller + Field 直接組裝)。

    npx shadcn add @mixxin/formView demo →
  • Fieldregistry:ui

    表單欄位的標籤、說明與錯誤訊息容器,供 react-hook-form 組裝使用。

    npx shadcn add @mixxin/fieldView demo →
  • Comboboxregistry:ui

    可搜尋、可清除的選項選擇器。

    npx shadcn add @mixxin/comboboxView demo →
  • Calendarregistry:ui

    選擇日期或日期區間的月曆。

    npx shadcn add @mixxin/calendarView demo →
  • Popoverregistry:ui

    點擊觸發、可含互動內容的浮層。

    npx shadcn add @mixxin/popoverView demo →
  • Paginationregistry:ui

    分頁切換的頁碼導覽列。

    npx shadcn add @mixxin/paginationView demo →
  • Breadcrumbregistry:ui

    顯示目前頁面在階層中位置的麵包屑導覽。

    npx shadcn add @mixxin/breadcrumbView demo →
  • Avatarregistry:ui

    顯示使用者頭像,附文字或圖示的替代顯示。

    npx shadcn add @mixxin/avatarView demo →
  • Alertregistry:ui

    顯示重要提示或狀態訊息的區塊。

    npx shadcn add @mixxin/alertView demo →
  • Sheetregistry:ui

    從畫面邊緣滑出的側邊面板。

    npx shadcn add @mixxin/sheetView demo →
  • Drawerregistry:ui

    從畫面底部滑出的抽屜面板,適合行動裝置。

    npx shadcn add @mixxin/drawerView demo →
  • Progressregistry:ui

    顯示工作進度的長條指示器。

    npx shadcn add @mixxin/progressView demo →
  • Scroll Arearegistry:ui

    自訂捲軸樣式的可捲動容器。

    npx shadcn add @mixxin/scroll-areaView demo →
  • Commandregistry:ui

    可搜尋指令與選項的指令面板。

    npx shadcn add @mixxin/commandView demo →
  • Input Groupregistry:ui

    輸入框搭配前後綴按鈕或圖示的組合容器。

    npx shadcn add @mixxin/input-groupView demo →
  • Use Mobileregistry:hook

    偵測目前視窗寬度是否為行動裝置的 React hook。

    npx shadcn add @mixxin/use-mobile
  • Spinnerregistry:ui

    顯示載入中狀態的旋轉指示圖示。

    npx shadcn add @mixxin/spinnerView demo →
  • Accordionregistry:ui

    可展開折疊的垂直堆疊內容區塊。

    npx shadcn add @mixxin/accordionView demo →