ckm:ui-styling
UI 樣式工具集 - shadcn/ui、Tailwind CSS 與 Canvas 設計
透過結合 shadcn/ui 的可存取元件庫、Tailwind CSS 的 utility-first 樣式設計與基於 canvas 的視覺設計系統,消除 UI 開發過程中的摩擦。這項技能提供 40 個以上 shadcn/ui 元件的完整參考文件、主題設定與深色模式模式、無障礙設計指南、響應式設計工具,以及用於元件安裝和 Tailwind 設定檔產生的 Python 自動化腳本。
下載技能 ZIP
在 Claude 中上傳
前往 設定 → 功能 → 技能 → 上傳技能
開啟並開始使用
測試它
正在使用「ckm:ui-styling」。 安裝 shadcn/ui 的 button、card 和 dialog 元件,並展示一個以卡片為基礎的設定面板
預期結果:
```bash
npx shadcn@latest add button card dialog
```
```tsx
import { Button } from "@/components/ui/button"
import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card"
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
export function SettingsPanel() {
return (
<div className="container mx-auto p-6 space-y-6">
<Card>
<CardHeader>
<CardTitle>Profile Settings</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<p className="text-sm text-muted-foreground">
Manage your account settings and preferences
</p>
<Dialog>
<DialogTrigger asChild>
<Button variant="outline">Edit Profile</Button>
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Edit Profile</DialogTitle>
</DialogHeader>
<div className="space-y-4 py-4">
<p className="text-sm text-muted-foreground">
Profile editing form content here
</p>
<Button className="w-full">Save Changes</Button>
</div>
</DialogContent>
</Dialog>
</CardContent>
</Card>
</div>
)
}
```
正在使用「ckm:ui-styling」。 使用 shadcn/ui 建立一個相容深色模式、含導覽功能的響應式頁首
預期結果:
```tsx
import { Button } from "@/components/ui/button"
import {
NavigationMenu,
NavigationMenuList,
NavigationMenuItem,
NavigationMenuLink,
} from "@/components/ui/navigation-menu"
import { Moon, Sun } from "lucide-react"
import { useTheme } from "next-themes"
export function Header() {
const { theme, setTheme } = useTheme()
return (
<header className="sticky top-0 z-50 w-full border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">
<div className="container flex h-16 items-center justify-between">
<NavigationMenu>
<NavigationMenuList>
<NavigationMenuItem>
<NavigationMenuLink className="font-bold text-xl">
Logo
</NavigationMenuLink>
</NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>
<Button
variant="ghost"
size="icon"
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
>
<Sun className="h-5 w-5 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
<Moon className="absolute h-5 w-5 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
</Button>
</div>
</header>
)
}
```
安全審計
低風險This skill is safe to publish. It provides UI component documentation and styling guidance. The only executable code is two Python utility scripts: shadcn_add.py (installs shadcn/ui components via npx subprocess) and tailwind_config_gen.py (generates Tailwind CSS config files). The subprocess.run() calls in shadcn_add.py use hardcoded command arguments (npx shadcn@latest add) with dry-run support, making them low-risk. All 770 static analysis findings were reviewed - the vast majority are false positives from font license files (SIL OFL text with URLs), SQLite coverage database binary data, and documentation markdown files containing code examples. No obfuscation, network callbacks, credential access, or dangerous code injection patterns were found.
低風險問題 (2)
風險因素
品質評分
你能建構什麼
建置管理後台
使用 shadcn/ui 元件與 Tailwind 工具類別快速建立管理介面,包含資料表格、導航選單、含驗證功能的表單,以及響應式卡片版面。
實作設計系統
透過產生包含自訂色彩、字型、間距與斷點的 Tailwind 設定檔,建立專案中一致的設計代碼,並將其套用至 shadcn/ui 主題化元件。
建立無障礙表單
使用 shadcn/ui 表單元件、react-hook-form 進行驗證,以及符合 ARIA 標準的鍵盤導航與螢幕閱讀器模式,建置具備完整無障礙支援的正式環境表單。
快速 UI 原型設計
按需安裝 shadcn/ui 元件、套用響應式 Tailwind 版面,並使用工具類別迭代視覺設計,無需撰寫自訂 CSS,即可快速建立 UI 概念原型。
視覺品牌素材
使用 canvas 設計系統模式,搭配精選字型組合與設計理念指引,產生基於 canvas 的視覺組合物、海報與品牌素材。
試試這些提示
為我的專案安裝以下 shadcn/ui 元件:[button, card, dialog, form, table]。接著展示一個完整的用法範例,將它們組合成[儀表板頁面 / 設定面板 / 資料檢視],並具備適當的版面配置與深色模式支援。
為我的 [Next.js / Vite / Astro] 專案產生 tailwind.config.ts,包含:自訂色彩調色盤[主色:藍色,強調色:紫色]、字型系列[無襯線用 Inter,等寬用 JetBrains Mono]、自訂間距[18: 4.5rem, 22: 5.5rem],以及額外斷點[3xl: 1920px]。包含建議的外掛。
使用 shadcn/ui 元件建立響應式[儀表板 / 登陸頁面 / 設定面板]版面,需包含:mobile-first 響應式網格、深色模式切換、支援鍵盤操作的無障礙導航,以及正確的語意化 HTML 結構。
使用 shadcn/ui 表單元件建立無障礙[註冊 / 聯絡 / 結帳]表單,需包含:使用 zod 進行欄位驗證、錯誤狀態處理、送出時的載入狀態、螢幕閱讀器適用的 ARIA 標籤、鍵盤 Tab 順序與焦點管理。
根據設計系統理念建立基於 canvas 的視覺[海報 / 品牌圖像 / 插圖],需包含:精緻的色彩調色盤、字型排版層級、空間構圖,以及博物館級的視覺衝擊力。使用最少文字。
最佳實務
- 從簡單、可組合的 shadcn/ui 基礎元件開始建構複雜 UI,而非打造單一大型元件
- 直接在 JSX 中使用 Tailwind 工具類別;僅在相同模式出現 3 次以上時才提取為可重複使用元件
- 採用 mobile-first 響應式設計:從基本行動版樣式開始,再疊加響應式變體(sm:、md:、lg:)
- 善用 Radix UI 內建的無障礙功能;務必加入可見的焦點指示器並使用語意化 HTML
- 維持一致的設計代碼:使用 tailwind.config 中定義的間距比例、色彩調色盤與字型排版系統
- 一致地在所有主題化元素上套用 dark: 變體,以避免出現半套的深色模式
- 避免動態建構類別名稱,以充分發揮 Tailwind 自動 CSS 清除的優勢
- 對 shadcn/ui 元件使用完整的 TypeScript 型別安全,以獲得更好的開發體驗並及早發現錯誤
- 讓視覺構圖引導注意力;有意識地運用間距、色彩與字型排版層級
- 將 UI 視為一門工藝,每個細節都很重要——從微互動到色彩對比度
避免
- 透過字串拼接動態建構 Tailwind 類別名稱(例如 `bg-${color}-500`),這會阻礙 CSS 清除;應改用完整類別名稱或 safelist 設定選項
- 直接覆寫 shadcn/ui 元件的原始檔,而非使用 CSS 變數主題系統或 variant slots
- 在元件提取中嵌套 Tailwind 的 @apply 指令,導致特殊性衝突
- 自行建置自訂 modal/dialog 實作,而 shadcn/ui 的 Dialog 或 Drawer 元件已提供可存取且經過測試的覆蓋層
- 透過複製整個元件樹來套用深色模式;應使用 dark: 變體前綴加在個別工具類別上
- 在專案中同時包含 .js 和 .ts 版本的 Tailwind 設定檔(只能啟用其中一個)
- 在未先執行 `npx shadcn@latest init` 初始化的情況下執行 shadcn/ui 元件安裝——components.json 設定檔是必需的
- 將 Canvas API 用於版面與結構,而非其設計目的:視覺設計組合物與圖形
- 在非按鈕元素上實作自訂點擊處理器時,忽略鍵盤使用者的 focus-visible 樣式
常見問題
使用這項技能前需要安裝任何東西嗎?
這項技能能與 React 以外的框架搭配使用嗎?
自動化腳本可以在正式 CI/CD 環境中使用嗎?
內含的 canvas 字型是什麼,我可以在我的網站上使用它們嗎?
這項技能在敏感專案中使用安全嗎?
開發者詳情
授權
MIT
引用
main