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/container-guard-initial-zero.md
1---2title: Guard Against Zero on Initial Render3impact: HIGH4tags: container, measure, initial-render5---67## Guard Against Zero on Initial Render89On initial render, measured bounds are 0. Guard against this to prevent animating from 0 to actual size.1011**Incorrect (animates from 0 on mount):**1213```tsx14<motion.div animate={{ width: bounds.width }}>15<div ref={ref}>{children}</div>16</motion.div>17```1819**Correct (falls back to auto on first frame):**2021```tsx22<motion.div animate={{ width: bounds.width > 0 ? bounds.width : "auto" }}>23<div ref={ref}>{children}</div>24</motion.div>25```26