Tesserae

NodeView

Description

The NodeView component is a powerful utility for rendering interactive node-based flows. It is used to define and display nodes with customizable inputs and outputs, allowing you to build complex flow-based interfaces. Use NodeView when you need to visually represent and interact with configurable node graphs.

Usage

Instantiate a NodeView using the static helper method from the Tesserae.UI class. Once instantiated, you can define nodes using methods like DefineNode for static nodes or DefineDynamicNode for nodes that update their outputs based on inputs. Additionally, you can monitor changes in the node graph through the OnChange method.

Below is a simple example that creates a node with a text input and a text output:

Methods

  • OnChange(Action onChange)
    Registers a callback that is invoked whenever the node view's state changes.
    • Parameters:
    - onChange: An Action delegate that receives the current NodeView instance.

  • DefineNode(string nodeTypeName, Action buildNode)
    Defines a new static node type with the specified name and configuration.
    • Parameters:
    - nodeTypeName: The display name of the node type.
    - buildNode: A callback that receives an InterfaceBuilder instance to define inputs and outputs for the node.

  • DefineDynamicNode(string nodeTypeName, Action buildBaseNode, Action<InputsState, OutputsState, InterfaceBuilder> onUpdate)
    Defines a dynamic node whose outputs can change based on its input state.
    • Parameters:
    - nodeTypeName: The name of the dynamic node type.
    - buildBaseNode: A callback to define the base inputs for the node.
    - onUpdate: A callback that is triggered to update outputs based on the current inputs.

  • Render() : HTMLElement
    Renders the NodeView and returns its root HTML element.

  • GetState() : NodeViewGraphState
    Retrieves the current state of the node graph as a NodeViewGraphState object.

  • GetJsonState(bool formated = false) : string
    Returns the JSON representation of the node graph state.
    • Parameters:
    - formated: If true, the JSON is returned in a formatted (indented) style.

  • SetState(string stateJson)
    Sets the node graph state using a JSON string.
    • Parameters:
    - stateJson: A JSON string representing the new state.

  • SetState(NodeViewGraphState state)
    Sets the node graph state directly using a NodeViewGraphState object.
    • Parameters:
    - state: The new state to load into the NodeView.

Properties

The NodeView component does not expose additional public properties apart from its fluent API methods. All configuration and updates are managed through its methods.

Samples

NodeView Sample Usage

The sample below demonstrates how to create a NodeView with multiple nodes, including a dynamic node whose outputs are generated based on an input value. It also shows how to attach a change listener that updates a text area with the current state in JSON format.

See also

  • Toast – For displaying information messages triggered by node actions.
  • TextArea – Used in conjunction with NodeView for state editing and display.
© 2026 Tesserae. All rights reserved.