CSS implementation patterns for layout, typography, color, spacing, and responsive design. Complements ui-design (fundamentals) with code-focused examples.
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install web-design或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install web-design⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/web-design/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: web-design model: standard description: CSS implementation patterns for layout, typography, color, spacing, and responsive design. Complements ui-design (fundamentals) with code-focused examples. version: "1.1.0" related: [ui-design, frontend-design, design-system-patterns] ---
CSS implementation patterns for production-grade interfaces. For design fundamentals and decision-making, see ui-design. This skill focuses on code.
> See also: ui-design for typography/color/spacing theory, frontend-design for creative aesthetics.
npx clawhub@latest install web-design
Use CSS Grid for two-dimensional layouts and Flexbox for one-dimensional flow. Choose the right tool for each context.
| Layout Need | Tool | Why | |---|---|---| | Page-level structure | CSS Grid (grid-template-areas) | Named regions, explicit row/column control | | Navigation bars | Flexbox | Single-axis alignment, spacing with gap | | Card grids | Grid (auto-fill / auto-fit) | Responsive without media queries | | Centering | Grid (place-items: center) | Shortest, most reliable centering | | Sidebar + content | Grid (grid-template-columns: 250px 1fr) | Proportional sizing with fixed sidebar | | Stacking overlaps | Grid + grid-area: 1/1 | Layer elements without position: absolute |
Go beyond predictable layouts. Intentional asymmetry, overlapping elements, and grid-breaking accents create visual interest. Use grid stacking (grid-area: 1/1) instead of position: absolute for overlapping elements. Choose generous negative space for luxury/editorial aesthetics, or controlled density for data-rich interfaces — the choice must be intentional.
Typography carries 90% of a design's personality. Choose fonts that match the interface's purpose.
| Context | Display Font Direction | Body Font Direction | Example Pairing | |---|---|---|---| | Editorial / magazine | High-contrast serif | Neutral humanist sans | Playfair Display + Source Sans 3 | | SaaS dashboard | Geometric sans | Matching weight sans | DM Sans + DM Mono (data) | | Creative portfolio | Expressive display | Clean readable sans | Syne + Outfit | | E-commerce luxury | Thin modern serif | Elegant sans | Cormorant Garamond + Jost | | Developer tooling | Monospace display | Monospace body | JetBrains Mono + IBM Plex Mono |
Use a consistent ratio. A 1.25 (major third) scale works for most interfaces: text-xs 0.64rem, text-sm 0.8rem, text-base 1rem, text-lg 1.25rem, text-xl 1.563rem, text-2xl 1.953rem, text-3xl 2.441rem, text-4xl 3.052rem. Set body text to 1rem (16px minimum), line-height 1.5 for body, 1.1–1.2 for headings. Limit line length to 60–75ch.
Every palette needs five functional roles:
| Role | Purpose | Example Usage | |---|---|---| | Primary | Brand identity, primary actions | Buttons, links, active states | | Neutral | Text, borders, backgrounds | Body text, cards, dividers | | Accent | Secondary actions, highlights | Tags, badges, secondary buttons | | Success / Warning / Error | Semantic feedback | Toasts, form validation, status | | Surface | Layered backgrounds | Cards on page, modals on overlay |
Create depth through surface layering, not just shadows:
:root {
--surface-0: hsl(220 15% 8%); /* page background */
--surface-1: hsl(220 15% 12%); /* card */
--surface-2: hsl(220 15% 16%); /* raised element */
--surface-3: hsl(220 15% 20%); /* popover / modal */
}
Use HSL or OKLCH for perceptually uniform color manipulation. Dominant color with sharp accents outperforms evenly-distributed palettes. Always verify WCAG contrast: 4.5:1 for normal text, 3:1 for large text.
Consistent spacing creates rhythm. Use an 8px base unit (or 4px for dense UIs):
| Token | Value | Use | |---|---|---| | --space-1 | 0.25rem (4px) | Inline icon gaps, tight padding | | --space-2 | 0.5rem (8px) | Input padding, compact lists | | --space-3 | 0.75rem (12px) | Button padding, card inner spacing | | --space-4 | 1rem (16px) | Default element spacing | | --space-6 | 1.5rem (24px) | Section padding, card gaps | | --space-8 | 2rem (32px) | Section separation | | --space-12 | 3rem (48px) | Major section breaks | | --space-16 | 4rem (64px) | Page-level vertical rhythm |
Apply spacing consistently: use gap on Grid/Flexbox containers instead of margins on children. This eliminates margin-collapse bugs and simplifies responsive adjustments.
Guide the eye through deliberate contrast in size, weight, color, and space.
| Technique | How | Impact | |---|---|---| | Size contrast | Hero heading 3–4x body size | Immediate focal point | | Weight contrast | Bold headings + regular body | Scannability | | Color contrast | Primary text vs muted secondary | Information layering | | Spatial grouping | Tight spacing within groups, wide between | Gestalt proximity | | Elevation | Shadows / surface layers | Interactive affordance | | Whitespace isolation | Empty space around key element | Emphasis through absence |
Layer hierarchy within cards: eyebrow (xs, uppercase, muted) → title (xl, semibold) → body (base, secondary color, 1.6 line-height) → action (spaced apart with margin-top). Use surface color for separation and consistent padding from spacing tokens.
| Breakpoint | Target | Approach | |---|---|---| | < 640px | Mobile | Single column, stacked navigation, touch targets ≥ 44px | | 640–1024px | Tablet | Two-column options, collapsible sidebars | | 1024–1440px | Desktop | Full layout, hover interactions enabled | | > 1440px | Wide | Max-width container (1280px), prevent ultra-wide line lengths |
Prefer fluid sizing over rigid breakpoints where possible:
/* Fluid typography — scales between 640px and 1440px viewport */
h1 { font-size: clamp(2rem, 1.5rem + 2.5vw, 3.5rem); }
/* Fluid spacing */
section { padding-block: clamp(2rem, 1rem + 4vw, 6rem); }
/* Intrinsic grid — no media queries needed */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: var(--space-6); }
Use container queries (@container) for component-level responsiveness when a component's layout should respond to its container, not the viewport.
Accessibility is not optional. Build it in from the start.
| Requirement | Implementation | Standard | |---|---|---| | Color contrast | 4.5:1 normal text, 3:1 large text / UI | WCAG 2.1 AA | | Keyboard navigation | All interactive elements focusable and operable | WCAG 2.1.1 | | Focus indicators | Visible :focus-visible ring, 2px+ offset | WCAG 2.4.7 | | Semantic HTML | Use , , , etc. | WCAG 1.3.1 | | Alt text | Descriptive for informational images, alt="" for decorative | WCAG 1.1.1 | | Motion safety | Respect prefers-reduced-motion | WCAG 2.3.3 | | Touch targets | Minimum 44×44px interactive areas | WCAG 2.5.8 | | ARIA when needed | aria-label, aria-live, role only when native semantics insufficient | WCAG 4.1.2 |
/* Robust focus indicator */
:focus-visible {
outline: 2px solid var(--color-primary);
outline-offset: 2px;
}
/* Respect motion preferences */
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
transition-duration: 0.01ms !important;
}
}
Every UI component should have clear states, consistent spacing, and predictable behavior:
...
安装 Web Design 后,可以对 AI 说这些话来触发它
Help me get started with Web Design
Explains what Web Design does, walks through the setup, and runs a quick demo based on your current project
Use Web Design to cSS implementation patterns for layout, typography, color, spacing,...
Invokes Web Design with the right parameters and returns the result directly in the conversation
What can I do with Web Design in my design & creative workflow?
Lists the top use cases for Web Design, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/web-design/ 目录(个人级,所有项目可用),或 .claude/skills/web-design/(项目级)。重启 AI 客户端后,用 /web-design 主动调用,或让 AI 根据上下文自动发现并使用。
Web Design 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Web Design 可免费安装使用。请查阅仓库了解许可证信息。
CSS implementation patterns for layout, typography, color, spacing, and responsive design. Complements ui-design (fundamentals) with code-focused examples.
Web Design 属于「Design & Creative」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my design & creative tasks using Web Design
Identifies repetitive steps in your workflow and sets up Web Design to handle them automatically