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
-
objectV
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.
textandchildrencan be combined. UI Toolkit's Button inherits from TextElement and keeps thetextproperty and child VisualElements independently, so usechildrenwhen declaring multiple children (e.g. icon + label) andtextfor text-only buttons.
- Button(string, params VNode?[])
Shorthand overload: positional
className+ variadicchildren, building aButtonwith just a class string and children (e.g. an icon + label). For any other prop — notablyonClick— 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 throughHooks.UseImperativeHandle.
- Component<TProps>(Func<TProps, VNode>, TProps, string?)
Embeds a function-style component that receives a single
TPropsargument 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 shorthandV.Custom<T>("class", child1, child2)form, see theparamsoverload.
- Custom<T>(string, params VNode?[])
Shorthand overload: positional
className+ variadicchildren, building aTelement with just a class string and children. For any prop besidesclassName, 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 theparamsoverload.
- Div(string, params VNode?[])
Shorthand overload: positional
className+ variadicchildren, building adivelement with just a class string and children. For any prop besidesclassName, use the long-form overload with named arguments.
- ErrorBoundary(Func<Exception, VNode>, VNode?[], string?)
Helper that wraps
childrenin an inline Error Boundary with the given fallback. Catches exceptions thrown during render of the child tree (including rethrows from pending Suspense resources viaHooks.Use) and renders the VNode produced byfallbackinstead. 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
keyis supplied, the Fragment's children participate in the parent's keyed sibling list as a single keyed unit: their identity is scoped bykeyso 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.
- Link(string, string?, string?, string?, VNode?[]?, bool, string?)
Clickable navigation primitive. Navigates to
tovia 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
rendererreturns null for an item, the slot is included in the array but skipped by the Reconciler'sFlattenAndFilter.
- Memo<TProps>(Func<TProps, VNode>, TProps, Func<TProps, TProps, bool>, string?)
Memoizes a component with a custom
areEqualcomparator. Embeds a props-receiving function component (the same shape as Component<TProps>(Func<TProps, VNode>, TProps, string?)) but supplies an explicitareEqualpredicate 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
keyis 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 variantinitial/animatepair (seeinitial), which plays its mount enter on any Motion, standalone or not. Whentransitionis null,StyleTransition.Fadeis applied as the default.duration/easingcan 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), passtransition: StyleTransitionConfig.None. Note: whenDurationSecis 0 (includingStyleTransitionConfig.None),delayis 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
activeClasswhen the link is active.
- Navigate(string, bool, string?)
Declarative redirect element. Navigates to
tovia the active Router, then renders nothing. Use it for conditional redirects such asreturn 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
effectin 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 wheneffectchanges.
- Portal(string, VNode?[]?, string?)
Renders
childreninto the Portal target identified bytargetId, detaching them from the surrounding DOM position so they mount under a different host element.targetIdmust reference an ID previously registered viaFiberPortalRegistry.Register.
- Portal(UILayer, VNode?[]?, string?)
Renders
childreninto 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, relationalgroup-/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 (timesresolutionScale), resized when the element's geometry changes, assigned tocamera.targetTexturewhile 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 theparamsoverload.
- ScrollView(string, params VNode?[])
Shorthand overload: positional
className+ variadicchildren, building aScrollViewelement with just a class string and children. For any prop besidesclassName, use the long-form overload with named arguments.
- Suspense(VNode?, VNode?[], string?)
Boundary that displays
fallbackwhile any descendant declares a pending async resource viaUse<T>(), until the resource resolves. On error, the failure is propagated to the nearest Error Boundary (a component that overridesRenderFallback).
- Text(string?)
Creates a text-only node. Materialized as a Label.
- 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
conditionis false (handled by the Reconciler's null filter).
- WorldSpace(Vector3, Quaternion?, Vector2?, VNode?[]?, string?)
Renders
childreninto 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, followsposition/rotationupdates, 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.