Table of Contents

Method Motion

Namespace
Velvet
Assembly
Velvet.Docs.dll

Motion(string?, string?, string?, StyleTransitionConfig?, float?, EasingMode?, float?, Action?, VNode?[]?, FiberElementProps?, FiberEventBinding[]?, Func<VisualElement, Action>?, string?, string?, string?, Type?, IReadOnlyDictionary<string, MotionVariant>?, string?, string?, string?, string?, bool)

Element targeted by an animation. Used inside AnimatePresence; toggles CSS classes on mount / unmount according to transition. The one exception is a variant initial/animate pair (see initial), which plays its mount enter on any Motion, standalone or not. When transition is null, StyleTransition.Fade is applied as the default. duration / easing can override individual fields of the transition preset (e.g. setting only the duration while keeping the preset's other fields). To disable animation entirely (immediate mount / unmount), pass transition: StyleTransitionConfig.None. Note: when DurationSec is 0 (including StyleTransitionConfig.None), delay is ignored and completion is immediate, except for a Spring with no RepeatDelaySec, which is instant but waits out delay before it lands (see motion.md).

public static MotionNode Motion(string? className = null, string? key = null, string? name = null, StyleTransitionConfig? transition = null, float? duration = null, EasingMode? easing = null, float? delay = null, Action? onEnterComplete = null, VNode?[]? children = null, FiberElementProps? props = null, FiberEventBinding[]? events = null, Func<VisualElement, Action>? refCallback = null, string? whileHoverClass = null, string? whileTapClass = null, string? whileFocusClass = null, Type? elementType = null, IReadOnlyDictionary<string, MotionVariant>? variants = null, string? animate = null, string? initial = null, string? exit = null, string? layoutId = null, bool enterOnMount = true)

Parameters

className string

CSS-like utility class string. Multiple classes separated by spaces.

key string

Key used to disambiguate siblings at the same position.

name string

Element name assigned to UnityEngine.UIElements.VisualElement.name for query/debug.

transition StyleTransitionConfig

Transition preset; defaults to StyleTransition.Fade when null. A variants entry naming its own replaces it for swaps into that pose.

duration float?

Override the transition duration (seconds).

easing EasingMode?

Override the transition easing mode.

delay float?

Override the transition delay (seconds). Ignored when DurationSec is 0, unless the transition is a Spring with no RepeatDelaySec, which waits it out.

onEnterComplete Action

Callback invoked when the enter transition finishes.

children VNode[]

Child VNodes rendered inside the motion element.

props FiberElementProps

Optional FiberElementProps (text / tooltip / enabled / etc.) bag.

events FiberEventBinding[]

Array of pre-built FiberEventBinding objects applied to the element.

refCallback Func<VisualElement, Action>

Callback invoked on mount with the created VisualElement; returned Action runs on unmount.

whileHoverClass string

USS class toggled while the pointer hovers the element.

whileTapClass string

USS class toggled while the pointer is pressed on the element.

whileFocusClass string

USS class toggled while the element holds keyboard/UI focus.

elementType Type

The VisualElement type the animated cell IS, e.g. typeof(Button) so a clickable cell is one element instead of a Motion wrapping a Button. Defaults to UnityEngine.UIElements.VisualElement. Supply interactions via events.

variants IReadOnlyDictionary<string, MotionVariant>

Named animation states: each label maps to a MotionVariant — a utility class string for that state, plus an optional transition for swaps INTO it (a bare string converts implicitly, taking transition). The label selected by animate has its classes merged on top of className. Because switching animate changes the element's class list, a USS transition-* utility in the classes tweens between states. Parent→child propagation: a descendant Motion that supplies variants but leaves animate null inherits the nearest ANCESTOR Motion's active label and resolves it against its OWN variants — so setting animate on a parent drives the whole subtree.

animate string

The active variant label (a key of variants). When this Motion names none of animate, initial and exit, the nearest ancestor Motion's labels are inherited; naming any of them, it inherits none.

initial string

Mount-time starting variant label. The enter starts at variants[initial] and transitions to variants[animate] (its persistent resting state); with no animate, the Motion rests at variants[initial]. The motion guide's Enter on mount section owns who plays the enter and when a presence withholds it. Transition resolves the timing.

exit string

Exit variant label. When the keyed AnimatePresence child this Motion sits in, however deep, is removed, the Motion animates from its resting pose to variants[exit] before the child unmounts, and hands the label down to the Motions inheriting its labels. Transition resolves the timing, whether or not variants[exit] applies a class. Unlike initial, this needs AnimatePresence to defer the unmount — set outside one, it is inert, which a warning reports where the mounted tree holds no AnimatePresence at all.

layoutId string
enterOnMount bool

False mounts this Motion and the Motions below it at their resting pose with no enter (Framer Motion's initial={false}). Left true, a Motion naming no initial label enters from the look it has without its variant classes.

Returns

MotionNode

The created MotionNode.