--- name: frontend-atomic-design description: Create modern, responsive frontend components and layouts using atomic design methodology with Tailwind CSS. Use this skill whenever building React components, designing UI layouts, creating responsive pages, or working with atomic design principles. Triggers include: component development, page design, responsive design requests, Tailwind CSS styling, creating design systems, building reusable UI elements, or designing for multiple screen sizes (desktop, tablet, mobile). This skill emphasizes reusable variables, modern aesthetics, and responsive design across all viewport sizes. --- # Atomic Design Frontend System with Tailwind CSS A comprehensive guide for building modern, responsive frontend applications using atomic design principles and Tailwind CSS. ## Core Principles ### 1. Atomic Design Hierarchy Atomic Design breaks UI into five distinct levels: #### **Atoms** Smallest, indivisible UI elements that cannot be broken down without losing functionality. - Buttons, input fields, labels, icons, text styles - Color variables, spacing units, typography scales - Simple, pure, reusable building blocks ```jsx // Example: Button Atom ``` #### **Molecules** Groups of atoms bonded together, forming simple functional units. - Search bars (input + button + icon) - Form fields (label + input + error message) - Card headers (avatar + title + subtitle) - Navigation items with icons and labels ```jsx // Example: Search Molecule
``` #### **Organisms** Complex functional units made of groups of molecules and/or atoms. - Header/Navigation bars - Form sections (multiple form molecules) - Card layouts with multiple sections - Modals with title, content, and actions - Data tables with headers, rows, and pagination ```jsx // Example: Product Card Organism

Product Name

Description

$99
``` #### **Templates** Page-level wireframes showing layout and component placement without final content. - Single-column layouts - Two-column layouts (sidebar + main) - Grid-based layouts - Hero + content sections #### **Pages** Specific instances of templates populated with real content and data. - Homepage with actual products - User profile with real user data - Dashboard with live metrics --- ## Design System Variables (Reusable Values) ### Color Palette ```css /* Define in Tailwind config or use CSS variables */ Primary: #2563eb (blue-600) Secondary: #7c3aed (violet-600) Success: #16a34a (green-600) Warning: #ea580c (orange-600) Danger: #dc2626 (red-600) Neutral: #6b7280 (gray-500) ``` ### Typography Scale ```css H1: 32px (2rem) - font-bold H2: 24px (1.5rem) - font-bold H3: 20px (1.25rem) - font-semibold Body: 16px (1rem) - font-normal Small: 14px (0.875rem) - font-normal Tiny: 12px (0.75rem) - font-normal ``` ### Spacing Scale ```css xs: 4px (0.25rem) sm: 8px (0.5rem) md: 16px (1rem) lg: 24px (1.5rem) xl: 32px (2rem) 2xl: 48px (3rem) ``` ### Border Radius ```css Subtle: 4px (rounded-sm) Standard: 8px (rounded-lg) Large: 12px (rounded-xl) Full: 9999px (rounded-full) ``` ### Box Shadows ```css Subtle: 0 1px 2px rgba(0,0,0,0.05) Soft: 0 4px 6px rgba(0,0,0,0.07) Medium: 0 10px 15px rgba(0,0,0,0.10) Strong: 0 20px 25px rgba(0,0,0,0.15) ``` --- ## Responsive Design Strategy ### Breakpoints (Tailwind Default) ``` Mobile: < 640px (sm) Tablet: 640px (md, lg) Desktop: 1024px+ (xl, 2xl) ``` ### Mobile-First Approach 1. **Start with mobile styles** (default, no prefix) 2. **Layer tablet styles** (md: prefix) 3. **Layer desktop styles** (lg:, xl: prefix) ### Example: Responsive Layout ```jsx // Mobile: 1 column, Tablet: 2 columns, Desktop: 3 columns
{items.map(item => ( ))}
``` ### Common Responsive Patterns **Responsive Typography** ```jsx

Responsive Heading

``` **Responsive Padding/Margins** ```jsx
Content with responsive spacing
``` **Responsive Grid** ```jsx
{/* Grid items */}
``` **Responsive Flexbox** ```jsx
Main content
``` **Responsive Images** ```jsx Responsive image ``` --- ## Modern Design Patterns ### 1. Consistency & Visual Hierarchy - **Use consistent spacing**: Apply spacing scale uniformly - **Establish clear hierarchy**: Size, weight, color for emphasis - **Group related content**: Use whitespace to separate sections - **Align elements**: Use grids for crisp layouts ```jsx

Section Title

Description text

{/* Related items with consistent spacing */}
``` ### 2. Interactive Feedback - **Hover states**: Subtle color/shadow changes - **Active states**: Indicate current selection - **Focus states**: Keyboard navigation support - **Loading states**: Spinners or skeleton screens - **Transitions**: Smooth animations (200-300ms) ```jsx ``` ### 3. Depth & Layering - **Subtle shadows**: Create depth without heaviness - **Elevation levels**: Consistent shadow progression - **Overlays**: Semi-transparent backgrounds for modals - **Z-index strategy**: Clear layering hierarchy ```jsx
Card content
``` ### 4. Color Usage - **Primary action**: Most frequent call-to-action - **Secondary action**: Alternative actions - **Semantic colors**: Status indicators (success, warning, danger) - **Contrast**: Ensure WCAG AA compliance (4.5:1 ratio) - **Limited palette**: 3-5 colors maximum in most designs ### 5. Whitespace & Breathing Room - Don't crowd elements - Use consistent gap values (gap-4, gap-6, gap-8) - Separate sections with vertical rhythm - Generous padding in cards and containers ```jsx
{/* Sections with good breathing room */}
``` --- ## Tailwind CSS Best Practices ### 1. Use Utility Classes Effectively ```jsx // Good: Semantic, reusable, organized // Avoid: Too many utilities, hard to read ); }; ``` ### 3. Organize Utility Classes ```jsx // Organize by category: layout → sizing → colors → effects → responsive
``` ### 4. Use Tailwind Config for Consistency ```js // tailwind.config.js module.exports = { theme: { extend: { colors: { primary: '#2563eb', secondary: '#7c3aed', }, spacing: { gutter: '1rem', }, }, }, }; ``` --- ## Component Construction Template Use this template when building atomic components: ```jsx /** * {Component Name} * * Atoms/Molecules/Organisms level component * Purpose: [Brief description] * * Props: * - prop1: type - description * - prop2: type - description */ export const ComponentName = ({ prop1, prop2, className = '' }) => { return (
{/* Component content */}
); }; ``` --- ## Layout Patterns ### Container + Padding ```jsx
{/* Content constrained to max width with responsive padding */}
``` ### Two-Column Sidebar Layout ```jsx
{/* Main content: takes remaining space */}
``` ### Responsive Grid ```jsx
{/* Items automatically stack on mobile, 2 columns on tablet, 3 on desktop */}
``` ### Hero Section ```jsx

Hero Title

Hero subtitle or description

``` --- ## Accessibility & Best Practices 1. **Semantic HTML**: Use ` ``` --- ## Performance Considerations 1. **Limit custom CSS**: Rely on Tailwind utilities 2. **Tree-shake unused styles**: Configure Tailwind content paths 3. **Optimize images**: Use responsive images, WebP format 4. **Lazy load**: Defer non-critical components 5. **Minimize bundle**: Use PurgeCSS in production --- ## Quick Reference Checklist When building a component, ensure: - [ ] Follows atomic design hierarchy (Atom/Molecule/Organism) - [ ] Uses design system variables (colors, spacing, typography) - [ ] Responsive across mobile, tablet, desktop - [ ] Consistent hover/active/focus states - [ ] Proper whitespace and visual hierarchy - [ ] Semantic HTML structure - [ ] Accessible (contrast, focus, labels) - [ ] Mobile-first approach - [ ] No hardcoded values (use Tailwind config)