Animation in a preview runs on loom’s own frame loop, through the same RunService signals your
Roblox code uses. The renderer uses no CSS transitions, so what you see is what your code computes.
Pick the layer that fits:
| Layer | Use it for |
|---|---|
| Bindings | A value you drive yourself, per frame, without re-rendering. |
TweenService | The engine’s tween API, with the same easing enums. |
@rbxts/ripple | Springs, tweens and motion as React hooks. |
Bindings
createBinding, useBinding and joinBindings come from @rbxts/react. Any host prop accepts a
plain value or a binding:
import { useBinding } from "@rbxts/react";
function Follower() { const [position, setPosition] = useBinding(UDim2.fromOffset(0, 0));
return ( <frame Size={UDim2.fromOffset(80, 80)} Position={position} Event={{ InputChanged: (_, input) => setPosition(UDim2.fromOffset(input.Position.X, input.Position.Y)), }} /> );}The renderer writes a bound prop straight onto the live instance, skipping React. A 60fps animation is 60 property writes and zero renders.
Bindings from useBinding and from ripple’s useSpring are the same kind of object, so you can mix
them freely.
TweenService
Import it the way you already do:
import { useEffect, useRef } from "@rbxts/react";import { TweenService } from "@rbxts/services";
function SlideIn() { const ref = useRef<Frame>();
useEffect(() => { const frame = ref.current; if (!frame) return;
const info = new TweenInfo(0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out); const tween = TweenService.Create(frame, info, { Position: UDim2.fromScale(0.5, 0.5), });
tween.Play(); return () => tween.Cancel(); }, []);
return <frame ref={ref} Position={UDim2.fromScale(0.5, 1.2)} />;}TweenInfo takes the engine’s arguments in the engine’s order:
(Time, EasingStyle, EasingDirection, RepeatCount, Reverses, DelayTime).
| Surface | Supported |
|---|---|
TweenService | Create, GetValue. |
GuiObject | TweenPosition, TweenSize, TweenSizeAndPosition. |
Tween | Play, Pause, Cancel, Completed, PlaybackState. |
TweenInfo | DelayTime, RepeatCount, Reverses, and every EasingStyle / EasingDirection. |
| Interpolated types | number, Color3, UDim, UDim2, Vector2. |
Tweens advance on the scheduler’s frame signal. Pausing the scheduler pauses the tween.
@rbxts/ripple
@rbxts/ripple and @rbxts/react-ripple work with no configuration. Loom swaps in a browser port
of the published implementation. See
Package compatibility for
details.
import { config, useSpring } from "@rbxts/react-ripple";
function AnimatedButton() { const [offset, spring] = useSpring(0, config.stiff);
return ( <textbutton Size={offset.map((value) => UDim2.fromOffset(200 + value, 50 + value))} Event={{ MouseEnter: () => spring.setGoal(10), MouseLeave: () => spring.setGoal(0), }} /> );}The spring math, easing curves, Oklab color interpolation and rest thresholds follow the Luau source, so a component animates the way it does in Roblox.
Exports
createSpring, createTween, createMotion, config, easing, springScheduler,
tweenScheduler, motionScheduler, and the useSpring / useTween / useMotion hooks. The hooks
package also re-exports the core, as the real one does. Every published config preset and easing
curve is implemented.
Controller methods
These match the published .d.ts:
| Controller | Methods |
|---|---|
| All three | getPosition getGoal setPosition setGoal onChange onComplete step idle configure start stop destroy |
Spring / Motion | getVelocity setVelocity |
Spring | impulse halt |
Tween | getFrom setFrom |
Motion | spring tween |
Every documented option works:
| Controller | Options |
|---|---|
| Spring | start, tension, friction, mass, dampingRatio, frequency, precision, restVelocity, position, velocity, impulse |
| Tween | start, easing, duration, repeats, reverses, position |
| Motion | start, spring, tween |
Values
You can animate number, Vector2, Vector3, Color3, UDim, UDim2, Rect, and records of
numbers. A record accepts a partial goal, so keys you leave out stay put. Color3 interpolates
through Oklab, and UDim / UDim2 offsets round to integers, as in Roblox.
CFrame throws instead of animating, because loom’s CFrame holds position only:
[loom] Ripple compatibility does not yet support animating CFrameAny other unsupported value, such as a string or a record of non-numbers, also throws by name.
Subpaths like @rbxts/ripple/foo are not covered.
Differences from upstream
destroy()also drops the controller’sonChangeandonCompletecallbacks, so a destroyed controller can’t call into an unmounted component. Upstream only stops it.- As upstream, the hooks ignore a changed
initialOptionsafter mount. Callcontroller.configure(...)to retune a controller in place.
One frame loop
Every spring, tween and motion controller shares one RunService.Heartbeat connection, released
when the last one settles. Values go into a binding, so React never re-renders.
Browsers don’t fire requestAnimationFrame for a hidden tab, so loom stops stepping. The animation
resumes where it left off when the tab comes back.