# Web Application Design
## Overview
This skill provides **The Web Application Usability Framework**, a systematic 4-dimension methodology for designing complex web applications, SaaS tools, dashboards, and admin panels. Use this when designing data-heavy interfaces, workflow-driven tools, or multi-platform responsive web applications.
**Core Principle**: Web applications serve power users who need speed, clarity, and flexibility. Success means presenting complex data clearly, enabling efficient workflows through keyboard shortcuts and bulk actions, adapting gracefully across devices, and ensuring core functionality works even in degraded conditions.
**Focus**: Complex data displays, keyboard-driven workflows, responsive design (mobile to desktop), and progressive enhancement for reliability.
## When to Use This Skill
**Use this skill when:**
- Designing web applications, SaaS tools, or admin panels
- Working with complex data displays (tables, charts, dashboards)
- Building tools for power users or enterprise environments
- Implementing responsive web designs across mobile, tablet, and desktop
- User mentions: "web app", "dashboard", "SaaS", "admin panel", "data table", "keyboard shortcuts", "bulk actions"
**Don't use this skill for:**
- Marketing websites or landing pages (simpler content-focused design, not workflow-driven)
- Mobile-native apps (use `lyra/ux-designer/mobile-design-patterns`)
- Desktop-native software (use `lyra/ux-designer/desktop-software-design`)
- Simple forms or single-purpose pages (use `lyra/ux-designer/interaction-design-patterns`)
## The Web Application Usability Framework
A systematic 4-dimension evaluation model for web application design:
1. **DATA CLARITY** - Tables, charts, dashboards, real-time updates, export
2. **WORKFLOW EFFICIENCY** - Keyboard shortcuts, bulk actions, inline editing, command palette
3. **RESPONSIVE ADAPTATION** - Mobile <768px, tablet 768-1024px, desktop >1024px
4. **PROGRESSIVE ENHANCEMENT** - Core content works without JS/CSS, graceful degradation
Evaluate designs by examining each dimension systematically, ensuring data is understandable, workflows are fast, interfaces adapt across devices, and functionality degrades gracefully.
## Dimension 1: DATA CLARITY
**Purpose:** Present complex data in an understandable, scannable, actionable way
Users come to web applications to work with data—view it, understand it, act on it. Poor data presentation creates cognitive overload and slows decision-making. Clear data visualization, sortable tables, and meaningful empty states are essential.
### Evaluation Questions
1. **Can users understand data at a glance?**
- Visual hierarchy guides the eye to important metrics
- Charts match data type (trends → line, comparison → bar)
- Numbers formatted appropriately (1,234 vs 1234, $1.2M vs $1,234,567)
2. **Are tables sortable and filterable?**
- Column headers clickable for sorting (ascending/descending)
- Filter controls above table or in column headers
- Search functionality for large datasets
- Pagination or infinite scroll for performance
3. **Do visualizations match data relationships?**
- Line charts: Trends over time
- Bar charts: Comparisons between categories
- Pie charts: Part-to-whole (use sparingly, max 5 slices)
- Scatter plots: Correlations between variables
4. **Are empty states helpful and actionable?**
- Explain why empty ("No results found", "You haven't created any projects yet")
- Provide next action (CTA: "Create your first project")
- Show illustration or helpful tips
5. **Is real-time data clearly indicated?**
- Visual indicator (pulsing dot, "Live" badge)
- Timestamp ("Updated 2 seconds ago")
- Smooth updates (no jarring content shifts)
### Tables with Sorting and Filtering
**Pattern: Sortable Table Headers**
```html
```
**Pagination:**
- Bottom of table: "Showing 1-25 of 487 results"
- Page controls: « Previous | 1 2 3 ... 20 | Next »
- Items per page: Dropdown (25, 50, 100)
- Performance: Only load visible rows (virtual scrolling for 1000+ rows)
**Row Selection for Bulk Actions:**
```html
Name
Status
Project Alpha
Active
```
**Selection Feedback:**
- Selected row: Background color change (light blue, 10% opacity)
- Bulk action bar appears: "3 items selected | Delete | Archive | Export"
- "Select all" checkbox states: Unchecked, Checked, Indeterminate (some selected)
### Data Visualization Best Practices
**Line Charts (Trends Over Time):**
- **Use for:** Time-series data, progress tracking, historical trends
- **Best practices:**
- X-axis: Time (dates, hours)
- Y-axis: Value (starts at 0 unless all values in narrow range)
- Max 5 lines per chart (more = unreadable)
- Legend with colors, or direct labels on lines
- Tooltips on hover: "Aug 15, 2024: 1,234 users"
**Bar Charts (Comparisons Between Categories):**
- **Use for:** Comparing quantities across categories
- **Best practices:**
- Horizontal bars: Better for long category names
- Vertical bars: Better for time-based categories (months)
- Sort by value (descending) unless chronological
- Space between bars: 20-40% of bar width
- Value labels on bars or at end
**Pie Charts (Part-to-Whole Relationships):**
- **Use sparingly:** Only when showing parts of 100%
- **Max 5 slices:** More slices = hard to compare
- **Alternative:** Donut chart (center shows total)
- **Better alternative:** Horizontal bar chart (easier to compare)
- **Labels:** Percentage + category name
**Dashboard Hierarchy (F-Pattern Layout):**
```
┌─────────────────────────────────────────────────┐
│ [Most Important Metric] [Primary Action] │ ← Top row: Critical
├──────────────────┬──────────────────┬───────────┤
│ Metric Card │ Metric Card │ Chart │ ← Second row: Important
├──────────────────┴──────────────────┴───────────┤
│ │
│ Detailed Table or Secondary Chart │ ← Below fold: Details
│ │
└─────────────────────────────────────────────────┘
```
**F-Pattern Scanning:**
- **Top-left:** Most important metric (users scan here first)
- **Top-right:** Primary action (CTA, create, export)
- **Left edge:** Vertical scan (labels, categories)
- **Horizontal scans:** Decreasing attention as user scrolls down
**Metric Cards:**
- Value (large, bold): "1,234"
- Label (smaller, gray): "Active Users"
- Change indicator: "↑ 12% vs last week" (green for positive, red for negative)
- Sparkline (optional): Tiny trend chart (last 7 days)
### Progressive Disclosure for Complex Data
**Pattern: Summary Cards → Detail Views**
```html
Project Alpha
Status: Active | 12 tasks remaining
Project Alpha
Created: Aug 1, 2024
Owner: Jane Smith
Budget: $50,000
```
**When to Use:**
- Large datasets: Show 5-10 items, "Load more" or pagination
- Complex records: Show summary, expand for full details
- Nested data: Accordion or tree view
**Interaction:**
- Click to expand: Smooth height animation (300ms ease-out)
- Keyboard: Tab to button, Enter/Space to toggle
- Icon: ▶ (collapsed) → ▼ (expanded)
### Real-Time Updates
**WebSocket for Live Data:**
- **Use for:** Stock prices, live dashboards, chat, collaborative editing
- **Pattern:** Establish WebSocket connection on page load, update DOM on message
- **Visual indicator:** "Live" badge (pulsing green dot), "Connected" status
**Polling for Updates:**
- **Use for:** Less time-critical updates (notifications, status checks)
- **Interval:** 60 seconds typical (balance freshness vs server load)
- **Pattern:** setInterval(fetchUpdates, 60000)
**Visual Indicators:**
- **Pulsing dot:** Live connection (CSS animation, 2s pulse)
- **Timestamp:** "Updated 2 seconds ago" (relative time, updates every second)
- **Flash on update:** Brief highlight (yellow background, fades after 2s)
**Smooth Content Updates:**
- Don't shift layout abruptly (causes disorientation)
- Animate new items in (slide down or fade in, 200ms)
- If sorting changes, animate reordering (swap positions smoothly)
### Export Functionality
**Export Options:**
**CSV for Data Analysis:**
- All rows or filtered/selected rows
- All columns or visible columns only
- Filename: "projects_export_2024-08-15.csv"
**PDF for Reports:**
- Formatted for printing (headers, footers, page numbers)
- Charts rendered as images
- Logo and branding
**Copy to Clipboard:**
- Selected cells or entire table
- Tab-separated values (paste into Excel/Sheets)
- Confirmation toast: "Copied 10 rows to clipboard"
**Pattern: Export Dropdown**
```html
```
## Dimension 2: WORKFLOW EFFICIENCY
**Purpose:** Enable power users to work at maximum speed with minimal friction
Web application users are often power users who perform repetitive tasks daily. Keyboard shortcuts, bulk actions, inline editing, and command palettes dramatically improve efficiency for these users.
### Evaluation Questions
1. **Can power users complete tasks without touching the mouse?**
- Keyboard shortcuts for common actions
- Tab navigation through all interactive elements
- Focus indicators visible and high-contrast
2. **Are bulk actions available for repetitive tasks?**
- Select multiple items (checkboxes)
- "Select all" option
- Bulk actions: Delete, Archive, Export, Tag, Assign
3. **Does inline editing reduce modal dialogs?**
- Click to edit cells in tables
- Auto-save on blur
- No modal for simple edits
4. **Is there an autosave mechanism?**
- Draft saved every 30 seconds
- Visual indicator: "Saving...", "All changes saved"
- No "lost work" anxiety
5. **Are contextual actions easily accessible?**
- Right-click context menus
- Hover actions on table rows
- Quick actions on cards
### Keyboard Shortcuts
**Essential Shortcuts (Cross-Platform):**
```
Cmd/Ctrl+S: Save
Cmd/Ctrl+F: Search/Find (open search modal or focus search input)
Cmd/Ctrl+Z: Undo
Cmd/Ctrl+Shift+Z: Redo
Cmd/Ctrl+K: Command palette (universal action search)
Cmd/Ctrl+/: Show keyboard shortcuts panel
```
**Navigation Shortcuts:**
```
Tab: Next field/element
Shift+Tab: Previous field/element
Arrow keys: Navigate lists, tables, calendar cells
Enter: Submit form, activate button, open selected item
Esc: Close modal, cancel edit, clear search
```
**Table Navigation:**
```
Arrow Up/Down: Previous/next row
Arrow Left/Right: Previous/next column (if cell-focused)
Space: Select/deselect row (checkbox)
Enter: Open detail view for selected row
```
**Application-Specific Shortcuts:**
```
G then I: Go to Inbox (Gmail-style navigation)
C: Compose new (email, message, post)
/: Focus search (common in many apps)
?: Show keyboard shortcuts help
```
**Discoverability Strategies:**
1. **Tooltips with Shortcuts:**
- Button tooltip: "Save (Cmd+S)"
- Show shortcut in gray, smaller text
2. **Onboarding Hints:**
- First-time user: "Pro tip: Press Cmd+K to quickly find anything"
- Dismissable, don't show again after 3 views
3. **Keyboard Shortcuts Panel:**
- Triggered by Cmd+/ or ? key
- Modal with categorized shortcuts (Navigation, Editing, Actions)
- Searchable
**Implementation:**
```javascript
// Global keyboard listener
document.addEventListener('keydown', (e) => {
// Cmd+S or Ctrl+S: Save
if ((e.metaKey || e.ctrlKey) && e.key === 's') {
e.preventDefault();
saveDocument();
}
// Cmd+K or Ctrl+K: Command palette
if ((e.metaKey || e.ctrlKey) && e.key === 'k') {
e.preventDefault();
openCommandPalette();
}
});
```
### Bulk Actions
**Pattern: Select Multiple Items, Act on All**
```html
Name
Status
Item 1
Active
Item 2
Inactive
3 items selected
```
**Bulk Action Behavior:**
1. **Select items:** Click checkboxes or Shift+Click for range selection
2. **Bulk action bar appears:** Slides in from top or bottom
3. **Click action:** Confirmation modal for destructive actions (delete)
4. **Process:** Show progress if >10 items ("Deleting 47 items... 23/47")
5. **Feedback:** Toast notification "3 items deleted" or "Export complete"
6. **Undo option:** "3 items deleted. Undo?" (5-second window)
**"Select All" Checkbox States:**
- **Unchecked:** No items selected
- **Checked:** All visible items selected
- **Indeterminate:** Some items selected (shows dash/minus icon)
**Selection Shortcuts:**
- Cmd+A: Select all (focus table first)
- Shift+Click: Select range (click first, Shift+Click last)
- Cmd+Click: Toggle individual selection (add/remove from selection)
### Inline Editing
**Pattern: Click to Edit, Auto-Save on Blur**
```html
Project Alpha
```
**Inline Edit Interaction:**
1. **Enter edit mode:**
- Click cell or edit icon
- Double-click cell
- Keyboard: Tab to cell, Enter to edit
2. **Edit value:**
- Input field focused, text selected
- Type new value
- Validation inline (if applicable)
3. **Save:**
- Click save button
- Press Enter
- Blur (click outside) triggers auto-save
- API request in background
4. **Cancel:**
- Click cancel button
- Press Esc
- Revert to original value
5. **Feedback:**
- Saving: Spinner or "Saving..." text
- Success: Brief green border flash, "Saved"
- Error: Red border, error message, revert to original
**Auto-Save Indicators:**
- Icon: ⏳ (saving), ✓ (saved), ⚠ (error)
- Text: "Saving...", "All changes saved", "Failed to save"
- Position: Top-right corner or inline with edited field
**When NOT to Use Inline Editing:**
- Complex fields (multi-line text, rich text editor → use modal or dedicated page)
- Multiple related fields (edit form in modal or expand row)
- Destructive actions (delete → confirmation modal)
### Command Palette
**Pattern: Cmd+K Opens Search for All Actions**
```html
📄Create New ProjectCmd+N
🔍Search ProjectsCmd+F
⚙️Settings
```
**Command Palette Features:**
- **Search:** Type to filter actions, pages, recent items
- **Keyboard navigation:** Arrow keys to select, Enter to execute
- **Shortcuts shown:** Display keyboard shortcut if available
- **Recents:** Show recently used actions at top
- **Categories:** Actions, Pages, Projects, Settings
- **Fuzzy search:** "crnw" matches "Create New Project"
**What to Include:**
- Navigation: All pages/sections
- Actions: Create, Export, Delete, Settings
- Recent items: Recently viewed projects, documents
- Search results: Data from tables, lists
**Examples:**
- Slack: Cmd+K (Quick switcher - channels, DMs, files)
- VS Code: Cmd+Shift+P (Command palette - all editor actions)
- Linear: Cmd+K (Create issue, search, navigate)
### Contextual Actions
**Pattern: Right-Click Context Menu**
```html
Project Alpha
Active
```
**Context Menu Behavior:**
- **Trigger:** Right-click on row, card, or item
- **Position:** Appears at mouse cursor position
- **Keyboard:** Shift+F10 or Menu key (if available)
- **Close:** Click outside, press Esc, select action
- **Actions:** Open, Edit, Duplicate, Archive, Delete (dangerous actions at bottom, red)
**Touch/Mobile Alternative:**
- Three-dot menu button (⋮) visible on mobile
- Tap to show action dropdown or bottom sheet
- Right-click not available on touch devices
**Hover Actions (Desktop):**
```html
Project Alpha
12 tasks remaining
```
**CSS for Hover Actions:**
```css
.hover-actions {
opacity: 0;
transition: opacity 150ms ease-out;
}
.card:hover .hover-actions {
opacity: 1;
}
.card:focus-within .hover-actions {
opacity: 1; /* Also show on keyboard focus */
}
```
### Undo/Redo
**Implementation Guidance:**
**Keyboard Shortcuts:**
- Cmd+Z / Ctrl+Z: Undo
- Cmd+Shift+Z / Ctrl+Shift+Z: Redo (or Cmd+Y / Ctrl+Y)
**State Management:**
- Maintain history stack of actions
- Max history: 20-50 actions (memory constraint)
- Persist across page refresh (localStorage)
**Visual Feedback:**
- Toast notification: "Undo: Deleted 3 items"
- Menu items: "Undo Delete" (shows last action)
- Disabled state: Gray out if no undo/redo available
**What Actions to Track:**
- Destructive: Delete, archive, remove
- Edits: Text changes, status updates
- Bulk actions: All bulk operations
- Don't track: Navigation, search, filter (non-destructive)
**Undo Toast Pattern:**
```html
3 items deleted
```
- Duration: 5 seconds (enough time to undo)
- Auto-dismiss: After 5s (or user clicks undo)
- Position: Bottom-center or top-right
### Autosave
**Pattern: Save Draft Every 30 Seconds**
```javascript
let autosaveTimer;
let isDirty = false; // Track if content changed
// Mark as dirty on user input
contentField.addEventListener('input', () => {
isDirty = true;
clearTimeout(autosaveTimer);
autosaveTimer = setTimeout(autosave, 30000); // 30 seconds
});
async function autosave() {
if (!isDirty) return;
updateStatus('Saving...');
try {
await saveDraft();
updateStatus('All changes saved');
isDirty = false;
} catch (error) {
updateStatus('Failed to save. Retry in 60s.');
autosaveTimer = setTimeout(autosave, 60000); // Retry
}
}
```
**Autosave Indicators:**
- **Saving:** "Saving..." (gray, spinner icon)
- **Saved:** "All changes saved" (green, checkmark, fades after 2s)
- **Error:** "Failed to save. Trying again..." (red, warning icon)
- **Position:** Top-right, below header, or inline with content
**Best Practices:**
- Save after 30 seconds of inactivity (not every keystroke)
- Save on blur (user navigates away)
- Debounce: Wait for user to stop typing
- Conflict resolution: Server timestamp wins, or show merge UI
**Manual Save:**
- Still provide "Save" button (Cmd+S)
- Immediate save, not delayed
- Feedback: "Saved successfully"
## Dimension 3: RESPONSIVE ADAPTATION
**Purpose:** Provide optimal experience across all screen sizes (mobile, tablet, desktop)
Web applications must work on phones, tablets, and desktops. Layout, navigation, and interaction patterns must adapt. Mobile users need simplified views and touch targets; desktop users need dense information and keyboard shortcuts.
### Evaluation Questions
1. **Does the layout adapt gracefully from mobile to desktop?**
- Mobile: Single column, simplified
- Tablet: Two columns, condensed
- Desktop: Multi-column, full features
2. **Are touch targets appropriately sized on mobile?**
- Mobile: 48x48px minimum
- Desktop: 32x32px acceptable (mouse precision)
3. **Do complex features have mobile alternatives?**
- Desktop: Hover actions, right-click menus
- Mobile: Tap menus, swipe actions, bottom sheets
4. **Is the mobile experience functional (not just hidden)?**
- Don't hide critical features behind mobile breakpoint
- Simplify, don't remove
- Provide alternative interactions
### Breakpoints
**Standard Breakpoints:**
```css
/* Mobile: <768px */
@media (max-width: 767px) {
/* Single column, stacked navigation, simplified tables */
}
/* Tablet: 768-1024px */
@media (min-width: 768px) and (max-width: 1024px) {
/* Two columns, condensed nav, partial tables */
}
/* Desktop: >1024px */
@media (min-width: 1025px) {
/* Multi-column, persistent nav, full features */
}
```
### Mobile (<768px)
**Layout:**
- **Single column:** Content stacks vertically
- **Full-width:** Cards, buttons, inputs span full width (minus padding)
- **Padding:** 16px left/right margins
**Navigation:**
- **Hamburger menu:** Three-line icon, opens drawer navigation
- **Bottom tabs:** 3-5 items for primary navigation (if app-like)
- **Sticky header:** Fixed top navigation (collapses on scroll optional)
**Tables:**
- **Option 1: Horizontal scroll** (preserve structure, scroll left/right)
- **Option 2: Hide columns** (show critical columns only, "View details" for rest)
- **Option 3: Card view** (stack data vertically, each row becomes card)
- **Option 4: Accordion rows** (tap to expand full details)
**Touch Targets:**
- **Minimum:** 48x48px (finger-sized)
- **Spacing:** 8px between targets
- **Buttons:** Full-width or large (minimum 48px height)
**Information Density:**
- **Reduced:** Show essential data, hide secondary info
- **Progressive disclosure:** "Show more" buttons
- **Simplified charts:** Single metric cards instead of complex multi-line charts
**Mobile-Specific Patterns:**
- Tap instead of hover (no hover state on mobile)
- Swipe gestures (swipe to delete, pull to refresh)
- Bottom sheets instead of modals (easier thumb reach)
### Tablet (768-1024px)
**Layout:**
- **Two-column:** Sidebar + content, or split view
- **Grid:** 2-3 columns for cards
- **Flexible:** Adapt to portrait (narrower) vs landscape (wider)
**Navigation:**
- **Condensed sidebar:** Icons + labels (collapsed width)
- **Icon nav:** Top nav with icons and text
- **Tabs:** Horizontal tabs for sections
**Tables:**
- **Partial columns:** Show more columns than mobile, hide non-critical
- **Horizontal scroll:** If all columns needed
- **Responsive breakpoints:** Adjust column visibility at 768px and 1024px
**Touch Targets:**
- **Still touch-friendly:** 48x48px (tablets are touch)
- **Hybrid:** Support touch and mouse (some tablets have trackpads)
**Information Density:**
- **Medium:** More than mobile, less than desktop
- **Two-column cards:** Side-by-side instead of stacked
### Desktop (>1024px)
**Layout:**
- **Multi-column:** 3+ columns, sidebars, panels
- **Persistent navigation:** Sidebar always visible, or top nav
- **Wider content:** Max-width 1400-1600px, centered
**Navigation:**
- **Full sidebar:** Expanded with icons + labels
- **Top nav with dropdowns:** Mega-menus for complex hierarchies
- **Breadcrumbs:** Show navigation path
**Tables:**
- **All columns visible:** Full table with all data
- **Sortable:** Column headers clickable
- **Hover states:** Row highlights on hover, actions appear
**Mouse/Keyboard Interactions:**
- **Hover:** Tooltips, action buttons, previews
- **Right-click:** Context menus
- **Keyboard shortcuts:** Full keyboard support
- **Focus indicators:** Visible for keyboard navigation
**Information Density:**
- **High:** Show all data, charts, metrics
- **Multi-pane:** Master-detail views (list + detail side-by-side)
- **Dense tables:** More rows per page (25-50)
**Desktop-Specific Patterns:**
- Hover to reveal actions
- Drag-and-drop reordering
- Resizable panels (drag divider to adjust width)
- Multi-select with Shift+Click, Cmd+Click
### Responsive Patterns
**Mobile-First CSS:**
```css
/* Base styles (mobile <768px) */
.container {
padding: 16px;
}
.card {
width: 100%;
margin-bottom: 16px;
}
.sidebar {
display: none; /* Hidden on mobile, hamburger menu instead */
}
/* Tablet (768px+) */
@media (min-width: 768px) {
.container {
display: grid;
grid-template-columns: 200px 1fr; /* Sidebar + content */
padding: 24px;
}
.sidebar {
display: block; /* Show sidebar */
}
.card {
width: calc(50% - 12px); /* Two columns */
}
}
/* Desktop (1025px+) */
@media (min-width: 1025px) {
.container {
grid-template-columns: 250px 1fr 300px; /* Sidebar + content + right panel */
max-width: 1600px;
margin: 0 auto;
}
.card {
width: calc(33.33% - 16px); /* Three columns */
}
}
```
### Responsive Navigation
**Mobile: Hamburger Menu → Drawer**
```html
App Name
```
**Tablet: Icon Nav with Labels**
```html
```
**Desktop: Full Sidebar**
```html
```
### Responsive Tables
**Option 1: Horizontal Scroll (Preserve Structure)**
```css
/* Mobile: Scroll horizontally to see all columns */
.table-container {
overflow-x: auto;
-webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}
table {
min-width: 600px; /* Force horizontal scroll */
}
```
**Option 2: Hide Columns (Show Critical Only)**
```css
/* Mobile: Hide non-critical columns */
@media (max-width: 767px) {
.column-created-date,
.column-last-updated {
display: none;
}
}
/* Desktop: Show all columns */
@media (min-width: 1025px) {
.column-created-date,
.column-last-updated {
display: table-cell;
}
}
```
**Option 3: Card View (Stack Data Vertically)**
```html
Project Alpha
Status: Active
Created: Aug 1, 2024
Project Alpha
Active
Aug 1, 2024
```
**Option 4: Accordion Rows (Tap to Expand)**
```html
Project AlphaActive
Created: Aug 1, 2024
Owner: Jane Smith
Budget: $50,000
```
### Responsive Charts
**Mobile: Simplified Charts**
- **Single metric:** Large number with sparkline
- **Simple bar chart:** 3-5 bars maximum
- **Avoid:** Multi-line charts (hard to read on small screen)
**Desktop: Full Detail Charts**
- **Multi-line charts:** Up to 5 lines
- **Complex visualizations:** Scatter plots, heat maps
- **Tooltips:** Hover for detailed data
**Responsive Chart Pattern:**
```css
/* Mobile: Smaller height, simplified */
.chart-container {
height: 200px;
}
/* Desktop: Larger, more detail */
@media (min-width: 1025px) {
.chart-container {
height: 400px;
}
}
```
### Touch vs Hover
**Mobile (Touch):**
- **No hover states:** All affordances must be visible
- **Tap actions:** Single tap to activate
- **Long press:** Context menu (500ms hold)
- **Swipe:** Swipe to delete, swipe to reveal actions
- **No right-click:** Use long-press or visible menu button
**Desktop (Mouse + Hover):**
- **Hover states:** Actions appear on hover, tooltips, previews
- **Click:** Left-click to activate
- **Right-click:** Context menu
- **Cursor changes:** Pointer for links, grab for draggable
- **Keyboard focus:** Visible focus indicators
**Responsive Hover Pattern:**
```css
/* Desktop: Show actions on hover */
@media (min-width: 1025px) {
.card-actions {
opacity: 0;
transition: opacity 150ms;
}
.card:hover .card-actions {
opacity: 1;
}
}
/* Mobile: Always show actions (no hover) */
@media (max-width: 767px) {
.card-actions {
opacity: 1; /* Always visible */
}
}
```
## Dimension 4: PROGRESSIVE ENHANCEMENT
**Purpose:** Ensure core functionality works in all conditions (slow networks, JavaScript disabled, older browsers)
Users access web apps under varying conditions: slow 3G networks, JavaScript blocked by corporate firewalls, older browsers. Progressive enhancement ensures core content and actions work even when conditions are degraded.
### Evaluation Questions
1. **Does content load if JavaScript fails?**
- Core HTML content visible
- Server-side rendering for critical content
- Graceful degradation for interactive features
2. **Are core actions available without JavaScript?**
- Forms submit to server (full page reload)
- Links work (not JavaScript-only routing)
- No "JavaScript required" errors
3. **Does the page render in a usable state without CSS?**
- Semantic HTML structure
- Logical source order (header → nav → content → footer)
- Text-based fallbacks for icons
4. **Is there graceful degradation for older browsers?**
- Feature detection (not browser detection)
- Polyfills for missing features
- Fallbacks for unsupported CSS
### Enhancement Layers
**Layer 1: Core HTML (Works Everywhere)**
Semantic HTML with forms, links, and headings. Content is accessible and functional with zero JavaScript or CSS.
```html
```
**Layer 2: CSS Enhancement (Visual Hierarchy)**
Add visual hierarchy, layout, spacing, and responsive design. Page looks professional and organized.
```css
/* CSS: Visual hierarchy */
.form-field {
margin-bottom: 16px;
}
label {
display: block;
font-weight: 600;
margin-bottom: 4px;
}
input, select {
width: 100%;
padding: 12px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 16px;
}
button {
background: #0066cc;
color: white;
padding: 12px 24px;
border: none;
border-radius: 4px;
font-size: 16px;
cursor: pointer;
}
button:hover {
background: #0052a3;
}
```
**Layer 3: JavaScript Optimization (Faster Feedback)**
Add client-side validation, AJAX requests (no page reload), smooth animations, and interactive features.
```javascript
// JavaScript: Client-side validation (faster feedback)
form.addEventListener('submit', async (e) => {
e.preventDefault(); // Prevent full page reload
// Validate
if (!nameInput.value) {
showError('Project name is required');
return;
}
// AJAX submit
const response = await fetch('/projects/create', {
method: 'POST',
body: new FormData(form)
});
if (response.ok) {
showSuccess('Project created!');
// Smooth redirect or update UI
} else {
showError('Failed to create project. Try again.');
}
});
```
**Progressive Enhancement Strategy:**
1. Build core HTML (works without JS/CSS)
2. Add CSS (visual hierarchy, responsive)
3. Add JavaScript (better UX, faster feedback)
4. Test with JS disabled, CSS disabled, slow network
### Forms Without JavaScript
**Pattern: Server-Side Validation, Full Page Submission**
```html
```
**Server-Side Flow:**
1. User submits form
2. Server validates input
3. If errors: Render form with error messages, pre-fill submitted values
4. If success: Redirect to success page or show confirmation
**Enhancement with JavaScript:**
- Client-side validation (instant feedback, no round-trip)
- AJAX submission (no page reload)
- Loading spinner (better perceived performance)
### Content-First Loading
**Priority: Above-Fold Content → Critical Resources → Non-Critical Assets**
```html
We're working to fix the issue. Please try again later.
```
### Layout Patterns
**F-Pattern Scanning:**
Users scan web pages in an F-shaped pattern: horizontal scan at top, second horizontal scan lower, then vertical scan on left.
**Design Implications:**
- **Top-left:** Logo, app name
- **Top-right:** Primary action, user menu
- **Left edge:** Navigation, filters
- **Top horizontal:** Important metrics, key actions
**Fixed Headers:**
```css
.header {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 1000;
background: white;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.main-content {
margin-top: 64px; /* Header height */
}
```
**Sticky CTAs (Call-to-Action):**
```css
.sticky-cta {
position: sticky;
bottom: 0;
background: white;
padding: 16px;
box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
z-index: 100;
}
```
**Modals:**
```html
Confirm Delete
Are you sure you want to delete this project?
```
**Modal Best Practices:**
- Backdrop click to close (or not, for critical modals)
- Esc key to close
- Focus trap (Tab cycles within modal)
- Focus first input on open
- Restore focus to trigger element on close
### Search Patterns
**Autocomplete:**
```html