Capítulo 22 de 142

Chapter 22: LayoutGroup

Core Idea

Coordinate React layout animations between Motion components.

Key Concepts

  • Namespace layoutId: Components expecting to perform shared layout animations are provided a layoutId prop.
  • Find & fix animation performance issues with your agent.: MotionScore for Agents grades animations in your source code S to F and hands your agent s
  • Animate faster with Motion+.: Unlock 430+ premium examples

Code Examples

function Item({ header, content }) {
  const [isOpen, setIsOpen] = useState(false)
  
  return (
    <motion.div
      layout
      onClick={() => setIsOpen(!isOpen)}
    >
      <motion.h2 layout>{header}</motion.h2>
      {isOpen ? content : null}
    </motion.div>
  )
}
  • What it demonstrates: Core usage pattern for LayoutGroup.

Key Takeaways

  1. LayoutGroup supports Namespace layoutId.
  2. LayoutGroup supports Find & fix animation performance issues with your agent..
  3. LayoutGroup supports Animate faster with Motion+..

Connects To

  • React motion component: related Motion doc page.
  • Layout Animation: related Motion doc page.
  • Animate numbers: related Motion doc page.