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, string>?, string?, string?, string?)

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.

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, string>? variants = null, string? animate = null, string? initial = null, string? exit = null)

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.

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.

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, string>

Named animation states: each label maps to a utility class string for that state. 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 null, the nearest ancestor Motion's active label is inherited; when set, it overrides any inherited label.

initial string

Mount-time starting variant label. When this Motion also sets animate + variants, the enter starts at variants[initial] and transitions to variants[animate] (its persistent resting state) using this Motion's transition timing — whether this Motion is the DIRECT child of an AnimatePresence or mounts standalone (Framer parity: initial/animate apply to any motion.* component).

exit string

Exit variant label. When this Motion is the DIRECT child of an AnimatePresence and also sets animate + variants, removal animates from variants[animate] to variants[exit] (using this Motion's transition timing) before the element unmounts. Unlike initial, this needs AnimatePresence to defer the unmount — set outside one, it is inert and logs a warning.

Returns

MotionNode

The created MotionNode.

Remarks

Equivalent to Framer Motion's motion.<tag> component (with its variants, initial, animate, and exit props, and parent→child context propagation) for users migrating from Framer Motion.