闲社服务运行正常AI智能体自动化平台
d

设计系统组件

技能标识:design-system-components

Patterns for building design system components using Surface primitives, CVA variants, and consistent styling. Use when building reusable UI components that follow design token architecture. Triggers on Surface component, CVA, class-variance-authority, component variants, design tokens.

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 1.0.0
检测标记
后台标记通过
免费
免费获取
2
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

设计系统组件

设计系统组件

构建可复用的组件,利用Surface原语和CVA(class-variance-authority)来使用设计令牌。



使用场景

  • - 使用设计令牌构建组件库
  • 需要基于变体的样式(尺寸、颜色、状态)
  • 创建具有一致表面的分层UI
  • 需要类型安全的组件API

模式1:Surface原语

适用于所有分层表面的单一组件:

tsx
import { cva, type VariantProps } from class-variance-authority;
import { cn } from @/lib/utils;

const surfaceVariants = cva(
rounded-lg backdrop-blur-sm transition-colors,
{
variants: {
layer: {
panel: bg-tone-cadet/40 border border-tone-jordy/10 shadow-card,
tile: bg-tone-midnight/60 border border-tone-jordy/5,
chip: bg-tone-cyan/10 border border-tone-cyan/20 rounded-full,
deep: bg-tone-void/80,
metric: bg-tone-cadet/20 border border-tone-jordy/8,
glass: bg-glass-bg backdrop-blur-lg border border-glass-border,
},
interactive: {
true: cursor-pointer hover:bg-tone-cadet/50 active:scale-[0.98],
false: ,
},
glow: {
true: shadow-glow,
false: ,
},
},
defaultVariants: {
layer: tile,
interactive: false,
glow: false,
},
}
);

interface SurfaceProps
extends React.HTMLAttributes,
VariantProps {}

export function Surface({
layer,
interactive,
glow,
className,
...props
}: SurfaceProps) {
return (
className={cn(surfaceVariants({ layer, interactive, glow }), className)}
{...props}
/>
);
}

使用示例

tsx

仪表盘



活跃


$1,234.56



模式2:CVA按钮变体

tsx
const buttonVariants = cva(
inline-flex items-center justify-center rounded-md font-medium transition-all focus-visible:outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50,
{
variants: {
variant: {
default: bg-primary text-primary-foreground hover:bg-primary/90,
destructive: bg-destructive text-destructive-foreground hover:bg-destructive/90,
outline: border border-input bg-background hover:bg-accent hover:text-accent-foreground,
ghost: hover:bg-accent hover:text-accent-foreground,
link: text-primary underline-offset-4 hover:underline,
cyber: bg-gradient-to-r from-tone-cadet to-tone-azure text-white border border-tone-cyan/30 shadow-glow hover:shadow-glow-lg,
},
size: {
default: h-10 px-4 py-2,
sm: h-9 rounded-md px-3,
lg: h-11 rounded-md px-8,
icon: h-10 w-10,
},
},
defaultVariants: {
variant: default,
size: default,
},
}
);



模式3:指标显示组件

tsx
const metricVariants = cva(
font-mono tabular-nums,
{
variants: {
size: {
lg: text-3xl font-bold tracking-tight,
md: text-xl font-semibold,
sm: text-base font-medium,
},
trend: {
positive: text-success,
negative: text-destructive,
neutral: text-foreground,
},
},
defaultVariants: {
size: md,
trend: neutral,
},
}
);

interface MetricProps extends VariantProps {
value: string | number;
label?: string;
prefix?: string;
suffix?: string;
}

export function Metric({
value,
label,
prefix = ,
suffix = ,
size,
trend,
}: MetricProps) {
return (


{label && (

{label}

)}

{prefix}{value}{suffix}


);
}


模式4:带标题的卡片

tsx
interface CardProps {
title?: string;
description?: string;
action?: React.ReactNode;
children: React.ReactNode;
}

export function Card({ title, description, action, children }: CardProps) {
return (

{(title || action) && (



{title && (

{title}


)}
{description && (

{description}


)}

{action}

)}
{children}


);
}


模式5:徽章/标签变体

tsx
const badgeVariants = cva(
inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors,
{
variants: {
variant: {
default: bg-primary/10 text-primary border border-primary/20,
success: bg-success/10 text-success border border-success/20,
warning: bg-warning/10 text-warning border border-warning/20,
destructive: bg-destructive/10 text-destructive border border-destructive/20,
outline: border border-input text-foreground,
},
},
defaultVariants: {
variant: default,
},
}
);



模式6:组合变体

将CVA与条件类结合:

tsx
function StatusIndicator({
status,
size = md
}: {
status: online | offline | away;
size?: sm | md | lg;
}) {
const sizeClasses = {
sm: size-2,
md: size-3,
lg: size-4,
};

const statusClasses = {
online: bg-success animate-pulse,
offline: bg-muted-foreground,
away: bg-warning,
};

return (
className={cn(
rounded-full,
sizeClasses[size],
statusClasses[status]
)}
/>
);
}



相关技能


禁止事项

  • - 构建自定义卡片容器 — 使用Surface原语
  • 在组件中硬编码颜色 — 使用设计令牌
  • 跳过变体类型 — CVA提供类型安全
  • 混合样式方法 — 选择CVA或cn(),不要随机使用内联样式
  • 忘记默认变体 — 组件应在不传props时也能正常工作

快速参考

tsx
// 1. 使用CVA定义变体
const variants = cva(base-classes, {
variants: {
size: { sm: ..., md: ..., lg: ... },
color: { primary: ..., secondary: ... },
},
defaultVariants: { size: md, color: primary },
});

// 2. 从变体类型化props
interface Props extends VariantProps {}

// 3. 在组件中应用

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 design-system-components-1776419997 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 design-system-components-1776419997 技能

通过命令行安装

skillhub install design-system-components-1776419997

下载

⬇ 下载 design-system-components v1.0.0(免费)

文件大小: 4.14 KB | 发布时间: 2026-4-17 19:12

v1.0.0 最新 2026-4-17 19:12
Initial release of design-system-components skill.

- Provides patterns for building reusable UI components using Surface primitives, CVA variants, and design tokens.
- Includes examples for Surface, Button, Metric, Card, Badge/Chip, and StatusIndicator components.
- Demonstrates how to structure components for style consistency, type-safety, and variant-based design.
- Outlines best practices and "never do" guidance to enforce design system standards.
- Features quick reference snippets for implementing variant-based styles.
- Lists related skills for extended design system workflows.
返回顶部