# ROA2WEB CSS Patterns Library **Version:** 2.0.0 **Last Updated:** 2025-11-19 **Status:** ✅ Complete --- ## Table of Contents 1. [Card Patterns](#card-patterns) 2. [Form Patterns](#form-patterns) 3. [Button Patterns](#button-patterns) 4. [Table Patterns](#table-patterns) 5. [Dashboard Patterns](#dashboard-patterns) 6. [Interactive Patterns](#interactive-patterns) 7. [Layout Patterns](#layout-patterns) 8. [Utility Classes](#utility-classes) 9. [Mobile Material Design](#mobile-material-design) 10. [Quick Reference](#quick-reference) --- ## Overview This document provides a comprehensive reference to all CSS patterns available in the ROA2WEB frontend application. All patterns are production-ready, tested, and follow our design system. ### Key Principles - ✅ **Use global patterns first** - Check this library before writing custom CSS - ✅ **Design tokens** - Use CSS variables (`var(--color-primary)`) not hardcoded values - ✅ **Responsive by default** - All patterns work on mobile - ✅ **Accessibility** - WCAG 2.1 AA compliant - ❌ **No duplication** - Never recreate existing patterns --- ## Card Patterns ### Basic Card Standard card with optional header, body, and footer sections. ```html

Card Title

Card content goes here

``` **Variants:** - `.card-compact` - Reduced padding - `.card-minimal` - No border/shadow - `.card-elevated` - Higher shadow with hover lift - `.card-hover` - Hover effect with border color change **Use Cases:** - Content containers - Form wrappers - Information blocks --- ### Metric Card Dashboard metric display with icon, value, and label. ```html
Total Sales
$125,430
+12.5% vs last month
``` **Structure:** - `.metric-card` - Base container - `.metric-header` - Icon + label section - `.metric-icon` - 40x40px icon container - `.metric-value` - Large numeric display - `.metric-label` - Uppercase description **Modifiers:** - `.metric-value-lg` - Larger font size (2.5rem) **Use Cases:** - KPI displays - Financial metrics - Statistics cards --- ### Stats Card Centered statistics display for key metrics. ```html
1,234 Active Users +5.2%
``` **Variants:** - `.stats-card-mini` - Compact size, left-aligned - `.stats-card-large` - Extra padding - `.stats-value-large` - Larger number display **Use Cases:** - Dashboard summaries - Quick stats - Report headers --- ### KPI Card Horizontal card with icon and key performance indicator. ```html
$45,231
Monthly Revenue
``` **Use Cases:** - Performance indicators - Business metrics - Dashboard sidebar stats --- ### Action Card Interactive card that functions as a clickable button. ```html
Export Data
Download as Excel file
``` **Use Cases:** - Quick actions - Navigation tiles - Feature shortcuts --- ### Status Card Card with colored left border indicating status. ```html
Success! Your payment was processed.
Error: Payment failed, please try again.
``` **Variants:** - `.success` - Green border, success background - `.warning` - Yellow border, warning background - `.error` - Red border, error background - `.info` - Blue border, info background **Use Cases:** - Alerts - Notifications - Status messages --- ## Form Patterns ### Standard Form Complete form structure with validation. ```html
{{ errors.username }} Minimum 3 characters
``` **Key Classes:** - `.form` - Base form container - `.form-group` - Field wrapper - `.form-row` - Horizontal field container - `.form-col` - Column within row - `.form-label` - Label text - `.form-label.required` - Adds red asterisk - `.form-input` - Text input - `.form-select` - Select dropdown - `.form-textarea` - Multi-line text - `.form-error` - Error message (red) - `.form-help` - Help text (gray) - `.form-actions` - Button container **Validation States:** - `.valid` - Green border with checkmark icon - `.invalid` - Red border with X icon --- ### Input Sizes ```html ``` --- ### Input Group Input with prefix/suffix addons. ```html
https:// .com
``` --- ### Search Form Dedicated search input with icon. ```html
``` --- ### File Upload Drag-and-drop file upload area. ```html
``` --- ## Button Patterns ### Button Variants ```html ``` --- ### Button Sizes ```html ``` --- ### Icon Buttons ```html ``` **Sizes:** - `.btn-icon-sm` - 32x32px - `.btn-icon` - 40x40px - `.btn-icon-lg` - 48x48px --- ### Button Groups ```html
``` --- ### Loading State ```html ``` --- ## Table Patterns **Note:** Table styles are centralized in `tables.css`. Always use PrimeVue DataTable component with global styling. ### Basic Table ```html ``` **Global Row Classes (App.vue):** - `.bank-row` - Blue background for bank rows - `.cash-row` - Green background for cash rows - `.invoice-paid` - Light green for paid invoices - `.invoice-overdue` - Light red for overdue invoices ### ⚠️ Important: Unified Table Column Structure **All tables in the application MUST follow this structure for consistency:** ✅ **DO: One value per column** ```html ``` ❌ **DON'T: Multiple values stacked vertically in single column** ```html ``` **Rationale:** - Maintains visual consistency across all views - Improves scannability and data comparison - Better for sorting and filtering - Follows established patterns (see InvoicesView, MaturityAndDetailsCard) ### Table Filter and Action Buttons **Standard pattern: PrimeVue buttons with icon + label, separate row below filters** All filter-related buttons (clear filters, export, refresh) MUST be: - ✅ **PrimeVue Button** components (not HTML ` ``` --- ### Metrics Row Responsive grid for metric cards. ```html
...
...
``` **Responsive:** - Desktop: 2 columns - Tablet/Mobile: 1 column --- ### Breakdown Pattern Collapsible data breakdown. ```html
Details
$10,500
Item 1 $5,000
Item 2 $5,500
``` --- ## Interactive Patterns ### Loading Spinner Animated loading indicator. ```html
``` --- ### Trend Indicator Shows increase/decrease with icon. ```html
+12.5%
-3.2%
0.0%
``` --- ### Collapsible Section Expandable/collapsible content. ```html
Section Title
Content goes here
``` --- ### Sparkline Chart Mini line chart for trends. ```html
Last 7 Days $12,345
``` **Sizes:** - Default: 60px height - `.sparkline-chart-lg`: 150px height --- ## Layout Patterns ### Container Page-level content container. ```html
``` **Variants:** - `.container-sm` - Max-width 640px - `.container-md` - Max-width 768px - `.container-lg` - Max-width 1024px - `.container-xl` - Max-width 1280px - `.container-full` - Full width --- ### Grid System Responsive column layout. ```html
Column 1
Column 2
Column 3
``` **Grid Columns:** - `.grid-cols-1` to `.grid-cols-12` - Responsive: `.sm:grid-cols-2`, `.md:grid-cols-3`, `.lg:grid-cols-4` --- ## Utility Classes ### Spacing ```html
No margin
Small margin (0.5rem)
Medium margin (1rem)
Large margin (1.5rem)
Extra large margin (2rem)
No padding
Small padding
Medium padding
Large padding
Margin top
Margin bottom
Margin left
Margin right
Horizontal center
Vertical margin
``` --- ### Text Utilities ```html

Extra small (0.75rem)

Small (0.875rem)

Base (1rem)

Large (1.125rem)

Extra large (1.25rem)

2X large (1.5rem)

3X large (1.875rem)

4X large (2.25rem)

Left aligned

Center aligned

Right aligned

Normal (400)

Medium (500)

Semibold (600)

Bold (700)

UPPERCASE TEXT

lowercase text

Capitalized Text

``` --- ### Color Utilities ```html

Primary color

Success (green)

Warning (yellow)

Error (red)

Info (blue)

Muted (gray)

Secondary (light gray)

Primary background
Success background
Warning background
Error background
Light primary
Light success
Light warning
Light error
``` --- ### Flexbox Utilities ```html
Flex container
Inline flex
Row (default)
Column
Row reverse
Column reverse
Start
Center
End
Space between
Space around
Start
Center
End
Stretch
Small gap
Medium gap
Large gap
``` --- ### Display Utilities ```html
Block
Inline block
Inline
Visible mobile, hidden tablet+
``` --- ## Mobile Material Design > **Full Documentation:** [docs/MOBILE_PATTERNS.md](./MOBILE_PATTERNS.md) ROA2WEB includes a complete mobile component library following Material Design 3 principles. All mobile components are designed for touch interactions and support both light and dark themes. ### Available Components | Component | Location | Description | |-----------|----------|-------------| | `MobileTopBar` | `@shared/components/mobile/` | Fixed top bar with title, back/menu buttons, and actions | | `MobileBottomNav` | `@shared/components/mobile/` | Fixed bottom navigation with router integration | | `MobileSelectionFooter` | `@shared/components/mobile/` | Slide-up action bar for batch operations | | `BottomSheet` | `@shared/components/mobile/` | Modal sheet for filters and forms | | `SwipeableCards` | `@shared/components/mobile/` | Touch carousel for KPI cards | ### Mobile Breakpoints ```css /* Mobile-first breakpoints */ @media (max-width: 768px) { /* Mobile styles - this is where mobile components activate */ } @media (min-width: 769px) { /* Tablet and desktop styles */ } @media (min-width: 1024px) { /* Desktop-only styles */ } ``` ### Key Mobile Layout Tokens | Token | Value | Use | |-------|-------|-----| | `--header-height` | 56px | TopBar and BottomNav height | | Touch target | 48×48px | Minimum button/tap area | | `--z-fixed` | 1030 | Fixed navigation elements | | `--z-modal` | 1050 | BottomSheet and overlays | ### Quick Example ```vue ``` **For complete documentation including all props, events, and usage patterns, see [MOBILE_PATTERNS.md](./MOBILE_PATTERNS.md).** --- ## Quick Reference ### Most Common Patterns ```html
Content

Success message

Item 1 Item 2
``` --- ### Color Shortcuts | Purpose | Class | Color | |---------|-------|-------| | Primary action | `.text-primary` `.bg-primary` | Blue (#2563eb) | | Success/Positive | `.text-success` `.bg-success` | Green (#059669) | | Warning/Caution | `.text-warning` `.bg-warning` | Yellow (#d97706) | | Error/Danger | `.text-error` `.bg-error` | Red (#dc2626) | | Info/Neutral | `.text-info` `.bg-info` | Cyan (#0891b2) | --- ### Spacing Scale | Token | Size | Use Case | |-------|------|----------| | `var(--space-xs)` | 0.25rem (4px) | Tight spacing | | `var(--space-sm)` | 0.5rem (8px) | Default gaps | | `var(--space-md)` | 1rem (16px) | Component padding | | `var(--space-lg)` | 1.5rem (24px) | Section padding | | `var(--space-xl)` | 2rem (32px) | Page margins | | `var(--space-2xl)` | 3rem (48px) | Large separations | | `var(--space-3xl)` | 4rem (64px) | Hero sections | --- ### Font Sizes | Class | Size | Use Case | |-------|------|----------| | `.text-xs` | 0.75rem (12px) | Tiny labels | | `.text-sm` | 0.875rem (14px) | Small text | | `.text-base` | 1rem (16px) | Body text | | `.text-lg` | 1.125rem (18px) | Emphasized text | | `.text-xl` | 1.25rem (20px) | Small headings | | `.text-2xl` | 1.5rem (24px) | Headings | | `.text-3xl` | 1.875rem (30px) | Large headings | | `.text-4xl` | 2.25rem (36px) | Page titles | --- ## Browser Support All patterns support: - ✅ Chrome 90+ - ✅ Firefox 88+ - ✅ Safari 14+ - ✅ Edge 90+ --- ## Performance Notes - CSS bundle size: **366.42 kB** (51.31 kB gzipped) - All patterns use design tokens for consistency - Animations use `transform` and `opacity` for GPU acceleration - No unused patterns in production build --- ## Need Help? - **Pattern not listed?** Check `src/assets/css/` directories - **Custom requirement?** Consult [Component Styling Guidelines](./COMPONENT_STYLING.md) - **New pattern needed?** Follow [Styling Guidelines](./STYLING_GUIDELINES.md) - **Questions?** Ask in #frontend-css channel --- **Last Updated:** 2026-01-12 **Version:** 2.1.0 (Added Mobile Material Design section) **Maintained By:** Frontend Team