React animation example
React Animated Tabs: Sliding Indicator and Content
Tabs should show where you went, not just where you are. The indicator here stretches toward the new tab before its trailing edge catches up, like a caterpillar, and the content slides in from the side you moved toward. Going right slides left, going back slides right.
- 4.4 KB file
- 5 live inputs
- React runtime
How this sliding tabs works
- The indicator's left and right edges are separate springs with different stiffness, which gives the stretch.
- Content direction comes from the sign of the index change.
- The active tab is an input and "change" fires with the tab label.
Add it to your React app
Install exodeui, download the file below, and paste this. The code updates as you customize. Other runtimes are in the other tabs.
import { ExodeUICanvas } from 'exodeui';
// react-animated-tabs.bexode goes in /public (download it below)
export function ReactAnimatedTabs() {
return (
<ExodeUICanvas
src="/react-animated-tabs.bexode"
fit="Layout"
autoPlay
interactive
onTrigger={(name) => {
// fires: 'change'
}}
style={{ width: '100%', height: 460 }}
/>
);
}Inputs
| Input | Type | Default | Range |
|---|---|---|---|
active | Number | 0 | 0 – 3 |
tabs | Text | Overview,Activity,Files,Settings | — |
accent | Text | #14b8a6 | hex colour |
ink | Text | #f0fdfa | hex colour |
bg | Text | #071211 | hex colour |
Events: change
More React animations
Orbit LoaderThree orbiting dots with motion trails and a live percentage; works as an endless spinner or a determinate loader.Depth Parallax SceneFive depth layers of mountains and sky that shift with the cursor at different speeds.Scramble TextA headline that decodes from random glyphs letter by letter; click to scramble to the next phrase.Shared Element TransitionA card grid where the tapped card springs into a full detail page and back: a shared element transition.Liquid Fill ButtonA button that fills with a liquid wave on hover and morphs into a checkmark on click.Like Heart IconA heart icon that squashes, pops and bursts into particles when liked, with a live counter.
The same idea in other frameworks: Vue slide and fade route transition