Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Living wiki of UI design patterns and best practices built with Fumadocs, Next.js, and Base UI components.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
rules/visual-animate-shadow-pseudo.md
1---2title: Animate Shadows via Pseudo-Element Opacity3impact: MEDIUM4tags: visual, shadow, animation, performance5---67## Animate Shadows via Pseudo-Element Opacity89Transitioning box-shadow directly forces expensive repaints. Instead, put the target shadow on a pseudo-element and animate its opacity.1011**Incorrect (animating box-shadow):**1213```css14.card {15box-shadow: var(--shadow-1);16transition: box-shadow 0.2s ease;17}1819.card:hover {20box-shadow: var(--shadow-3);21}22```2324**Correct (pseudo-element opacity):**2526```css27.card {28position: relative;29box-shadow: var(--shadow-1);30}3132.card::after {33content: "";34position: absolute;35inset: 0;36border-radius: inherit;37box-shadow: var(--shadow-3);38opacity: 0;39transition: opacity 0.2s ease;40pointer-events: none;41z-index: -1;42}4344.card:hover::after {45opacity: 1;46}47```4849Reference: [Designing Beautiful Shadows in CSS](https://www.joshwcomeau.com/css/designing-shadows/)50