AgentSkillsCN

carbon-design-system

使用 IBM 的 Carbon 设计系统构建 UI。当用户要求设计 Carbon 风格的界面、IBM 风格的仪表板、遵循 Carbon 规范的企业级 UI,或明确提及 Carbon、IBM 设计,或 @carbon/react 时使用。涵盖组件使用、设计令牌(颜色、字体、间距、动效)、主题化(白色、灰 10、灰 90、灰 100)、网格布局以及无障碍访问。同时支持产物输出/HTML 输出(基于 CDN)和完整的 React 项目输出(@carbon/react)。触发词包括“Carbon”、“IBM 设计系统”、“企业级仪表板”、“@carbon/react”、“Carbon 组件”,或任何对 IBM 风格专业界面的需求。

SKILL.md
--- frontmatter
name: carbon-design-system
description: Build UIs using IBM's Carbon Design System. Use when the user requests Carbon-styled interfaces, IBM-style dashboards, enterprise UIs following Carbon conventions, or explicitly mentions Carbon, IBM design, or @carbon/react. Covers component usage, design tokens (color, typography, spacing, motion), theming (White, Gray 10, Gray 90, Gray 100), grid layout, and accessibility. Supports both artifact/HTML output (CDN-based) and full React project output (@carbon/react). Triggers include "Carbon", "IBM design system", "enterprise dashboard", "@carbon/react", "carbon components", or requests for IBM-style professional interfaces.

Carbon Design System

Build UIs conforming to IBM's Carbon Design System v11. Carbon provides a token-based, accessible, enterprise-grade component library.

Rendering Context

Determine the output target before writing code.

HTML Artifacts (no build pipeline)

Use pre-built CSS via CDN. Add to <head>:

html
<link rel="stylesheet" href="https://unpkg.com/@carbon/styles/css/styles.css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;600&family=IBM+Plex+Mono:wght@400;600&display=swap" />

Apply Carbon classes to HTML elements. See references/html-classes.md.

React Artifacts

@carbon/react is not in Claude's default artifact environment. For React artifacts, load the CDN CSS above and apply Carbon class names to standard HTML/JSX elements. The visual output is identical.

Full Projects (file creation)

bash
npm install @carbon/react sass
jsx
import { Button } from '@carbon/react';
// Styles: @use '@carbon/react'; in root SCSS

Requires Dart Sass. All styles, components, icons ship in the single @carbon/react package.

Design Foundations

Typography

Always use IBM Plex. Never substitute.

RoleFamilyWeights
Body, UIIBM Plex Sans300, 400, 600
CodeIBM Plex Mono400, 600
EditorialIBM Plex Serif300, 400, 600

Color Themes

ThemeBackgroundContext
White#ffffffDefault light
g10#f4f4f4Subtle light
g90#262626Dark
g100#161616High-contrast dark

Primary action: Blue 60 #0f62fe. See references/tokens.md for full palette.

Spacing

8px base grid, 2px mini-unit. Component spacing: 2, 4, 8, 12, 16, 24, 32, 40, 48 px. Layout spacing: 16, 24, 32, 48, 64, 96, 160 px.

2x Grid

BreakpointWidthColumnsMargin
sm320px40
md672px816px
lg1056px1616px
xlg1312px1616px
max1584px1624px

Grid classes: cds--grid, cds--row, cds--col, cds--col-sm-N, cds--col-md-N, cds--col-lg-N.

Motion

TokenDurationUse
fast-0170msMicro-interactions
fast-02110msToggle, expand
moderate-01150msButtons, fields
moderate-02240msModal, dropdown
slow-01400msPage transitions
slow-02700msComplex choreography

Standard easing: cubic-bezier(0.2, 0, 0.38, 0.9). Entrance: cubic-bezier(0, 0, 0.38, 0.9). Exit: cubic-bezier(0.2, 0, 1, 0.9).

References

  • Component HTML classes and usage: references/html-classes.md
  • Full design token values: references/tokens.md

Read the appropriate reference when building specific components or when exact token values are needed.

Implementation Checklist

  1. IBM Plex loaded (Sans minimum; Mono for code)
  2. Theme class applied: cds--white, cds--g10, cds--g90, or cds--g100
  3. Correct prefix: cds-- (v11). Never bx-- (v10 legacy)
  4. Grid layout: cds--grid > cds--row > cds--col-*
  5. Spacing from scale only — no arbitrary pixel values
  6. Focus states preserved — 2px blue outline
  7. Color by role via tokens, not raw hex
  8. Icons at Carbon sizes: 16, 20, 24, 32px

Common Patterns

Page Shell

html
<div class="cds--white" style="min-height:100vh">
  <header class="cds--header" role="banner">
    <a class="cds--header__name" href="#">[App Name]</a>
  </header>
  <div class="cds--grid" style="padding-top:3rem">
    <div class="cds--row">
      <div class="cds--col-lg-3"><!-- Side nav --></div>
      <div class="cds--col-lg-13"><!-- Content --></div>
    </div>
  </div>
</div>

Theme Nesting

html
<div class="cds--g100"><!-- dark header --></div>
<div class="cds--white"><!-- light body --></div>

Data Dashboard

Combine cds--tile containers for metric cards with cds--data-table for tabular data, all within the 2x grid.

Anti-Patterns

  • Non-IBM Plex fonts
  • bx-- prefix (v10; use cds-- for v11)
  • Arbitrary border-radius (Carbon: 0px default, 4px for tags/pills only)
  • Drop shadows on components that lack them in spec
  • Overriding focus ring styles
  • Colors outside the Carbon palette
  • Spacing values not on the scale