Skill: maryambahri/impeccable-uxui (version 1.0.0)

--- name: UI/UX description: "The design language that makes AI better at frontend design. 7 domain-specific references (typography, color, spatial, motion, interaction, responsive, UX writing), 20 steering commands (/audit, /critique, /polish, /distill, /animate, etc.), and curated anti-patterns. Use when building or reviewing any UI — fights AI's bias toward generic templates." homepage: https://github.com/pbakaus/impeccable --- This skill guides creation of distinctive, production-grade frontend interfaces that avoid generic "AI slop" aesthetics. Implement real working code with exceptional attention to aesthetic details and creative choices. ## Context Gathering Protocol Design skills produce generic output without project context. You MUST have confirmed design context before doing any design work. **Required context** — every design skill needs at minimum: - **Target audience**: Who uses this product and in what context? - **Use cases**: What jobs are they trying to get done? - **Brand personality/tone**: How should the interface feel? Individual skills may require additional context — check the skill's preparation section for specifics. **CRITICAL**: You cannot infer this context by reading the codebase. Code tells you what was built, not who it's for or what it should feel like. Only the creator can provide this context. **Gathering order:** 1. **Check current instructions (instant)**: If your loaded instructions already contain a **Design Context** section, proceed immediately. 2. **Check .impeccable.md (fast)**: If not in instructions, read `.impeccable.md` from the project root. If it exists and contains the required context, proceed. 3. **Run teach-impeccable (REQUIRED)**: If neither source has context, you MUST run {{command_prefix}}teach-impeccable NOW before doing anything else. Do NOT skip this step. Do NOT attempt to infer context from the codebase instead. --- ## Design Direction Commit to a BOLD aesthetic direction: - **Purpose**: What problem does this interface solve? Who uses it? - **Tone**: Pick an extreme: brutally minimal, maximalist chaos, retro-futuristic, organic/natural, luxury/refined, playful/toy-like, editorial/magazine, brutalist/raw, art deco/geometric, soft/pastel, industrial/utilitarian, etc. There are so many flavors to choose from. Use these for inspiration but design one that is true to the aesthetic direction. - **Constraints**: Technical requirements (framework, performance, accessibility). - **Differentiation**: What makes this UNFORGETTABLE? What's the one thing someone will remember? **CRITICAL**: Choose a clear conceptual direction and execute it with precision. Bold maximalism and refined minimalism both work—the key is intentionality, not intensity. Then implement working code that is: - Production-grade and functional - Visually striking and memorable - Cohesive with a clear aesthetic point-of-view - Meticulously refined in every detail ## Frontend Aesthetics Guidelines ### Typography → *Consult [typography reference](reference/typography.md) for scales, pairing, and loading strategies.* Choose fonts that are beautiful, unique, and interesting. Pair a distinctive display font with a refined body font. **DO**: Use a modular type scale with fluid sizing (clamp) **DO**: Vary font weights and sizes to create clear visual hierarchy **DON'T**: Use overused fonts—Inter, Roboto, Arial, Open Sans, system defaults **DON'T**: Use monospace typography as lazy shorthand for "technical/developer" vibes **DON'T**: Put large icons with rounded corners above every heading—they rarely add value and make sites look templated ### Color & Theme → *Consult [color reference](reference/color-and-contrast.md) for OKLCH, palettes, and dark mode.* Commit to a cohesive palette. Dominant colors with sharp accents outperform timid, evenly-distributed palettes. **DO**: Use modern CSS color functions (oklch, color-mix, light-dark) for perceptually uniform, maintainable palettes **DO**: Tint your neutrals toward your brand hue—even a subtle hint creates subconscious cohesion **DON'T**: Use gray text on colored backgrounds—it looks washed out; use a shade of the background color instead **DON'T**: Use pure black (#000) or pure white (#fff)—always tint; pure black/white never appears in nature **DON'T**: Use the AI color palette: cyan-on-dark, purple-to-blue gradients, neon accents on dark backgrounds **DON'T**: Use gradient text for "impact"—especially on metrics or headings; it's decorative rather than meaningful **DON'T**: Default to dark mode with glowing accents—it looks "cool" without requiring actual design decisions ### Layout & Space → *Consult [spatial reference](reference/spatial-design.md) for grids, rhythm, and container queries.* Create visual rhythm through varied spacing—not the same padding everywhere. Embrace asymmetry and unexpected compositions. Break the grid intentionally for emphasis. **DO**: Create visual rhythm through varied spacing—tight groupings, generous separations **DO**: Use fluid spacing with clamp() that breathes on larger screens **DO**: Use asymmetry and unexpected compositions; break the grid intentionally for emphasis **DON'T**: Wrap everything in cards—not everything needs a container **DON'T**: Nest cards inside cards—visual noise, flatten the hierarchy **DON'T**: Use identical card grids—same-sized cards with icon + heading + text, repeated endlessly **DON'T**: Use the hero metric layout template—big number, small label, supporting stats, gradient accent **DON'T**: Center everything—left-aligned text with asymmetric layouts feels more designed **DON'T**: Use the same spacing everywhere—without rhythm, layouts feel monotonous ### Visual Details **DO**: Use intentional, purposeful decorative elements that reinforce brand **DON'T**: Use glassmorphism everywhere—blur effects, glass cards, glow borders used decoratively rather than purposefully **DON'T**: Use rounded elements with thick colored border on one side—a lazy accent that almost never looks intentional **DON'T**: Use sparklines as decoration—tiny charts that look sophisticated but convey nothing meaningful **DON'T**: Use rounded rectangles with generic drop shadows—safe, forgettable, could be any AI output **DON'T**: Use modals unless there's truly no better alternative—modals are lazy ### Motion → *Consult [motion reference](reference/motion-design.md) for timing, easing, and reduced motion.* Focus on high-impact moments: one well-orchestrated page load with staggered reveals creates more delight than scattered micro-interactions. **DO**: Use motion to convey state changes—entrances, exits, feedback **DO**: Use exponential easing (ease-out-quart/quint/expo) for natural deceleration **DO**: For height animations, use grid-template-rows transitions instead of animating height directly **DON'T**: Animate layout properties (width, height, padding, margin)—use transform and opacity only **DON'T**: Use bounce or elastic easing—they feel dated and tacky; real objects decelerate smoothly ### Interaction → *Consult [interaction reference](reference/interaction-design.md) for forms, focus, and loading patterns.* Make interactions feel fast. Use optimistic UI—update immediately, sync later. **DO**: Use progressive disclosure—start simple, reveal sophistication through interaction (basic options first, advanced behind expandable sections; hover states that reveal secondary actions) **DO**: Design empty states that teach the interface, not just say "nothing here" **DO**: Make every interactive surface feel intentional and responsive **DON'T**: Repeat the same information—redundant headers, intros that restate the heading **DON'T**: Make every button primary—use ghost buttons, text links, secondary styles; hierarchy matters ### Responsive → *Consult [responsive reference](reference/responsive-design.md) for mobile-first, fluid design, and container queries.* **DO**: Use container queries (@container) for component-level responsiveness **DO**: Adapt the interface for different contexts—don't just shrink it **DON'T**: Hide critical functionality on mobile—adapt the interface, don't amputate it ### UX Writing → *Consult [ux-writing reference](reference/ux-writing.md) for labels, errors, and empty states.* **DO**: Make every word earn its place **DON'T**: Repeat information users can already see --- ## The AI Slop Test **Critical quality check**: If you showed this interface to someone and said "AI made this," would they believe you immediately? If yes, that's the problem. A distinctive interface should make someone ask "how was this made?" not "which AI made this?" Review the DON'T guidelines above—they are the fingerprints of AI-generated work from 2024-2025. --- ## Implementation Principles Match implementation complexity to the aesthetic vision. Maximalist designs need elaborate code with extensive animations and effects. Minimalist or refined designs need restraint, precision, and careful attention to spacing, typography, and subtle details. Interpret creatively and make unexpected choices that feel genuinely designed for the context. No design should be the same. Vary between light and dark themes, different fonts, different aesthetics. NEVER converge on common choices across generations. Remember: {{model}} is capable of extraordinary creative work. Don't hold back—show what can truly be created when thinking outside the box and committing fully to a distinctive vision. --- # Reference: typography # Typography ## Classic Typography Principles ### Vertical Rhythm Your line-height should be the base unit for ALL vertical spacing. If body text has `line-height: 1.5` on `16px` type (= 24px), spacing values should be multiples of 24px. This creates subconscious harmony—text and space share a mathematical foundation. ### Modular Scale & Hierarchy The common mistake: too many font sizes that are too close together (14px, 15px, 16px, 18px...). This creates muddy hierarchy. **Use fewer sizes with more contrast.** A 5-size system covers most needs: | Role | Typical Ratio | Use Case | |------|---------------|----------| | xs | 0.75rem | Captions, legal | | sm | 0.875rem | Secondary UI, metadata | | base | 1rem | Body text | | lg | 1.25-1.5rem | Subheadings, lead text | | xl+ | 2-4rem | Headlines, hero text | Popular ratios: 1.25 (major third), 1.333 (perfect fourth), 1.5 (perfect fifth). Pick one and commit. ### Readability & Measure Use `ch` units for character-based measure (`max-width: 65ch`). Line-height scales inversely with line length—narrow columns need tighter leading, wide columns need more. **Non-obvious**: Increase line-height for light text on dark backgrounds. The perceived weight is lighter, so text needs more breathing room. Add 0.05-0.1 to your normal line-height. ## Font Selection & Pairing ### Choosing Distinctive Fonts **Avoid the invisible defaults**: Inter, Roboto, Open Sans, Lato, Montserrat. These are everywhere, making your design feel generic. They're fine for documentation or tools where personality isn't the goal—but if you want distinctive design, look elsewhere. **Better Google Fonts alternatives**: - Instead of Inter → **Instrument Sans**, **Plus Jakarta Sans**, **Outfit** - Instead of Roboto → **Onest**, **Figtree**, **Urbanist** - Instead of Open Sans → **Source Sans 3**, **Nunito Sans**, **DM Sans** - For editorial/premium feel → **Fraunces**, **Newsreader**, **Lora** **System fonts are underrated**: `-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui` looks native, loads instantly, and is highly readable. Consider this for apps where performance > personality. ### Pairing Principles **The non-obvious truth**: You often don't need a second font. One well-chosen font family in multiple weights creates cleaner hierarchy than two competing typefaces. Only add a second font when you need genuine contrast (e.g., display headlines + body serif). When pairing, contrast on multiple axes: - Serif + Sans (structure contrast) - Geometric + Humanist (personality contrast) - Condensed display + Wide body (proportion contrast) **Never pair fonts that are similar but not identical** (e.g., two geometric sans-serifs). They create visual tension without clear hierarchy. ### Web Font Loading The layout shift problem: fonts load late, text reflows, and users see content jump. Here's the fix: ```css /* 1. Use font-display: swap for visibility */ @font-face { font-family: 'CustomFont'; src: url('font.woff2') format('woff2'); font-display: swap; } /* 2. Match fallback metrics to minimize shift */ @font-face { font-family: 'CustomFont-Fallback'; src: local('Arial'); size-adjust: 105%; /* Scale to match x-height */ ascent-override: 90%; /* Match ascender height */ descent-override: 20%; /* Match descender depth */ line-gap-override: 10%; /* Match line spacing */ } body { font-family: 'CustomFont', 'CustomFont-Fallback', sans-serif; } ``` Tools like [Fontaine](https://github.com/unjs/fontaine) calculate these overrides automatically. ## Modern Web Typography ### Fluid Type Fluid typography via `clamp(min, preferred, max)` scales text smoothly with the viewport. The middle value (e.g., `5vw + 1rem`) controls scaling rate—higher vw = faster scaling. Add a rem offset so it doesn't collapse to 0 on small screens. **Use fluid type for**: Headings and display text on marketing/content pages where text dominates the layout and needs to breathe across viewport sizes. **Use fixed `rem` scales for**: App UIs, dashboards, and data-dense interfaces. No major app design system (Material, Polaris, Primer, Carbon) uses fluid type in product UI — fixed scales with optional breakpoint adjustments give the spatial predictability that container-based layouts need. Body text should also be fixed even on marketing pages, since the size difference across viewports is too small to warrant it. ### OpenType Features Most developers don't know these exist. Use them for polish: ```css /* Tabular numbers for data alignment */ .data-table { font-variant-numeric: tabular-nums; } /* Proper fractions */ .recipe-amount { font-variant-numeric: diagonal-fractions; } /* Small caps for abbreviations */ abbr { font-variant-caps: all-small-caps; } /* Disable ligatures in code */ code { font-variant-ligatures: none; } /* Enable kerning (usually on by default, but be explicit) */ body { font-kerning: normal; } ``` Check what features your font supports at [Wakamai Fondue](https://wakamaifondue.com/). ## Typography System Architecture Name tokens semantically (`--text-body`, `--text-heading`), not by value (`--font-size-16`). Include font stacks, size scale, weights, line-heights, and letter-spacing in your token system. ## Accessibility Considerations Beyond contrast ratios (which are well-documented), consider: - **Never disable zoom**: `user-scalable=no` breaks accessibility. If your layout breaks at 200% zoom, fix the layout. - **Use rem/em for font sizes**: This respects user browser settings. Never `px` for body text. - **Minimum 16px body text**: Smaller than this strains eyes and fails WCAG on mobile. - **Adequate touch targets**: Text links need padding or line-height that creates 44px+ tap targets. --- **Avoid**: More than 2-3 font families per project. Skipping fallback font definitions. Ignoring font loading performance (FOUT/FOIT). Using decorative fonts for body text. --- # Reference: color-and-contrast # Color & Contrast ## Color Spaces: Use OKLCH **Stop using HSL.** Use OKLCH (or LCH) instead. It's perceptually uniform, meaning equal steps in lightness *look* equal—unlike HSL where 50% lightness in yellow looks bright while 50% in blue looks dark. ```css /* OKLCH: lightness (0-100%), chroma (0-0.4+), hue (0-360) */ --color-primary: oklch(60% 0.15 250); /* Blue */ --color-primary-light: oklch(85% 0.08 250); /* Same hue, lighter */ --color-primary-dark: oklch(35% 0.12 250); /* Same hue, darker */ ``` **Key insight**: As you move toward white or black, reduce chroma (saturation). High chroma at extreme lightness looks garish. A light blue at 85% lightness needs ~0.08 chroma, not the 0.15 of your base color. ## Building Functional Palettes ### The Tinted Neutral Trap **Pure gray is dead.** Add a subtle hint of your brand hue to all neutrals: ```css /* Dead grays */ --gray-100: oklch(95% 0 0); /* No personality */ --gray-900: oklch(15% 0 0); /* Warm-tinted grays (add brand warmth) */ --gray-100: oklch(95% 0.01 60); /* Hint of warmth */ --gray-900: oklch(15% 0.01 60); /* Cool-tinted grays (tech, professional) */ --gray-100: oklch(95% 0.01 250); /* Hint of blue */ --gray-900: oklch(15% 0.01 250); ``` The chroma is tiny (0.01) but perceptible. It creates subconscious cohesion between your brand color and your UI. ### Palette Structure A complete system needs: | Role | Purpose | Example | |------|---------|---------| | **Primary** | Brand, CTAs, key actions | 1 color, 3-5 shades | | **Neutral** | Text, backgrounds, borders | 9-11 shade scale | | **Semantic** | Success, error, warning, info | 4 colors, 2-3 shades each | | **Surface** | Cards, modals, overlays | 2-3 elevation levels | **Skip secondary/tertiary unless you need them.** Most apps work fine with one accent color. Adding more creates decision fatigue and visual noise. ### The 60-30-10 Rule (Applied Correctly) This rule is about **visual weight**, not pixel count: - **60%**: Neutral backgrounds, white space, base surfaces - **30%**: Secondary colors—text, borders, inactive states - **10%**: Accent—CTAs, highlights, focus states The common mistake: using the accent color everywhere because it's "the brand color." Accent colors work *because* they're rare. Overuse kills their power. ## Contrast & Accessibility ### WCAG Requirements | Content Type | AA Minimum | AAA Target | |--------------|------------|------------| | Body text | 4.5:1 | 7:1 | | Large text (18px+ or 14px bold) | 3:1 | 4.5:1 | | UI components, icons | 3:1 | 4.5:1 | | Non-essential decorations | None | None | **The gotcha**: Placeholder text still needs 4.5:1. That light gray placeholder you see everywhere? Usually fails WCAG. ### Dangerous Color Combinations These commonly fail contrast or cause readability issues: - Light gray text on white (the #1 accessibility fail) - **Gray text on any colored background**—gray looks washed out and dead on color. Use a darker shade of the background color, or transparency - Red text on green background (or vice versa)—8% of men can't distinguish these - Blue text on red background (vibrates visually) - Yellow text on white (almost always fails) - Thin light text on images (unpredictable contrast) ### Never Use Pure Gray or Pure Black Pure gray (`oklch(50% 0 0)`) and pure black (`#000`) don't exist in nature—real shadows and surfaces always have a color cast. Even a chroma of 0.005-0.01 is enough to feel natural without being obviously tinted. (See tinted neutrals example above.) ### Testing Don't trust your eyes. Use tools: - [WebAIM Contrast Checker](https://webaim.org/resources/contrastchecker/) - Browser DevTools → Rendering → Emulate vision deficiencies - [Polypane](https://polypane.app/) for real-time testing ## Theming: Light & Dark Mode ### Dark Mode Is Not Inverted Light Mode You can't just swap colors. Dark mode requires different design decisions: | Light Mode | Dark Mode | |------------|-----------| | Shadows for depth | Lighter surfaces for depth (no shadows) | | Dark text on light | Light text on dark (reduce font weight) | | Vibrant accents | Desaturate accents slightly | | White backgrounds | Never pure black—use dark gray (oklch 12-18%) | ```css /* Dark mode depth via surface color, not shadow */ :root[data-theme="dark"] { --surface-1: oklch(15% 0.01 250); --surface-2: oklch(20% 0.01 250); /* "Higher" = lighter */ --surface-3: oklch(25% 0.01 250); /* Reduce text weight slightly */ --body-weight: 350; /* Instead of 400 */ } ``` ### Token Hierarchy Use two layers: primitive tokens (`--blue-500`) and semantic tokens (`--color-primary: var(--blue-500)`). For dark mode, only redefine the semantic layer—primitives stay the same. ## Alpha Is A Design Smell Heavy use of transparency (rgba, hsla) usually means an incomplete palette. Alpha creates unpredictable contrast, performance overhead, and inconsistency. Define explicit overlay colors for each context instead. Exception: focus rings and interactive states where see-through is needed. --- **Avoid**: Relying on color alone to convey information. Creating palettes without clear roles for each color. Using pure black (#000) for large areas. Skipping color blindness testing (8% of men affected). --- # Reference: spatial-design # Spatial Design ## Spacing Systems ### Use 4pt Base, Not 8pt 8pt systems are too coarse—you'll frequently need 12px (between 8 and 16). Use 4pt for granularity: 4, 8, 12, 16, 24, 32, 48, 64, 96px. ### Name Tokens Semantically Name by relationship (`--space-sm`, `--space-lg`), not value (`--spacing-8`). Use `gap` instead of margins for sibling spacing—it eliminates margin collapse and cleanup hacks. ## Grid Systems ### The Self-Adjusting Grid Use `repeat(auto-fit, minmax(280px, 1fr))` for responsive grids without breakpoints. Columns are at least 280px, as many as fit per row, leftovers stretch. For complex layouts, use named grid areas (`grid-template-areas`) and redefine them at breakpoints. ## Visual Hierarchy ### The Squint Test Blur your eyes (or screenshot and blur). Can you still identify: - The most important element? - The second most important? - Clear groupings? If everything looks the same weight blurred, you have a hierarchy problem. ### Hierarchy Through Multiple Dimensions Don't rely on size alone. Combine: | Tool | Strong Hierarchy | Weak Hierarchy | |------|------------------|----------------| | **Size** | 3:1 ratio or more | <2:1 ratio | | **Weight** | Bold vs Regular | Medium vs Regular | | **Color** | High contrast | Similar tones | | **Position** | Top/left (primary) | Bottom/right | | **Space** | Surrounded by white space | Crowded | **The best hierarchy uses 2-3 dimensions at once**: A heading that's larger, bolder, AND has more space above it. ### Cards Are Not Required Cards are overused. Spacing and alignment create visual grouping naturally. Use cards only when content is truly distinct and actionable, items need visual comparison in a grid, or content needs clear interaction boundaries. **Never nest cards inside cards**—use spacing, typography, and subtle dividers for hierarchy within a card. ## Container Queries Viewport queries are for page layouts. **Container queries are for components**: ```css .card-container { container-type: inline-size; } .card { display: grid; gap: var(--space-md); } /* Card layout changes based on its container, not viewport */ @container (min-width: 400px) { .card { grid-template-columns: 120px 1fr; } } ``` **Why this matters**: A card in a narrow sidebar stays compact, while the same card in a main content area expands—automatically, without viewport hacks. ## Optical Adjustments Text at `margin-left: 0` looks indented due to letterform whitespace—use negative margin (`-0.05em`) to optically align. Geometrically centered icons often look off-center; play icons need to shift right, arrows shift toward their direction. ### Touch Targets vs Visual Size Buttons can look small but need large touch targets (44px minimum). Use padding or pseudo-elements: ```css .icon-button { width: 24px; /* Visual size */ height: 24px; position: relative; } .icon-button::before { content: ''; position: absolute; inset: -10px; /* Expand tap target to 44px */ } ``` ## Depth & Elevation Create semantic z-index scales (dropdown → sticky → modal-backdrop → modal → toast → tooltip) instead of arbitrary numbers. For shadows, create a consistent elevation scale (sm → md → lg → xl). **Key insight**: Shadows should be subtle—if you can clearly see it, it's probably too strong. --- **Avoid**: Arbitrary spacing values outside your scale. Making all spacing equal (variety creates hierarchy). Creating hierarchy through size alone - combine size, weight, color, and space. --- # Reference: motion-design # Motion Design ## Duration: The 100/300/500 Rule Timing matters more than easing. These durations feel right for most UI: | Duration | Use Case | Examples | |----------|----------|----------| | **100-150ms** | Instant feedback | Button press, toggle, color change | | **200-300ms** | State changes | Menu open, tooltip, hover states | | **300-500ms** | Layout changes | Accordion, modal, drawer | | **500-800ms** | Entrance animations | Page load, hero reveals | **Exit animations are faster than entrances**—use ~75% of enter duration. ## Easing: Pick the Right Curve **Don't use `ease`.** It's a compromise that's rarely optimal. Instead: | Curve | Use For | CSS | |-------|---------|-----| | **ease-out** | Elements entering | `cubic-bezier(0.16, 1, 0.3, 1)` | | **ease-in** | Elements leaving | `cubic-bezier(0.7, 0, 0.84, 0)` | | **ease-in-out** | State toggles (there → back) | `cubic-bezier(0.65, 0, 0.35, 1)` | **For micro-interactions, use exponential curves**—they feel natural because they mimic real physics (friction, deceleration): ```css /* Quart out - smooth, refined (recommended default) */ --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1); /* Quint out - slightly more dramatic */ --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1); /* Expo out - snappy, confident */ --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1); ``` **Avoid bounce and elastic curves.** They were trendy in 2015 but now feel tacky and amateurish. Real objects don't bounce when they stop—they decelerate smoothly. Overshoot effects draw attention to the animation itself rather than the content. ## The Only Two Properties You Should Animate **transform** and **opacity** only—everything else causes layout recalculation. For height animations (accordions), use `grid-template-rows: 0fr → 1fr` instead of animating `height` directly. ## Staggered Animations Use CSS custom properties for cleaner stagger: `animation-delay: calc(var(--i, 0) * 50ms)` with `style="--i: 0"` on each item. **Cap total stagger time**—10 items at 50ms = 500ms total. For many items, reduce per-item delay or cap staggered count. ## Reduced Motion This is not optional. Vestibular disorders affect ~35% of adults over 40. ```css /* Define animations normally */ .card { animation: slide-up 500ms ease-out; } /* Provide alternative for reduced motion */ @media (prefers-reduced-motion: reduce) { .card { animation: fade-in 200ms ease-out; /* Crossfade instead of motion */ } } /* Or disable entirely */ @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } } ``` **What to preserve**: Functional animations like progress bars, loading spinners (slowed down), and focus indicators should still work—just without spatial movement. ## Perceived Performance **Nobody cares how fast your site is—just how fast it feels.** Perception can be as effective as actual performance. **The 80ms threshold**: Our brains buffer sensory input for ~80ms to synchronize perception. Anything under 80ms feels instant and simultaneous. This is your target for micro-interactions. **Active vs passive time**: Passive waiting (staring at a spinner) feels longer than active engagement. Strategies to shift the balance: - **Preemptive start**: Begin transitions immediately while loading (iOS app zoom, skeleton UI). Users perceive work happening. - **Early completion**: Show content progressively—don't wait for everything. Video buffering, progressive images, streaming HTML. - **Optimistic UI**: Update the interface immediately, handle failures gracefully. Instagram likes work offline—the UI updates instantly, syncs later. Use for low-stakes actions; avoid for payments or destructive operations. **Easing affects perceived duration**: Ease-in (accelerating toward completion) makes tasks feel shorter because the peak-end effect weights final moments heavily. Ease-out feels satisfying for entrances, but ease-in toward a task's end compresses perceived time. **Caution**: Too-fast responses can decrease perceived value. Users may distrust instant results for complex operations (search, analysis). Sometimes a brief delay signals "real work" is happening. ## Performance Don't use `will-change` preemptively—only when animation is imminent (`:hover`, `.animating`). For scroll-triggered animations, use Intersection Observer instead of scroll events; unobserve after animating once. Create motion tokens for consistency (durations, easings, common transitions). --- **Avoid**: Animating everything (animation fatigue is real). Using >500ms for UI feedback. Ignoring `prefers-reduced-motion`. Using animation to hide slow loading. --- # Reference: interaction-design # Interaction Design ## The Eight Interactive States Every interactive element needs these states designed: | State | When | Visual Treatment | |-------|------|------------------| | **Default** | At rest | Base styling | | **Hover** | Pointer over (not touch) | Subtle lift, color shift | | **Focus** | Keyboard/programmatic focus | Visible ring (see below) | | **Active** | Being pressed | Pressed in, darker | | **Disabled** | Not interactive | Reduced opacity, no pointer | | **Loading** | Processing | Spinner, skeleton | | **Error** | Invalid state | Red border, icon, message | | **Success** | Completed | Green check, confirmation | **The common miss**: Designing hover without focus, or vice versa. They're different. Keyboard users never see hover states. ## Focus Rings: Do Them Right **Never `outline: none` without replacement.** It's an accessibility violation. Instead, use `:focus-visible` to show focus only for keyboard users: ```css /* Hide focus ring for mouse/touch */ button:focus { outline: none; } /* Show focus ring for keyboard */ button:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; } ``` **Focus ring design**: - High contrast (3:1 minimum against adjacent colors) - 2-3px thick - Offset from element (not inside it) - Consistent across all interactive elements ## Form Design: The Non-Obvious **Placeholders aren't labels**—they disappear on input. Always use visible `<label>` elements. **Validate on blur**, not on every keystroke (exception: password strength). Place errors **below** fields with `aria-describedby` connecting them. ## Loading States **Optimistic updates**: Show success immediately, rollback on failure. Use for low-stakes actions (likes, follows), not payments or destructive actions. **Skeleton screens > spinners**—they preview content shape and feel faster than generic spinners. ## Modals: The Inert Approach Focus trapping in modals used to require complex JavaScript. Now use the `inert` attribute: ```html <!-- When modal is open --> <main inert> <!-- Content behind modal can't be focused or clicked --> </main> <dialog open> <h2>Modal Title</h2> <!-- Focus stays inside modal --> </dialog> ``` Or use the native `<dialog>` element: ```javascript const dialog = document.querySelector('dialog'); dialog.showModal(); // Opens with focus trap, closes on Escape ``` ## The Popover API For tooltips, dropdowns, and non-modal overlays, use native popovers: ```html <button popovertarget="menu">Open menu</button> <div id="menu" popover> <button>Option 1</button> <button>Option 2</button> </div> ``` **Benefits**: Light-dismiss (click outside closes), proper stacking, no z-index wars, accessible by default. ## Dropdown & Overlay Positioning Dropdowns rendered with `position: absolute` inside a container that has `overflow: hidden` or `overflow: auto` will be clipped. This is the single most common dropdown bug in generated code. ### CSS Anchor Positioning The modern solution uses the CSS Anchor Positioning API to tether an overlay to its trigger without JavaScript: ```css .trigger { anchor-name: --menu-trigger; } .dropdown { position: fixed; position-anchor: --menu-trigger; position-area: block-end span-inline-end; margin-top: 4px; } /* Flip above if no room below */ @position-try --flip-above { position-area: block-start span-inline-end; margin-bottom: 4px; } ``` Because the dropdown uses `position: fixed`, it escapes any `overflow` clipping on ancestor elements. The `@position-try` block handles viewport edges automatically. **Browser support**: Chrome 125+, Edge 125+. Not yet in Firefox or Safari - use a fallback for those browsers. ### Popover + Anchor Combo Combining the Popover API with anchor positioning gives you stacking, light-dismiss, accessibility, and correct positioning in one pattern: ```html <button popovertarget="menu" class="trigger">Open</button> <div id="menu" popover class="dropdown"> <button>Option 1</button> <button>Option 2</button> </div> ``` The `popover` attribute places the element in the **top layer**, which sits above all other content regardless of z-index or overflow. No portal needed. ### Portal / Teleport Pattern In component frameworks, render the dropdown at the document root and position it with JavaScript: - **React**: `createPortal(dropdown, document.body)` - **Vue**: `<Teleport to="body">` - **Svelte**: Use a portal library or mount to `document.body` Calculate position from the trigger's `getBoundingClientRect()`, then apply `position: fixed` with `top` and `left` values. Recalculate on scroll and resize. ### Fixed Positioning Fallback For browsers without anchor positioning support, `position: fixed` with manual coordinates avoids overflow clipping: ```css .dropdown { position: fixed; /* top/left set via JS from trigger's getBoundingClientRect() */ } ``` Check viewport boundaries before rendering. If the dropdown would overflow the bottom edge, flip it above the trigger. If it would overflow the right edge, align it to the trigger's right side instead. ### Anti-Patterns - **`position: absolute` inside `overflow: hidden`** - The dropdown will be clipped. Use `position: fixed` or the top layer instead. - **Arbitrary z-index values** like `z-index: 9999` - Use a semantic z-index scale: `dropdown (100) -> sticky (200) -> modal-backdrop (300) -> modal (400) -> toast (500) -> tooltip (600)`. - **Rendering dropdown markup inline** without an escape hatch from the parent's stacking context. Either use `popover` (top layer), a portal, or `position: fixed`. ## Destructive Actions: Undo > Confirm **Undo is better than confirmation dialogs**—users click through confirmations mindlessly. Remove from UI immediately, show undo toast, actually delete after toast expires. Use confirmation only for truly irreversible actions (account deletion), high-cost actions, or batch operations. ## Keyboard Navigation Patterns ### Roving Tabindex For component groups (tabs, menu items, radio groups), one item is tabbable; arrow keys move within: ```html <div role="tablist"> <button role="tab" tabindex="0">Tab 1</button> <button role="tab" tabindex="-1">Tab 2</button> <button role="tab" tabindex="-1">Tab 3</button> </div> ``` Arrow keys move `tabindex="0"` between items. Tab moves to the next component entirely. ### Skip Links Provide skip links (`<a href="#main-content">Skip to main content</a>`) for keyboard users to jump past navigation. Hide off-screen, show on focus. ## Gesture Discoverability Swipe-to-delete and similar gestures are invisible. Hint at their existence: - **Partially reveal**: Show delete button peeking from edge - **Onboarding**: Coach marks on first use - **Alternative**: Always provide a visible fallback (menu with "Delete") Don't rely on gestures as the only way to perform actions. --- **Avoid**: Removing focus indicators without alternatives. Using placeholder text as labels. Touch targets <44x44px. Generic error messages. Custom controls without ARIA/keyboard support. --- # Reference: responsive-design # Responsive Design ## Mobile-First: Write It Right Start with base styles for mobile, use `min-width` queries to layer complexity. Desktop-first (`max-width`) means mobile loads unnecessary styles first. ## Breakpoints: Content-Driven Don't chase device sizes—let content tell you where to break. Start narrow, stretch until design breaks, add breakpoint there. Three breakpoints usually suffice (640, 768, 1024px). Use `clamp()` for fluid values without breakpoints. ## Detect Input Method, Not Just Screen Size **Screen size doesn't tell you input method.** A laptop with touchscreen, a tablet with keyboard—use pointer and hover queries: ```css /* Fine pointer (mouse, trackpad) */ @media (pointer: fine) { .button { padding: 8px 16px; } } /* Coarse pointer (touch, stylus) */ @media (pointer: coarse) { .button { padding: 12px 20px; } /* Larger touch target */ } /* Device supports hover */ @media (hover: hover) { .card:hover { transform: translateY(-2px); } } /* Device doesn't support hover (touch) */ @media (hover: none) { .card { /* No hover state - use active instead */ } } ``` **Critical**: Don't rely on hover for functionality. Touch users can't hover. ## Safe Areas: Handle the Notch Modern phones have notches, rounded corners, and home indicators. Use `env()`: ```css body { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); } /* With fallback */ .footer { padding-bottom: max(1rem, env(safe-area-inset-bottom)); } ``` **Enable viewport-fit** in your meta tag: ```html <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> ``` ## Responsive Images: Get It Right ### srcset with Width Descriptors ```html <img src="hero-800.jpg" srcset=" hero-400.jpg 400w, hero-800.jpg 800w, hero-1200.jpg 1200w " sizes="(max-width: 768px) 100vw, 50vw" alt="Hero image" > ``` **How it works**: - `srcset` lists available images with their actual widths (`w` descriptors) - `sizes` tells the browser how wide the image will display - Browser picks the best file based on viewport width AND device pixel ratio ### Picture Element for Art Direction When you need different crops/compositions (not just resolutions): ```html <picture> <source media="(min-width: 768px)" srcset="wide.jpg"> <source media="(max-width: 767px)" srcset="tall.jpg"> <img src="fallback.jpg" alt="..."> </picture> ``` ## Layout Adaptation Patterns **Navigation**: Three stages—hamburger + drawer on mobile, horizontal compact on tablet, full with labels on desktop. **Tables**: Transform to cards on mobile using `display: block` and `data-label` attributes. **Progressive disclosure**: Use `<details>/<summary>` for content that can collapse on mobile. ## Testing: Don't Trust DevTools Alone DevTools device emulation is useful for layout but misses: - Actual touch interactions - Real CPU/memory constraints - Network latency patterns - Font rendering differences - Browser chrome/keyboard appearances **Test on at least**: One real iPhone, one real Android, a tablet if relevant. Cheap Android phones reveal performance issues you'll never see on simulators. --- **Avoid**: Desktop-first design. Device detection instead of feature detection. Separate mobile/desktop codebases. Ignoring tablet and landscape. Assuming all mobile devices are powerful. --- # Reference: ux-writing # UX Writing ## The Button Label Problem **Never use "OK", "Submit", or "Yes/No".** These are lazy and ambiguous. Use specific verb + object patterns: | Bad | Good | Why | |-----|------|-----| | OK | Save changes | Says what will happen | | Submit | Create account | Outcome-focused | | Yes | Delete message | Confirms the action | | Cancel | Keep editing | Clarifies what "cancel" means | | Click here | Download PDF | Describes the destination | **For destructive actions**, name the destruction: - "Delete" not "Remove" (delete is permanent, remove implies recoverable) - "Delete 5 items" not "Delete selected" (show the count) ## Error Messages: The Formula Every error message should answer: (1) What happened? (2) Why? (3) How to fix it? Example: "Email address isn't valid. Please include an @ symbol." not "Invalid input". ### Error Message Templates | Situation | Template | |-----------|----------| | **Format error** | "[Field] needs to be [format]. Example: [example]" | | **Missing required** | "Please enter [what's missing]" | | **Permission denied** | "You don't have access to [thing]. [What to do instead]" | | **Network error** | "We couldn't reach [thing]. Check your connection and [action]." | | **Server error** | "Something went wrong on our end. We're looking into it. [Alternative action]" | ### Don't Blame the User Reframe errors: "Please enter a date in MM/DD/YYYY format" not "You entered an invalid date". ## Empty States Are Opportunities Empty states are onboarding moments: (1) Acknowledge briefly, (2) Explain the value of filling it, (3) Provide a clear action. "No projects yet. Create your first one to get started." not just "No items". ## Voice vs Tone **Voice** is your brand's personality—consistent everywhere. **Tone** adapts to the moment. | Moment | Tone Shift | |--------|------------| | Success | Celebratory, brief: "Done! Your changes are live." | | Error | Empathetic, helpful: "That didn't work. Here's what to try..." | | Loading | Reassuring: "Saving your work..." | | Destructive confirm | Serious, clear: "Delete this project? This can't be undone." | **Never use humor for errors.** Users are already frustrated. Be helpful, not cute. ## Writing for Accessibility **Link text** must have standalone meaning—"View pricing plans" not "Click here". **Alt text** describes information, not the image—"Revenue increased 40% in Q4" not "Chart". Use `alt=""` for decorative images. **Icon buttons** need `aria-label` for screen reader context. ## Writing for Translation ### Plan for Expansion German text is ~30% longer than English. Allocate space: | Language | Expansion | |----------|-----------| | German | +30% | | French | +20% | | Finnish | +30-40% | | Chinese | -30% (fewer chars, but same width) | ### Translation-Friendly Patterns Keep numbers separate ("New messages: 3" not "You have 3 new messages"). Use full sentences as single strings (word order varies by language). Avoid abbreviations ("5 minutes ago" not "5 mins ago"). Give translators context about where strings appear. ## Consistency: The Terminology Problem Pick one term and stick with it: | Inconsistent | Consistent | |--------------|------------| | Delete / Remove / Trash | Delete | | Settings / Preferences / Options | Settings | | Sign in / Log in / Enter | Sign in | | Create / Add / New | Create | Build a terminology glossary and enforce it. Variety creates confusion. ## Avoid Redundant Copy If the heading explains it, the intro is redundant. If the button is clear, don't explain it again. Say it once, say it well. ## Loading States Be specific: "Saving your draft..." not "Loading...". For long waits, set expectations ("This usually takes 30 seconds") or show progress. ## Confirmation Dialogs: Use Sparingly Most confirmation dialogs are design failures—consider undo instead. When you must confirm: name the action, explain consequences, use specific button labels ("Delete project" / "Keep project", not "Yes" / "No"). ## Form Instructions Show format with placeholders, not instructions. For non-obvious fields, explain why you're asking. --- **Avoid**: Jargon without explanation. Blaming users ("You made an error" → "This field is required"). Vague errors ("Something went wrong"). Varying terminology for variety. Humor for errors. --- ## Attribution Created by **Paul Bakaus** ([@pbakaus](https://twitter.com/nickerbocker)). Source: [github.com/pbakaus/impeccable](https://github.com/pbakaus/impeccable). Website: [impeccable.style](https://impeccable.style) Packaged for OpenClaw/ClawHub distribution with credit to the original author.


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: clean (LOW)