--- name: ui-ux description: General UI/UX principles — visual hierarchy, accessibility (WCAG), feedback, affordance, typography, spacing. Use when designing any interface (web, mobile, desktop, CLI). Platform-agnostic complement to /web-design. license: MIT --- # General UI/UX Principles These principles apply across all platforms: web, mobile, desktop, CLI, games. ## Core Principles ### 1. Accessibility Design for all users, including those with disabilities. - **Contrast**: Minimum 4.5:1 ratio for normal text, 3:1 for large text - **Focus states**: Visible indicators for keyboard navigation - **Alt text**: Descriptive text for meaningful images - **Keyboard navigation**: Logical tab order, keyboard-accessible actions - **Screen readers**: Semantic HTML, ARIA labels where needed - **Color not sole indicator**: Combine with icons, text, patterns ### 2. Visual Hierarchy Guide the user's attention to what matters most. - **Primary action**: Most prominent (size, color, position) - **Content importance**: Heading levels, size, weight - **Scanning patterns**: F-pattern (top-left scanning), Z-pattern (diagonal) - **Grouping**: Related items together, whitespace separates sections ### 3. Consistency Similar elements should look and act similarly. - **Internal consistency**: Same patterns within your product - **Platform conventions**: Follow OS conventions (back button placement, etc.) - **Different = different**: If it looks different, it should behave differently ### 4. Feedback Tell users what's happening. - **Loading**: Show progress for operations taking time - **Success**: Confirm when actions complete - **Errors**: Clear error messages near the problem - **State changes**: Visual feedback for hover, focus, active states ### 5. Affordance Show how to interact. - **Interactive elements**: Look clickable/tappable (cursor, color, shadows) - **Hover states**: Visual change on mouse over - **Click states**: Response to interaction (press, release) - **Disabled states**: Clear when something is not actionable ### 6. Error Handling Help users recover from mistakes. - **Clear messages**: What went wrong, in plain language - **Near the problem**: Error where the action occurred - **Recovery suggestions**: How to fix, what to do next - **Prevent errors**: Validate before submission, confirm destructive actions ### 7. Typography Make text readable and scannable. - **Size**: Minimum 16px body text, scalable - **Line length**: 65-75 characters optimal - **Line height**: 1.5-1.75 for body text - **Hierarchy**: Clear size differences between headings and body - **Contrast**: Text vs background meets accessibility ratios ### 8. Color Use color meaningfully and accessibly. - **Meaning**: Consistent (green = success, red = error) - **Contrast**: Meet accessibility ratios - **Not sole indicator**: Combine with icons, text, patterns - **Palette**: Limited colors, purposeful accents - **Dark mode**: Consider contrast in both modes ### 9. Spacing Give content room to breathe. - **Consistent rhythm**: Use consistent increments (4px, 8px, 16px) - **Grouping**: More space between sections than within - **Padding**: Adequate inside containers - **Touch spacing**: Minimum 44px between tappable elements ### 10. Touch Targets Make interactive elements easy to tap. - **Minimum size**: 44x44px (Apple), 48x48dp (Android) - **Spacing**: Adequate gap between targets - **Thumb zone**: Important actions within easy reach - **No accidental taps**: Adequate separation from other targets --- ## Quick Reference | Principle | Checkpoint Questions | | -------------- | ------------------------------------------------ | | Accessibility | Contrast adequate? Keyboard navigable? Alt text? | | Hierarchy | What draws attention first? Clear priority? | | Consistency | Same patterns? Platform conventions? | | Feedback | Loading shown? Errors clear? | | Affordance | Clickable elements obvious? | | Error handling | Messages helpful? Recovery possible? | | Typography | Readable? Scannable? | | Color | Meaningful? Accessible? | | Spacing | Consistent? Adequate? | | Touch targets | Large enough? Well-spaced? |