Knit UI
GitHub

Motion

Motion in the kit is tokenised like everything else: durations and easings have names, and components reference the names. One table — packages/core/src/config/motion.ts — is the source of truth for both animation drivers.

Duration tokenms
instant0
quick100
fast150
base200
slow300
deliberate450
ambient600
loop1000
Easing tokenCurve
standardease-in-out
decelerateease-out
accelerateease-in
gentleease
linearlinear
transition presetMotion (web and native)
fast150ms ease-in-out
medium200ms ease-in-out
slow300ms ease-in-out
bouncyspring (damping 10, mass 0.9, stiffness 100)
pulse600ms ease-in-out
spin700ms linear
stripe180ms linear
linear200ms linear
ease200ms ease
ease-in200ms ease-in
ease-out200ms ease-out
ease-in-out200ms ease-in-out

Read the primitives from @knitui/core:

import { DURATIONS, EASINGS, MOTION_PRESETS } from "@knitui/core";

The transition prop

transition names a preset from the table above. With Tamagui v3 a preset is the same motion on every driver: the web CSS driver and the native Reanimated driver are both built from MOTION_PRESETS, so transition="bouncy" is one spring on iOS, Android and the web.

<Box transition="fast" bg="color2 hover:color3" />

Use the object form to restrict or retime it:

<Box
  transition={{ preset: "fast", properties: "transform, opacity", enter: "medium", exit: "fast" }}
/>
<Box transition={{ preset: "ease-out", duration: 250 }} />   // keep the curve, retime it
<Box transition="100ms ease-out" />                          // a duration is plain CSS
<Box transition="none" />                                    // set, never animate

properties replaces v2's animateOnly: a property the transition does not name is set rather than animated. transition="none" animates nothing and completes exits immediately.

Enter and exit

Mount and unmount styles are clauses on the properties they change — there are no enterStyle / exitStyle objects:

<AnimatePresence>
  {open ? (
    <Box key="panel" transition="medium" opacity="1 enter:0 exit:0" y="0 enter:8px exit:8px" />
  ) : null}
</AnimatePresence>

Raw lengths inside a clause need units (8px); a bare 8 would be read as a token name.

To act when a transition finishes, use onTransition:

<Box
  transition="medium"
  onTransition={({ phase, cause, finished }) => {
    if (phase === "end" && cause === "exit") cleanUp();
  }}
/>

phase is "start" or "end"; cause is "enter", "exit" or "update".

Presets

A motion preset pairs a transition with enter / exit values, so "fade in" means the same thing everywhere:

import { motionPresets, useMotionPreset } from "@knitui/components";

const motion = useMotionPreset("fade");

useMotionPreset resolves a named recipe to plain props (a transition plus the matching enter: / exit: clauses) that you pass to an animated frame, with reduced motion already applied. Overlay components (Popover, Tooltip, HoverCard, Modal, Drawer) accept a preset by name through their animation prop, and they animate out before unmounting — which is why they share one transition engine rather than each running their own timer.

The interactive playground — tweak any prop from the Controls panel.

Loading example…

PlaygroundSourceStorybook

Press feedback

import { usePressScale } from "@knitui/components";

usePressScale is the shared press-down animation: a small scale on the UI thread via Reanimated on native, a CSS transform on the web. Every control in the kit uses it, so press feedback is consistent and never runs on the JS thread.

Two implementations, one contract

PlatformMechanism
NativeReanimated worklets on the UI thread
WebCSS transitions and requestAnimationFrame painters

That split is why animation code inside the kit is platform-split (.native.tsx / .web.tsx) rather than branching at runtime — a worklet cannot be conditionally compiled.

Reduced motion

useReducedMotion() reads the OS setting on both platforms, and the kit's own transitions already respect it: durations collapse to instant rather than being skipped, so nothing ends up mid-transition.

import { useReducedMotion } from "@knitui/hooks";

Height transitions

Animating height is the hard case, because the natural height has to be measured first. Collapse and Spoiler share one implementation (CollapseBox) that measures with the content pinned absolute, then animates a clip — on native by hand with Reanimated, on the web through a real CSS transition.

If you write your own and it never opens, the measurement came back as zero because the content was already clipped. See Troubleshooting.

Edit this page on GitHub