Get the FREE Ultimate OpenClaw Setup Guide →

design-patterns

Scanned
npx machina-cli add skill shahtuyakov/claude-setup/design-patterns --openclaw
Files (1)
SKILL.md
7.2 KB

Design Patterns

Modern design system patterns optimized for 2025 web development.

Technology Selection

CSS Framework

OptionBest ForNotes
Tailwind CSS 4Most projectsCSS-first config, P3 colors
Vanilla CSSSimple sitesCSS variables, modern features
CSS ModulesComponent isolationScoped styles

Component Library

OptionBest ForNotes
shadcn/uiFull controlCopy-paste, Radix + Tailwind
Radix UICustom designHeadless, accessible primitives
Base UIFuture-proofBy Radix team, actively maintained

Animation

OptionBest ForNotes
Framer MotionReact appsDeclarative, layout animations
GSAPComplex timelinesSVG, scroll-driven
CSS transitionsSimple statesNo JS, performant

Reference Files

TopicLoadUse When
Design tokensreferences/design-tokens.mdToken architecture, CSS variables
Color systemsreferences/color-systems.mdOKLCH, palettes, contrast
Typographyreferences/typography.mdFluid type, scales
Animationreferences/animation.mdFramer Motion, micro-interactions
Dark modereferences/dark-mode.mdTheme switching
Componentsreferences/component-patterns.mdshadcn/ui, Radix
Handoffreferences/design-handoff.mdFigma Dev Mode

Quick Start

Tailwind CSS 4 Setup

/* app.css */
@import "tailwindcss";

@theme {
  /* Colors - OKLCH for P3 gamut */
  --color-primary: oklch(55% 0.25 250);
  --color-secondary: oklch(65% 0.15 300);
  --color-destructive: oklch(55% 0.25 25);

  /* Typography */
  --font-sans: "Inter Variable", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  /* Spacing (4px base) */
  --spacing-px: 1px;
  --spacing-0: 0;
  --spacing-1: 0.25rem;
  --spacing-2: 0.5rem;
  --spacing-4: 1rem;
  --spacing-8: 2rem;

  /* Border radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-full: 9999px;
}

CSS Variables (Token System)

:root {
  /* Primitives */
  --blue-50: oklch(97% 0.02 250);
  --blue-500: oklch(55% 0.25 250);
  --blue-900: oklch(25% 0.15 250);

  /* Semantic */
  --color-background: var(--blue-50);
  --color-foreground: var(--blue-900);
  --color-primary: var(--blue-500);

  /* Component */
  --button-bg: var(--color-primary);
  --button-text: white;
}

.dark {
  --color-background: oklch(12% 0.02 250);
  --color-foreground: oklch(95% 0.02 250);
}

Fluid Typography

:root {
  /* Fluid type scale */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.375vw, 1rem);
  --text-base: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.625vw, 1.25rem);
  --text-xl: clamp(1.25rem, 1rem + 1.25vw, 1.5rem);
  --text-2xl: clamp(1.5rem, 1rem + 2.5vw, 2rem);
  --text-3xl: clamp(1.875rem, 1rem + 4.375vw, 3rem);
}

Animation Basics

// Framer Motion - Fade in
import { motion } from "framer-motion";

export function FadeIn({ children }) {
  return (
    <motion.div
      initial={{ opacity: 0, y: 10 }}
      animate={{ opacity: 1, y: 0 }}
      transition={{ duration: 0.3 }}
    >
      {children}
    </motion.div>
  );
}

// Respect reduced motion
const prefersReducedMotion = window.matchMedia(
  "(prefers-reduced-motion: reduce)"
).matches;

const variants = prefersReducedMotion
  ? { initial: {}, animate: {} }
  : { initial: { opacity: 0 }, animate: { opacity: 1 } };

Dark Mode Toggle

// Theme provider pattern
import { useEffect, useState } from "react";

export function useTheme() {
  const [theme, setTheme] = useState<"light" | "dark">("light");

  useEffect(() => {
    // Check system preference
    const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
    const stored = localStorage.getItem("theme");

    setTheme(stored ? stored as "light" | "dark" : prefersDark ? "dark" : "light");
  }, []);

  useEffect(() => {
    document.documentElement.classList.toggle("dark", theme === "dark");
    localStorage.setItem("theme", theme);
  }, [theme]);

  return { theme, setTheme, toggle: () => setTheme(t => t === "light" ? "dark" : "light") };
}

Design Principles

Token Architecture

┌─────────────────────────────────────┐
│  Primitive Tokens                   │
│  Raw values: colors, sizes, fonts   │
│  --blue-500: oklch(55% 0.25 250)   │
├─────────────────────────────────────┤
│  Semantic Tokens                    │
│  Purpose-based: primary, danger     │
│  --color-primary: var(--blue-500)  │
├─────────────────────────────────────┤
│  Component Tokens                   │
│  Specific usage: button-bg          │
│  --button-bg: var(--color-primary) │
└─────────────────────────────────────┘

Accessibility Checklist

  • Color contrast AA (4.5:1 text, 3:1 UI)
  • Focus indicators visible (2px minimum)
  • Touch targets 44x44px minimum
  • Reduced motion support
  • Semantic HTML structure
  • ARIA labels where needed
  • Keyboard navigation works

Responsive Strategy

Mobile-first approach:
1. Base styles = mobile
2. sm: (640px) = large phones
3. md: (768px) = tablets
4. lg: (1024px) = laptops
5. xl: (1280px) = desktops

Container queries for components:
@container (min-width: 400px) { ... }

Common Patterns

Button with States

// Tailwind + shadcn style
<button className="
  inline-flex items-center justify-center
  h-10 px-4 py-2
  bg-primary text-primary-foreground
  rounded-md text-sm font-medium
  transition-colors duration-150
  hover:bg-primary/90
  focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring
  disabled:opacity-50 disabled:pointer-events-none
">
  Click me
</button>

Card with Hover

<div className="
  rounded-lg border bg-card p-6
  shadow-sm
  transition-all duration-200
  hover:shadow-md hover:-translate-y-0.5
">
  <h3 className="text-lg font-semibold">Card Title</h3>
  <p className="text-muted-foreground">Card content here.</p>
</div>

Loading Skeleton

<div className="animate-pulse">
  <div className="h-4 bg-muted rounded w-3/4 mb-2" />
  <div className="h-4 bg-muted rounded w-1/2" />
</div>

Performance Tips

  1. Use CSS over JS for simple animations
  2. Avoid layout thrashing - batch DOM reads/writes
  3. Lazy load below-fold content
  4. Optimize images - WebP, proper sizing
  5. Reduce motion for accessibility & performance
  6. Use will-change sparingly for complex animations

Source

git clone https://github.com/shahtuyakov/claude-setup/blob/main/skills/design-patterns/SKILL.mdView on GitHub

Overview

A practical guide to modern design system patterns for 2025, covering design tokens, OKLCH color systems, fluid typography, animations, dark mode, shadcn/ui components, and Figma handoff. It helps teams implement cohesive UI styles, theming, accessibility, and visual polish across projects.

How This Skill Works

The skill maps technology choices (Tailwind CSS 4, Vanilla CSS, CSS Modules) to component libraries (shadcn/ui, Radix UI, Base UI) and patterns for tokens, color systems, typography, animation, and handoff. It provides reference files and a Quick Start with concrete code samples to bootstrap a design system aligned with 2025 practices.

When to Use It

  • When implementing UI styles and theming across a product with consistent tokens and color systems
  • When building dark mode support and accessible color contrasts using OKLCH
  • When selecting a CSS framework or component library for a project
  • When standardizing typography with fluid scales and responsive type
  • When coordinating design handoff between Figma designs and development (Dev Mode)

Quick Start

  1. Step 1: Set up Tailwind CSS 4 and define OKLCH color tokens in app.css
  2. Step 2: Create a CSS Variables token system for primitives, semantic colors, and components
  3. Step 3: Add fluid typography, basic animations, and a dark mode toggle with a theme provider

Best Practices

  • Define design tokens first (primitives, semantic colors, and component tokens) and document their usage
  • Use OKLCH color systems to ensure perceptual uniformity and contrast across themes
  • Implement fluid typography with clamp-based scales for consistent readability
  • Respect reduced motion preferences and provide accessible, performant animations
  • Maintain a single source of truth for dark mode tokens and theme switching in a global provider

Example Use Cases

  • Tailwind CSS 4 setup with OKLCH color tokens defined in app.css
  • CSS Variables token system with primitives, semantic colors, and component tokens
  • Fluid typography definitions using clamp-based scales
  • Framer Motion animations with reduced motion respect and simple fade-in examples
  • Dark mode toggle implemented via a theme provider pattern and CSS variable overrides

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers