Motion+

Tab select

An example of using making a tab select component with Motion for React's shared layout animations. Because it uses onTap and whileFocus, it's keyboard-accessible by default. Try tabbing between the options and hitting Enter.

Time
5 min
Difficulty
Intermediate
Access
Motion+
>Live exampleOpen in new tab

Introduction

The Tab Select example shows a common UI pattern: a set of tabs where the selected indicator smoothly animates from the old tab to the new one.

In this example, the selected indicator looks like one element but it's actually several elements, all animating between each other as if there were just one.

This shared element "magic move" effect can be complex to build manually, but Motion makes it simple. In this tutorial, we'll learn to use:

  • The layoutId prop to create a shared layout animation.
  • Gesture props like whileTap and whileFocus to add satisfying micro-interactions.