UI Cookbook

Guide for frontend component design, library API usage, and architectural decisions. Use when building or refactoring UI components, choosing state management solutions, styling approaches, or optimizing frontend performance and accessibility.

lurui1997 Updated

File contents

Frontend Design

Provide concise, actionable guidance for modern frontend development.

Component Design

  • Prefer composition over inheritance.
  • Keep components focused on a single responsibility.
  • Lift state only when necessary; co-locate related logic.

State Management

  • Local state: use built-in primitives (useState, ref, signal).
  • Cross-component: prefer context or lightweight stores (Zustand, Pinia) before reaching for Redux.
  • Server state: use a data-fetching library (TanStack Query, SWR, RTK Query) to handle caching, deduplication, and background updates.

Styling

  • Use utility-first CSS (Tailwind) or CSS-in-JS based on team consensus.
  • Maintain design tokens for colors, spacing, and typography.
  • Avoid deeply nested selectors; keep specificity low.

Performance

  • Lazy-load routes and heavy components.
  • Memoize expensive computations and stable callbacks where profiling shows benefit.
  • Optimize images (modern formats, responsive srcset).

Accessibility

  • Use semantic HTML elements.
  • Ensure keyboard navigability and visible focus states.
  • Add meaningful alt text and ARIA labels where native semantics are insufficient.

lurui1997/awesome_skills/tree/main/ui-cookbook commit 9a18e5096b

Frequently asked questions

npx skillmds@latest add lurui1997/ui-cookbook