一键导入
component-library
Expert reference for building, maintaining, and governing design system component libraries
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Expert reference for building, maintaining, and governing design system component libraries
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Expert reference for application security — OWASP Top 10 mitigations, auth/authz, secrets management, cryptography, input validation, dependency hygiene, and secure-by-default code patterns
Expert reference for token counting, prompt compression, cost estimation, and quality preservation when optimizing prompts for Claude models
Experimentation design and A/B testing standards for product teams
Expert reference for digital accessibility — WCAG conformance, ARIA, and inclusive design patterns
Authoritative reference for agent architecture selection, multi-agent orchestration, tool design, memory systems, and failure mode prevention
Expert reference for evaluating LLM systems, RAG pipelines, and AI features in production
| name | component-library |
| description | Expert reference for building, maintaining, and governing design system component libraries |
| version | 1.0.0 |
#3b82f6 when --color-primary-500 exists.value/onChange.variant="destructive" not isDestructive)className on the root and document sub-element classes, or use CSS custom properties as escape hatches. Never expose style props for individual sub-elements.<Select> with <Select.Option>) → use React Context internally. Don't rely on prop drilling.|| defaultValue to paper over missing required data.Mistake: Conflating variants with states
Bad: <Button loading primary disabled /> — boolean soup
Good: <Button variant="primary" state="loading" disabled /> — clear separation of variant, state, and HTML attribute
Mistake: Leaking implementation details
Bad: <Dropdown menuClass="dropdown__menu-inner" />
Good: Expose a --dropdown-menu-bg CSS custom property or a documented menuClassName
Mistake: Component does too much
Bad: <UserCard showAvatar showBadge showActions onFollow onMessage onBlock compact /> — 20 props later it's a page
Good: <UserCard>, <UserCard.Avatar>, <UserCard.Actions> — compound component pattern
Mistake: Hardcoded breakpoints inside components
Bad: @media (max-width: 768px) inside Button styles
Good: Components are layout-agnostic. Responsive behavior belongs to layout components or the consuming context.
Mistake: Uncontrolled-only components
Bad: Modal that manages its own open/close state only
Good: open + onOpenChange props for controlled usage; default uncontrolled behavior preserved
Mistake: Story doesn't cover states Bad: One story showing the default button Good: Stories for every variant × every state (default, hover, focus, disabled, loading) + edge cases (long text, icon-only)
Mistake: Missing forwardRef
Bad: Component wraps a DOM element but doesn't forward ref — breaks any consumer using refs
Good: React.forwardRef on every component that renders a focusable/measurable element
Bad prop API:
<Button
onClick={handleClick}
isBlue
isBig
roundedFull
hasIcon
iconLeft={<PlusIcon />}
/>
Good prop API:
<Button
variant="primary"
size="lg"
leadingIcon={<PlusIcon />}
onClick={handleClick}
>
Create project
</Button>
Bad component (layout-coupled):
export function Badge({ label }) {
return (
<span style={{ marginLeft: '8px', display: 'inline-block' }}>
{label}
</span>
)
}
Good component (layout-agnostic):
export function Badge({ label, variant = 'default', className, ...props }) {
return (
<span
className={cn(badgeVariants({ variant }), className)}
{...props}
>
{label}
</span>
)
}
Atomic design: Atoms → Molecules → Organisms → Templates → Pages. Components at lower levels have fewer assumptions about context.
Primitive vs composite: Primitives (Button, Text, Box) are unstyled or minimally styled. Composites (Card, Modal, DataTable) layer primitives with opinion.
Headless components: Logic and accessibility only — no styles. Consumers bring their own CSS. (Radix UI, Headless UI model.)
Design tokens: The design system's single source of truth for color, spacing, typography, shadows. Tokens decouple design decisions from implementation.
Variant-first API design: Model variants as an exhaustive enum at design time. If you can't enumerate all variants, the design is underdefined.
Component contract: The documented guarantee between the library and its consumers — what props are stable, what is internal, what triggers a semver bump.
Escape hatches: Mechanisms consumers use when the component can't do what they need — className, CSS variables, asChild/as polymorphism. Must be documented and intentional.
Storybook as spec: Stories are the living specification of component behavior, not just demos. Every edge case that broke in production should become a story.
Prop spreading (...props): Pass HTML attributes through to the underlying element for maximum composability. Always spread onto the root DOM element, not a wrapper.