Table of Contents

Class V

Namespace
Velvet
Assembly
Velvet.Docs.dll

VNode builder DSL. Declarative UI construction API for composing element trees in C#.

public static class V
Inheritance
object
V

Methods

AnimatePresence(VNode?[]?, string?, bool, float, float, int, AnimatePresenceMode, Action?)

Container that supports mount / unmount animations. When a keyed child becomes null, removal is deferred until the exit animation completes.

Button(string?, string?, Action?, string?, string?, string?, bool?, StyleOverrides?, Func<VisualElement, Action>?, Func<VisualElement, VisualElement>?, string?, string?, string?, VNode?[]?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)

Creates a Button. text and children can be combined. UI Toolkit's Button inherits from TextElement and keeps the text property and child VisualElements independently, so use children when declaring multiple children (e.g. icon + label) and text for text-only buttons.

Button(string, params VNode?[])

Shorthand overload: positional className + variadic children, building a Button with just a class string and children (e.g. an icon + label). For any other prop — notably onClick — use the long-form overload with named arguments.

Component(Func<VNode>?, string?)

Embeds a function-style component ([Component] static VNode Foo()) into the VNode tree as a child node. Props are read from Stores / Context via hooks, so passing state/props through method arguments is not the supported pattern.

Component<TRef>(Func<VNode>?, Ref<TRef>, string?)

Embeds a function-style component with parent-to-child ref forwarding. The child retrieves the ref via Hooks.ForwardedRef<THandle>() and exposes it through Hooks.UseImperativeHandle.

Component<TProps>(Func<TProps, VNode>, TProps, string?)

Embeds a function-style component that receives a single TProps argument carrying the per-instance values (e.g. an item id plus a click handler). Use this overload for V.List iteration / per-item callbacks where Context-based prop distribution would require allocating a Provider node per item.

Custom<T>(string?, string?, string?, FiberElementProps?, Func<VisualElement, Action>?, VNode?[]?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)

Creates an element backed by a custom UnityEngine.UIElements.VisualElement subclass T, for control types the built-in factories (Div(string?, string?, string?, FiberElementProps?, StyleOverrides?, Func<VisualElement, Action>?, VNode?[]?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?), Label(string?, string?, string?, string?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?), …) do not expose. Long form: every prop is a named optional parameter. For the shorthand V.Custom<T>("class", child1, child2) form, see the params overload.

Custom<T>(string, params VNode?[])

Shorthand overload: positional className + variadic children, building a T element with just a class string and children. For any prop besides className, use the long-form overload with named arguments.

Div(string?, string?, string?, FiberElementProps?, StyleOverrides?, Func<VisualElement, Action>?, VNode?[]?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)

Creates a VisualElement (generic container). Equivalent to HTML's div. Long form: every prop is a named optional parameter. For the shorthand V.Div("class", child1, child2) form, see the params overload.

Div(string, params VNode?[])

Shorthand overload: positional className + variadic children, building a div element with just a class string and children. For any prop besides className, use the long-form overload with named arguments.

DropdownField(string?, string?, List<string>?, Action<string>?, string?, string?, string?, bool?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)

Creates a DropdownField.

ErrorBoundary(Func<Exception, VNode>, VNode?[], string?)

Helper that wraps children in an inline Error Boundary with the given fallback. Catches exceptions thrown during render of the child tree (including rethrows from pending Suspense resources via Hooks.Use) and renders the VNode produced by fallback instead. Useful for reducing boilerplate where introducing a dedicated [Component(IsErrorBoundary = true)] wrapper class would be overkill (e.g. a root boundary directly under Mount).

Fragment(VNode?[], string?)

Fragment node. Returns multiple nodes without an enclosing wrapper element. When key is supplied, the Fragment's children participate in the parent's keyed sibling list as a single keyed unit: their identity is scoped by key so siblings under a Fragment with a different key do not collide, and per-child fiber state (Hooks, refs) is preserved across reorders of the keyed Fragments.

Image(string?, string?, string?, StyleOverrides?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)

Creates an Image element for displaying sprites or textures.

IntegerField(string?, int?, Action<int>?, string?, string?, string?, bool?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)

Creates an IntegerField for entering integer values.

Label(string?, string?, string?, string?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)

Creates a Label.

Link(string, string?, string?, string?, VNode?[]?, bool, string?)

Clickable navigation primitive. Navigates to to via the active Router on click. The target may be absolute or relative (resolved against the current location).

ListFragment<T>(IReadOnlyList<T>, Func<T, int, string>, Func<T, int, VNode>, string?)

Sibling-friendly variant of List<T>(IReadOnlyList<T>, Func<T, int, string>, Func<T, int, VNode>) that wraps the mapped nodes in a single FragmentNode so the result can sit inline among sibling nodes in one children list.

ListFragment<T>(IReadOnlyList<T>, Func<T, string>, Func<T, VNode>, string?)

Sibling-friendly variant of List<T>(IReadOnlyList<T>, Func<T, string>, Func<T, VNode>) that wraps the mapped nodes in a single FragmentNode. Because a Fragment is a VNode that the reconciler expands inline, the result can sit among sibling nodes in one children list (e.g. V.Div("c", header, V.ListFragment(...), footer)) without an extra wrapper element.

ListView(string?, string?, string?, bool?, StyleOverrides?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)

Creates a ListView (virtualized scrollable list).

List<T>(IReadOnlyList<T>, Func<T, int, string>, Func<T, int, VNode>)

Builds a keyed VNode list from an indexed collection, mapping each item together with its index to a VNode.

List<T>(IReadOnlyList<T>, Func<T, string>, Func<T, VNode>)

Builds a keyed VNode list from a collection by mapping each item to a VNode and attaching a stable per-item key. If renderer returns null for an item, the slot is included in the array but skipped by the Reconciler's FlattenAndFilter.

Memo<TProps>(Func<TProps, VNode>, TProps, Func<TProps, TProps, bool>, string?)

Memoizes a component with a custom areEqual comparator. Embeds a props-receiving function component (the same shape as Component<TProps>(Func<TProps, VNode>, TProps, string?)) but supplies an explicit areEqual predicate that decides whether a parent re-render bails this component.

Memoized(Func<VNode>, params object?[]?)

Memoization node. Skips rebuilding the child subtree while the dependency array is unchanged. When key is omitted, the order of MemoNodes within the same component must remain stable, since identity is resolved by call order. If the order can change dynamically, use MemoizedWithKey(string?, Func<VNode>, params object?[]?) instead. This is distinct from Memo<TProps>(Func<TProps, VNode>, TProps, Func<TProps, TProps, bool>, string?), which memoizes a function-style component by props equality.

MemoizedWithKey(string?, Func<VNode>, params object?[]?)

Keyed memoization node. Provides a stable cache keyed by the supplied key.

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.

Mount(VisualElement, VNode)

Mounts a VNode tree onto target, establishing it as a render root and performing the initial render. Dispose the returned MountedTree to unmount.

NavLink(string, string, string?, string?, string?, VNode?[]?, bool, bool, bool, string?)

Clickable navigation primitive that derives an active state from the current location. Applies activeClass when the link is active.

Navigate(string, bool, string?)

Declarative redirect element. Navigates to to via the active Router, then renders nothing. Use it for conditional redirects such as return loggedIn ? V.Outlet() : V.Navigate("/login").

Outlet(object?, string?)

Placeholder that renders the matched child route component of a nested route at this position.

Particles(ParticleSystem?, string?, string?, string?, PlayTrigger, float, StyleOverrides?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)

Creates a Particles element that simulates effect in a hidden, framework-owned host and draws the live particles as textured quads inside the element — no camera, no world-space canvas, no render-pipeline coupling. The simulation host is instantiated on mount (its renderer disabled; only the simulation is consumed), destroyed on unmount, and recreated when effect changes.

Portal(string, VNode?[]?, string?)

Renders children into the Portal target identified by targetId, detaching them from the surrounding DOM position so they mount under a different host element. targetId must reference an ID previously registered via FiberPortalRegistry.Register.

Portal(UILayer, VNode?[]?, string?)

Renders children into a framework-managed screen-space layer panel sorted around the app's main panel — one host panel per layer per reconciler, created lazily and destroyed with the reconciler. Like every portal, the children stay part of the LOGICAL tree (context and state cross the boundary) while attaching physically to the layer panel — so event bubbling, relational group-/peer- variants and focus-within do not cross, and responsive breakpoints evaluate against the layer panel's own width. Screen-space layers always composite over the 3D scene; UI that must sit among scene geometry is WorldSpace(Vector3, Quaternion?, Vector2?, VNode?[]?, string?)'s territory.

Provider<T>(ComponentContext<T>, T, VNode?[]?, string?)

Provides a context value to the descendant subtree, visible to descendants that read the same context via Hooks.UseContext.

RadioButton(string?, bool?, Action<bool>?, string?, string?, string?, bool?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)

Creates a RadioButton. An individual radio button used inside a RadioButtonGroup.

RadioButtonGroup(string?, int?, List<string>?, Action<int>?, string?, string?, string?, bool?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)

Creates a RadioButtonGroup that materializes a set of radio buttons from a list of choices.

Route(string?, ComponentNode?, string?, Func<RouteLoaderContext, CancellationToken, UniTask<object>>?, LoaderMode, ComponentNode?, RouteDefinition[]?, string?, Func<RouteLoaderContext, string>?, bool)

Path-based route definition. Declaratively expresses Velvet Router's nested routes and Loaders.

Routes(params RouteDefinition[])

Container for an array of RouteDefinition values. Aggregates routes declared via V.Route() into the route table consumed when configuring the Router.

SceneView(Camera?, string?, string?, string?, float, StyleOverrides?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)

Creates a SceneView element displaying camera's output — the canvas-parity element. The framework owns the RenderTexture: it is created at the element's laid-out pixel size (times resolutionScale), resized when the element's geometry changes, assigned to camera.targetTexture while mounted, and released on unmount (restoring the camera's target only if it is still the framework's own texture). The output arrives through the element's background image, so background utilities and rounded corners apply to it.

ScrollView(string?, string?, string?, ScrollerVisibility?, ScrollerVisibility?, TouchScrollBehavior?, Action<VisualElement>?, Func<VisualElement, Action>?, VNode?[]?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)

Creates a ScrollView. Long form: every prop is a named optional parameter. For the shorthand V.ScrollView("class", child1, child2) form, see the params overload.

ScrollView(string, params VNode?[])

Shorthand overload: positional className + variadic children, building a ScrollView element with just a class string and children. For any prop besides className, use the long-form overload with named arguments.

Slider(string?, float?, float?, float?, Action<float>?, string?, string?, bool?, Func<VisualElement, Action>?, Action<VisualElement>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)

Creates a Slider.

Suspense(VNode?, VNode?[], string?)

Boundary that displays fallback while any descendant declares a pending async resource via Use<T>(), until the resource resolves. On error, the failure is propagated to the nearest Error Boundary (a component that overrides RenderFallback).

Text(string?)

Creates a text-only node. Materialized as a Label.

TextField(string?, string?, Action<string>?, string?, string?, string?, bool?, bool?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)

Creates a TextField.

Toggle(string?, bool?, Action<bool>?, string?, string?, string?, bool?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)

Creates a Toggle.

VirtualList<T>(IReadOnlyList<T>, Func<T, string>, float, Func<T, VNode>, int, string?, string?, string?)

Virtualized list component for rendering large item collections. Renders a fixed-height-item ScrollView and only places the visible range in the DOM (a virtualized list).

When(bool, Func<VNode>?)

Conditional rendering. Returns null when condition is false (handled by the Reconciler's null filter).

WorldSpace(Vector3, Quaternion?, Vector2?, VNode?[]?, string?)

Renders children into a framework-owned world-space panel positioned by a scene transform — UI that lives among 3D content and is depth-tested against it (the drei <Html> parity point), unlike the always-on-top screen-space layers. The host (GameObject + world-space panel) is created on mount, follows position / rotation updates, and is destroyed on unmount. Children stay part of the logical tree (context and state cross; events do not — the panel boundary is physical). Display-only: world-space input routing is not wired.