variant
Provides a type-safe system for managing component visual variants.
Install
mkdir -p .claude/skills/variant && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/13685" && unzip -o skill.zip -d .claude/skills/variant && rm skill.zipInstalls to .claude/skills/variant
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Variant type system for component visual variants. Invoke when defining component variant/type attributes using VARIANT_TYPES constant and Enum utility.Key capabilities
- →Define component visual variants
- →Extend existing variant values
- →Create custom enumerations for attributes
- →Map variants to icons
- →Integrate with BEM for class management
How it works
The skill uses the VARIANT_TYPES constant and an Enum utility to standardize the definition and extension of visual variant attributes for components.
Inputs & outputs
When to use variant
- →Define new component variants
- →Implement type-safe visual attributes
- →Standardize icon mapping for components
About this skill
Variant 类型系统
统一管理组件视觉变体类型的规范,使用 VARIANT_TYPES 常量和 Enum 工具。
常量定义
定义在 src/constants/variant.ts:
export const VARIANT_TYPES = [
"primary",
"success",
"warning",
"danger",
"info",
] as const;
export type VariantType = (typeof VARIANT_TYPES)[number];
export const VARIANT_DEFAULT = "info";
export const VARIANT_ICON_MAP: Record<string, string> = {
primary: "circle-info",
success: "circle-check",
info: "circle-info",
warning: "triangle-exclamation",
danger: "circle-xmark",
error: "circle-xmark",
};
Enum 工具
导入路径:@utils/Enum
import { Enum } from "@utils/Enum";
// 传入数组
Enum(VARIANT_TYPES) // 返回数组本身
// 传入多个参数
Enum("a", "b", "c") // 返回 ["a", "b", "c"]
Enum() 本质是标识函数,让 @attribute 的 type 字段区分枚举类型和普通构造器。
使用方式
基础用法
import { Enum } from "@utils/Enum";
import { VARIANT_TYPES, VARIANT_DEFAULT, type VariantType } from "@constants/variant";
@attribute({
type: Enum(VARIANT_TYPES),
default: VARIANT_DEFAULT,
observer(this: EaAlert, newVal: VariantType) {
this.updateContainerClasslist();
},
})
variant: VariantType = VARIANT_DEFAULT;
扩展 variant 值
@attribute({
type: Enum([...VARIANT_TYPES, "normal"]),
default: "normal",
observer(this: EaComponent) {
this.updateContainerClasslist();
},
})
variant: VariantType | "normal" = "normal";
自定义枚举(非 variant)
@attribute({
type: Enum(["outline", "solid", "dashed"]),
default: "solid",
})
borderStyle: string = "solid";
命名规则
- 属性名统一为
variant:用于表示组件视觉变体/类型的属性,不使用type - 统一使用
danger:作为错误类型,不使用error(VARIANT_ICON_MAP中保留error做兼容映射) - 可选值:
primary,success,warning,danger,info
与 BEM 配合
updateContainerClasslist(): string {
const className = bem(
{ [this.variant]: true },
{ disabled: this.disabled }
);
this._container.className = className;
return className;
}
@include block($name) {
@include modifier(primary) {
background-color: var(--primary-color);
}
@include modifier(success) {
background-color: var(--green-500);
}
@include modifier(danger) {
background-color: var(--red-500);
}
}
图标映射
使用 VARIANT_ICON_MAP 获取 variant 对应的图标名:
import { VARIANT_ICON_MAP } from "@constants/variant";
const iconName = VARIANT_ICON_MAP[this.variant]; // 如 "circle-check"
When not to use it
- →When defining component attributes that are not visual variants or enumerations
- →When the attribute name is 'type' instead of 'variant'
Limitations
- →Requires the attribute name to be 'variant' for visual variants
- →Requires using 'danger' as the error type, not 'error'
- →Relies on the Enum utility to distinguish enum types from ordinary constructors
How it compares
This system provides a standardized, type-safe approach to managing component visual variants and their associated icons, unlike ad-hoc string-based attribute definitions.
Compared to similar skills
variant side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| variant (this skill) | 0 | 2mo | No flags | Intermediate |
| scroll-experience | 101 | 6mo | No flags | Intermediate |
| anthropic-frontend-design | 12 | 6mo | No flags | Intermediate |
| infographic-structure-creator | 1 | 5mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
scroll-experience
davila7
Expert in building immersive scroll-driven experiences - parallax storytelling, scroll animations, interactive narratives, and cinematic web experiences. Like NY Times interactives, Apple product pages, and award-winning web experiences. Makes websites feel like experiences, not just pages. Use when: scroll animation, parallax, scroll storytelling, interactive story, cinematic website.
anthropic-frontend-design
chaibuilder
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.
infographic-structure-creator
antvis
Generate or update infographic Structure components for this repo (TypeScript/TSX in src/designs/structures). Use when asked to design, implement, or modify structure layouts (list/compare/sequence/hierarchy/relation/geo/chart), including layout logic, component composition, and registration.
logo-with-variants
crafter-station
Create logo components with multiple variants (icon, wordmark, logo) and light/dark modes. Use when the user provides logo SVG files and wants to create a variant-based logo component following the Clerk pattern in the Elements project.
design-context
WellApp-ai
Refresh UI/UX context from design system, Storybook, and codebase
threejs-postprocessing
CloudAI-X
Three.js post-processing - EffectComposer, bloom, DOF, screen effects. Use when adding visual effects, color grading, blur, glow, or creating custom screen-space shaders.