Decision Flow
Before building any UI component, follow these steps in order. Stop as soon as you find a match.
- •
Check existing components — Search
web/components/ui/andweb/components/blocks/for an existing component that fits. If found, import via@/components/*and use it. - •
Check shadcn/ui library — If no existing component matches, look up the equivalent in
./references/components.md. If available, install it using instructions from theweb/directory. - •
Create a new primitive — Only if steps 1 and 2 fail, create a new primitive under
web/components/ui/. Keep it generic with no domain logic.
Core Principles
- •Compose, Don’t Rebuild — Prefer composing existing shadcn/ui primitives over creating new primitives.
- •Primitives Stay Generic —
web/components/ui/*must not contain domain logic, data fetching, or feature-specific state. - •Match the Design System — Reuse existing patterns, spacing, typography, and interaction styles.
- •Mobile-First Tailwind — Write mobile classes first, then scale up (e.g.,
flex-col md:flex-row). - •Prefer Utility Classes — Use Tailwind for layout/spacing/typography; avoid inline styles unless unavoidable.
Component Placement Rules
- •
web/components/ui/— UI primitives only (buttons, inputs, dialogs, etc.). - •
web/components/blocks/— reusable compositions built from primitives. - •
web/features/*— feature/domain UI (may compose blocks + primitives; owns feature logic).
Styling Conventions
- •Prefer
cn()forclassNamecomposition (seeweb/components/lib/utils.ts). - •Keep responsive behavior consistent with existing layouts (container widths, breakpoints, spacing).
- •Avoid inline styles; use Tailwind utilities.
Anti-Patterns to Avoid
- •Adding feature-specific behavior to
web/components/ui/*. - •Introducing new primitives when an existing shadcn/ui primitive already matches.
- •Deep relative imports across domains (prefer
@/absolute imports). - •Desktop-first styling that breaks mobile layouts.
Quality Checklist
Before completing any UI component task:
- •Component is placed in the correct folder (
ui/vsblocks/vsfeatures/). - •
web/components/ui/*contains no domain logic or data fetching. - •Tailwind classes are mobile-first and match existing spacing/typography patterns.
- •
classNamecomposition usescn()when applicable.