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-two-div-pattern.md
1---2title: Two-Div Pattern for Animated Bounds3impact: HIGH4tags: container, measure, motion5---67## Two-Div Pattern for Animated Bounds89Use an outer animated div and an inner measured div. Never measure and animate the same element.1011**Incorrect (measure and animate same element — creates feedback loop):**1213```tsx14function AnimatedContainer({ children }) {15const [ref, bounds] = useMeasure();16return (17<motion.div ref={ref} animate={{ height: bounds.height }}>18{children}19</motion.div>20);21}22```2324**Correct (separate measure and animate targets):**2526```tsx27function AnimatedContainer({ children }) {28const [ref, bounds] = useMeasure();29return (30<motion.div animate={{ height: bounds.height }}>31<div ref={ref}>{children}</div>32</motion.div>33);34}35```36