ckm:ui-styling
UI 样式工具包 - shadcn/ui、Tailwind CSS 与 Canvas 设计系统
通过将 shadcn/ui 的可访问组件库与 Tailwind CSS 实用优先样式及基于 Canvas 的可视化设计系统相结合,消除 UI 开发摩擦。本技能提供 40+ 个 shadcn/ui 组件的全面参考文档、主题及深色模式方案、可访问性指南、响应式设计实用工具,以及用于组件安装和 Tailwind 配置生成的 Python 自动化脚本。
下载技能 ZIP
在 Claude 中上传
前往 设置 → 功能 → 技能 → 上传技能
开启并开始使用
测试它
正在使用“ckm:ui-styling”。 安装 shadcn/ui 的 button、card 和 dialog 组件,并展示一个基于 card 的设置面板
预期结果:
```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 组件创建响应式[仪表盘/落地页/设置面板]布局:移动优先的响应式网格、深色模式切换开关、支持键盘导航的可访问导航、以及正确的语义化 HTML 结构。
使用 shadcn/ui 表单组件构建无障碍[注册/联系/结账]表单:使用 zod 进行字段验证、错误状态处理、提交时加载状态、面向屏幕阅读器的 ARIA 标签、键盘 Tab 顺序和焦点管理。
使用设计系统理念创建基于 Canvas 的[海报/品牌图形/插画]:精致的调色板、排版层次、空间构图和博物馆级的视觉冲击力。尽量少用文字。
最佳实践
- 从简单、可组合的 shadcn/ui 原语构建复杂 UI,而非创建单体组件
- 直接在 JSX 中使用 Tailwind 工具类;仅在相同模式出现 3 次以上时才提取可复用组件
- 采用移动优先的响应式设计:从基础移动端样式开始,然后叠加响应式变体(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 指令,导致产生特异性冲突
- 在 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