Method Div
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
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.
public static ElementNode Div(string? className = null, string? key = null, string? name = null, FiberElementProps? props = null, StyleOverrides? styles = null, Func<VisualElement, Action>? refCallback = null, VNode?[]? children = null, string? whileHoverClass = null, string? whileTapClass = null, string? whileFocusClass = null, IReadOnlyDictionary<string, string>? data = null, IReadOnlyDictionary<string, string>? aria = null)
Parameters
classNamestringCSS-like utility class string. Multiple classes separated by spaces.
keystringKey used to disambiguate siblings at the same position.
namestringElement name assigned to UnityEngine.UIElements.VisualElement.name for query/debug.
propsFiberElementPropsOptional FiberElementProps (text / tooltip / enabled / etc.) bag.
stylesStyleOverridesInline style overrides applied on top of USS classes.
refCallbackFunc<VisualElement, Action>Callback invoked on mount with the created VisualElement; returned Action runs on unmount.
childrenVNode[]Child VNodes rendered inside this element.
whileHoverClassstringUSS class toggled while the pointer hovers the element.
whileTapClassstringUSS class toggled while the pointer is pressed on the element.
whileFocusClassstringUSS class toggled while the element holds keyboard/UI focus.
dataIReadOnlyDictionary<string, string>data-* attribute map matched by
data-[...]variants.ariaIReadOnlyDictionary<string, string>aria-* attribute map matched by
aria-[...]variants.
Returns
- ElementNode
The created ElementNode representing this element.
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.
public static ElementNode Div(string className, params VNode?[] children)
Parameters
classNamestringCSS-like utility class string. Multiple classes separated by spaces.
childrenVNode[]Child VNodes; pass zero or more positionals or expand an existing array.
Returns
- ElementNode
The created ElementNode.