CSS Driver
Lightweight CSS transition-based animations
The @tamagui/animations-css package provides lightweight, typed animations
through CSS transitions on web.
Installation
yarn
npm
bun
pnpm
Configuration
Add it to your Tamagui config:
The config format is the same for all four drivers, so a name means the same motion whichever driver renders it. See Animations for the shipped table.
The root entry contains CSS component transitions only. If your app uses
useAnimatedNumber, useAnimatedNumberStyle, useAnimatedNumbersStyle, or
useAnimatedNumberReaction, import the same factory from the extras entry:
Sheet uses animated numbers for its position and Toast uses them for swipe
gestures, so apps using either component with the CSS driver need the extras
entry. The root entry keeps apps that only use CSS transitions from shipping
the JavaScript spring and linked-style runtime.
How it works
At runtime, the plugin does very little except to set the transition property
in CSS. At compile-time, the compiler does the same, ensuring you get all the
benefits of prop removal and view flattening even when using animations.
Animation configuration
A config entry is a spring, written as { duration, bounce }:
Springs work under this driver: they compile to a linear() easing that traces
the real spring curve, overshoot included, with no JavaScript running.
An entry can also be a plain CSS timing string, in <easing-function> <duration> order or the CSS order:
Delay
The delay (in milliseconds) is applied as CSS transition-delay. A CSS
transition string spells it the CSS way, transition="200ms ease-out 100ms".
Supported easing functions
ease: default easing (equivalent tocubic-bezier(0.25, 0.1, 0.25, 1))linear: no easing, constant speedease-in: slow startease-out: slow endease-in-out: slow start and endcubic-bezier(x1, y1, x2, y2): custom cubic bezier curve
When to use
Advantages:
- Smallest bundle size: minimal JavaScript overhead
- Broad compatibility: works everywhere CSS works
- Compiler optimizations: benefits from static extraction
Limitations:
- Springs are sampled into a
linear()easing up front, so they can’t react to an interruption mid-flight the way a running JS spring can - Limited to CSS animatable properties
- Less control over animation lifecycle