Loomguides

Animation

Three ways to move a preview — bindings, TweenService and springs — at zero React renders.

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:

LayerUse it for
BindingsA value you drive yourself, per frame, without re-rendering.
TweenServiceThe engine’s tween API, with the same easing enums.
@rbxts/rippleSprings, 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).

SurfaceSupported
TweenServiceCreate, GetValue.
GuiObjectTweenPosition, TweenSize, TweenSizeAndPosition.
TweenPlay, Pause, Cancel, Completed, PlaybackState.
TweenInfoDelayTime, RepeatCount, Reverses, and every EasingStyle / EasingDirection.
Interpolated typesnumber, 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:

ControllerMethods
All threegetPosition getGoal setPosition setGoal onChange onComplete step idle configure start stop destroy
Spring / MotiongetVelocity setVelocity
Springimpulse halt
TweengetFrom setFrom
Motionspring tween

Every documented option works:

ControllerOptions
Springstart, tension, friction, mass, dampingRatio, frequency, precision, restVelocity, position, velocity, impulse
Tweenstart, easing, duration, repeats, reverses, position
Motionstart, 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 CFrame

Any 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’s onChange and onComplete callbacks, so a destroyed controller can’t call into an unmounted component. Upstream only stops it.
  • As upstream, the hooks ignore a changed initialOptions after mount. Call controller.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.