Skip to content
Crafts

A tab bar that becomes search

Craft 07 · React Native, motion

Two shapes, swapping widths.

The bar at the bottom of Fefys, and the one morph that turns it into search.

Fig. 1Tabs, then search, then back.

Fefys has four tabs and a search, and search lives in the tab bar, not in a field on every screen. So the bar is two glass shapes floating over the content: a capsule with the tabs, and a circle with a magnifying glass. Everything it does is those two shapes changing.

The pill under the active tab slides in 340 ms, and on its way it stretches: to 1.22 times its width over the first third of the trip, then back. It reads as a drop of something sliding, without the overshoot a spring would add. The first placement doesn't animate at all, so opening the app never shows a pill sliding in from nowhere. Changing tab gives a haptic tap when haptics are on; pressing the tab you're already on gives none, because nothing happened.

src/components/ui/TabBar.tsx · tsx
x.set(withTiming(target, { duration: SLIDE, easing: EASE_OUT }));
stretch.set(
  withSequence(
    withTiming(1.22, { duration: SLIDE * 0.35, easing: EASE_OUT }),
    withTiming(1, { duration: SLIDE * 0.65, easing: EASE_OUT }),
  ),
);

Each label takes its colour from how close the pill is to it, not from which tab is selected. Slide from Today to List and Explore and Plan light up as the pill passes under them and dim as it leaves, so the bar says where the pill is at every frame, not only where it's going.

src/components/ui/TabBar.tsx · tsx
const label = useAnimatedStyle(() => {
  const near = Math.max(0, 1 - Math.abs(x.get() - order * restStep) / TAB.width);
  return {
    color: interpolateColor(near, [0, 1], [colors.mute, colors.ink]),
    opacity: 1 - Math.min(1, morph.get() * 4),
  };
});

Tap search and the two shapes trade widths over 460 ms: the capsule shrinks into a circle and the circle grows into the field. Nothing new appears. As the capsule narrows, the tab slots squeeze their spacing to match and fade out right to left, List first and Today last, each one shrinking a little as it goes. Once they've gone, a house fades in as the Home button in the circle that's left, the magnifying glass glides to the field's left edge, and the field fades in for the second half.

The bar only rides the keyboard while it's searching. Its lift is the keyboard's height multiplied by the morph, so on any other screen a keyboard opens under a bar that stays put, and during the morph the two move together. The keyboard itself waits for a tap on the field instead of jumping up the moment search opens, and closing search with the Home circle puts it away.

src/components/ui/TabBar.tsx · tsx
const left = useAnimatedStyle(() => ({
  width: interpolate(morph.get(), [0, 1], [capsuleWide, ROUND]),
}));
const right = useAnimatedStyle(() => ({
  width: interpolate(morph.get(), [0, 1], [ROUND, capsuleWide]),
}));
const bar = useAnimatedStyle(() => ({
  transform: [
    {
      translateY:
        morph.get() * Math.min(0, keyboard.height.get() + insets.bottom + FOOTER_GAP - 8),
    },
  ],
}));
The same two widths, swapped. The lift is zero until morph moves.