Skip to content

Using scrollsheet with Motion

scrollsheet uses its own spring, Web Animations API wrapper, and scroll tween, exported from scrollsheet/motion. See the API reference. Use onTravel or --scrollsheet-progress to drive an animation library you already use.

import { useMotionValue, useTransform, motion } from 'motion/react';
const progress = useMotionValue(0);
const scale = useTransform(progress, [0, 1], [0.9, 1]);
<Sheet.Root onTravel={(_px, p) => progress.set(p)} detents={['full']}>
<Sheet.Content>
<motion.div style={{ scale }}>{/* rides the sheet's own travel */}</motion.div>
</Sheet.Content>
</Sheet.Root>

For any library that accepts a number, read progress from onTravel’s second argument. For CSS animations, use --scrollsheet-progress directly.

Drag the sheet and watch the header fade with onTravel's progress value.