Soenneker.Blazor.Drawflow 3.0.22

Prefix Reserved
dotnet add package Soenneker.Blazor.Drawflow --version 3.0.22
                    
NuGet\Install-Package Soenneker.Blazor.Drawflow -Version 3.0.22
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Blazor.Drawflow" Version="3.0.22" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Blazor.Drawflow" Version="3.0.22" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Blazor.Drawflow" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Blazor.Drawflow --version 3.0.22
                    
#r "nuget: Soenneker.Blazor.Drawflow, 3.0.22"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Blazor.Drawflow@3.0.22
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Blazor.Drawflow&version=3.0.22
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Blazor.Drawflow&version=3.0.22
                    
Install as a Cake Tool

NuGet Build Status NuGet Downloads alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Blazor.Drawflow

Soenneker.Blazor.Drawflow is a lightweight, modern Blazor wrapper for drawflow.js, enabling interactive node-based diagrams in your Blazor applications. It supports advanced features like modules, zoom, import/export, and full event handling.

image

Features

  • Node and Connection Management: Add, remove, and update nodes and connections programmatically.
  • Modules: Organize nodes into modules and switch between them.
  • Zoom & Pan: Built-in zoom controls and canvas panning.
  • Import/Export: Serialize and restore flows as JSON.
  • Event Handling: Subscribe to all major events (node created, removed, selected, data changed, etc).
  • Customizable: Pass options to control rerouting, curvature, zoom limits, and more.
  • CDN or Local Assets: Load drawflow.js and CSS from CDN or local files.

Installation

dotnet add package Soenneker.Blazor.Drawflow

Quick Start

  1. Register Services (in Program.cs):
builder.Services.AddDrawflowInteropAsScoped();
  1. Add the Component (in your .razor file):
<Drawflow @ref="Flow" Options="_options" OnNodeCreated="HandleNodeCreated" style="height:400px"></Drawflow>

@code {
    private Drawflow? Flow;
    private readonly DrawflowOptions _options = new();

    private Task HandleNodeCreated(string id)
    {
        Console.WriteLine($"Node created {id}");
        return Task.CompletedTask;
    }
}

Event Callbacks

<Drawflow
    @ref="Flow"
    Options="_options"
    OnNodeCreated="HandleNodeCreated"
    OnNodeRemoved="HandleNodeRemoved"
    OnConnectionCreated="HandleConnectionCreated"
    OnDataChanged="HandleDataChanged"
    ... />

Programmatic API

The Drawflow component implements IDrawflow interface, providing a clean API for programmatic control:

// Using the component reference
await Flow.AddNode("github", 1, 1, 150, 150, "github", new { name = "GitHub" }, "<div>GitHub</div>");
await Flow.AddConnection("github", "slack", "output", "input");
await Flow.ZoomIn();

// Export as strongly-typed object
DrawflowExport graph = await Flow.Export();

// Export as JSON string
string json = await Flow.ExportAsJson();

Interface Usage

You can also use the IDrawflow interface for dependency injection and testing:

// In your service registration
services.AddScoped<IDrawflow, Drawflow>();

// In your component or service
@inject IDrawflow DrawflowService

// Usage
await DrawflowService.AddNode("test", 1, 1, 100, 100, "test", null, "<div>Test</div>");

Strongly-Typed Methods

The library provides overload methods that accept strongly-typed objects for better type safety and IntelliSense support:

// Add node using strongly-typed DrawflowNode
var node = new DrawflowNode
{
    Name = "MyNode",
    PosX = 100,
    PosY = 100,
    Class = "my-node",
    Html = "<div>My Node</div>",
    Data = new Dictionary<string, object> { ["key"] = "value" }
};
await Flow.AddNode(node);

// Add module using strongly-typed DrawflowModule
var module = new DrawflowModule
{
    Data = new Dictionary<string, DrawflowNode>
    {
        ["node1"] = new DrawflowNode { Name = "Node1", PosX = 100, PosY = 100 }
    }
};
await Flow.AddModule("MyModule", module);

// Import using strongly-typed DrawflowExport
var drawflowExport = new DrawflowExport
{
    Drawflow = new Dictionary<string, DrawflowModule>
    {
        ["Home"] = new DrawflowModule { Data = new Dictionary<string, DrawflowNode>() }
    }
};
await Flow.Import(drawflowExport);

// Import from JSON string
await Flow.Import(jsonString);

Options

var options = new DrawflowOptions {
    Reroute = true,
    Curvature = 0.3,
    Zoom = 1.0,
    ZoomMax = 2.0,
    ZoomMin = 0.3,
    DraggableInputs = true,
    UseUuid = true,
    ManualCreate = false // auto-create on render
};

Export Models

The library provides strongly-typed models for working with exported drawflow data:

// Main graph structure
public class DrawflowExport
{
    public Dictionary<string, DrawflowModule>? Drawflow { get; set; }
}

// Module containing nodes
public class DrawflowModule
{
    public Dictionary<string, DrawflowNode>? Data { get; set; }
}

// Individual node with connections
public class DrawflowNode
{
    public string? Id { get; set; }
    public string? Name { get; set; }
    public Dictionary<string, object>? Data { get; set; }
    public Dictionary<string, DrawflowNodeIO>? Inputs { get; set; }
    public Dictionary<string, DrawflowNodeIO>? Outputs { get; set; }
    public int PosX { get; set; }
    public int PosY { get; set; }
}

// Input/Output connections
public class DrawflowNodeIO
{
    public List<DrawflowConnection>? Connections { get; set; }
}

// Connection between nodes
public class DrawflowConnection
{
    public string? Node { get; set; }
    public string? Input { get; set; }
    public string? Output { get; set; }
}
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.22 82 7/30/2025
3.0.21 433 7/24/2025
3.0.20 430 7/21/2025
3.0.19 181 7/20/2025
3.0.18 184 7/19/2025
3.0.17 15 7/19/2025
3.0.16 15 7/19/2025
3.0.13 28 7/18/2025
3.0.12 158 7/9/2025
3.0.11 131 7/9/2025
3.0.10 135 7/9/2025
3.0.9 134 7/9/2025
3.0.8 132 7/3/2025
3.0.7 129 7/3/2025
3.0.6 132 7/3/2025
3.0.5 132 7/1/2025
3.0.4 126 7/1/2025
3.0.3 131 7/1/2025
3.0.1 134 6/30/2025