syncfusion/blazor-ui-components-skills / skills/syncfusion-blazor-diagram
syncfusion-blazor-diagram
VerifiedBuild and troubleshoot Syncfusion Blazor diagrams using SfDiagramComponent. Trigger for flowcharts, org charts, mind maps, BPMN, UML sequence, swimlanes, symbol palettes, nodes/connectors/ports/annotations, layouts, data binding, serialization (load/save), export/print, and collaborative editing questions. Provide Blazor + Syncfusion setup steps, configuration patterns, and sample snippets.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 28.6 KB |
| references/advanced-features.md | markdown | 10.0 KB |
| references/annotations.md | markdown | 11.9 KB |
| references/bpmn.md | markdown | 6.6 KB |
| references/collaborative-editing.md | markdown | 7.0 KB |
| references/connectors.md | markdown | 6.4 KB |
| references/data-binding.md | markdown | 12.8 KB |
| references/events.md | markdown | 52.7 KB |
| references/export-print.md | markdown | 5.9 KB |
| references/getting-started.md | markdown | 5.4 KB |
| references/interaction.md | markdown | 36.7 KB |
| references/layout.md | markdown | 12.3 KB |
| references/nodes.md | markdown | 8.6 KB |
| references/overview-component.md | markdown | 5.5 KB |
| references/ports.md | markdown | 5.1 KB |
| references/serialization.md | markdown | 3.5 KB |
| references/shapes.md | markdown | 6.2 KB |
| references/styling.md | markdown | 6.1 KB |
| references/swimlane.md | markdown | 6.1 KB |
| references/symbol-palette.md | markdown | 7.7 KB |
| references/uml-class-diagram.md | markdown | 25.5 KB |
| references/uml-sequence.md | markdown | 6.5 KB |
references/ports.md
View on GitHub# Ports in Blazor Diagram
## Table of Contents
- [Overview](#overview)
- [Creating Ports](#creating-ports)
- [Port Positioning](#port-positioning)
- [Port Appearance](#port-appearance)
- [Connecting via Ports](#connecting-via-ports)
- [Port Visibility](#port-visibility)
- [Dynamic Ports](#dynamic-ports)
- [Port Constraints](#port-constraints)
- [Common Gotchas](#common-gotchas)
---
## Overview
Ports are fixed connection points on nodes. When a connector is attached to a port (instead of a node), it always connects at that exact point — even when the node is moved. Use ports when precise connection placement matters.
**Node-to-node connection:** Connector auto-routes to the nearest edge.
**Port-to-port connection:** Connector always connects at the specified port, regardless of node movement.
---
## Creating Ports
Add ports to a node's `Ports` collection using `PointPort`:
```razor
@using Syncfusion.Blazor.Diagram
<SfDiagramComponent Height="600px" Nodes="@nodes" />
@code {
DiagramObjectCollection<Node> nodes = new();
protected override void OnInitialized()
{
nodes.Add(new Node
{
ID = "node1",
OffsetX = 250, OffsetY = 250,
Width = 100, Height = 100,
Style = new ShapeStyle { Fill = "#6495ED", StrokeColor = "white" },
Ports = new DiagramObjectCollection<PointPort>
{
new PointPort
{
ID = "port1",
Offset = new DiagramPoint { X = 0.5, Y = 0 }, // top center
Visibility = PortVisibility.Visible,
Shape = PortShapes.Circle
},
new PointPort
{
ID = "port2",
Offset = new DiagramPoint { X = 0.5, Y = 1 }, // bottom center
Visibility = PortVisibility.Visible,
Shape = PortShapes.Circle
}
}
});
}
}
```
> **⚠️ Port ID rules:** Must not start with a number or contain underscores/spaces.
---
## Port Positioning
Port `Offset` uses fractions of the node's width and height:
| Offset | Position |
|--------|----------|
| `(0.5, 0)` | Top center |
| `(0.5, 1)` | Bottom center |
| `(0, 0.5)` | Left center |
| `(1, 0.5)` | Right center |
| `(0, 0)` | Top-left corner |
| `(1, 0)` | Top-right corner |
| `(0, 1)` | Bottom-left corner |
| `(1, 1)` | Bottom-right corner |
| `(0.5, 0.5)` | Center |
---
## Port Appearance
```razor
new PointPort
{
ID = "p1",
Offset = new DiagramPoint { X = 1, Y = 0.5 },
Visibility = PortVisibility.Visible,
Shape = PortShapes.Circle, // Circle, Square, Diamond, Custom
Style = new ShapeStyle
{
Fill = "#37909A",
StrokeColor = "white",
StrokeWidth = 1
},
Width = 12,
Height = 12
}
```
Available `PortShapes`: `Circle`, `Square`, `Diamond`, `Custom` (with `PathData`)
---
## Connecting via Ports
Use `SourcePortID` and `TargetPortID` on a connector to connect to specific ports:
```razor
connectors.Add(new Connector
{
ID = "conn1",
SourceID = "node1",
SourcePortID = "port1", // connect from port1 on node1
TargetID = "node2",
TargetPortID = "portA", // connect to portA on node2
Type = ConnectorSegmentType.Orthogonal
});
```
To connect from a port to a free point:
```razor
new Connector
{
SourceID = "node1",
SourcePortID = "port1",
TargetPoint = new DiagramPoint { X = 400, Y = 300 }
}
```
---
## Port Visibility
Control when ports are shown:
```razor
new PointPort
{
Visibility = PortVisibility.Visible // always visible
// PortVisibility.Hidden // never visible
// PortVisibility.Hover // show on mouse hover only (default)
// PortVisibility.Connect // show when connecting
}
```
---
## Dynamic Ports
Add ports to a node at runtime:
```csharp
_diagram.Nodes[0].Ports.Add(new PointPort
{
ID = "dynPort",
Offset = new DiagramPoint { X = 0.5, Y = 0.5 },
Visibility = PortVisibility.Visible,
Shape = PortShapes.Square
});
```
---
## Port Constraints
Control what a port allows:
```razor
new PointPort
{
Constraints = PortConstraints.Default & ~PortConstraints.Draw
// PortConstraints.None — no connections allowed
// PortConstraints.Draw — allow drawing connectors from port
// PortConstraints.Default — all interactions enabled
// PortConstraints.InConnect — allow connecting only the target end of the connector
// PortConstraints.OutConnect — allow connecting only the source end of the connector.
}
```
---
## Common Gotchas
- **Port ID must be unique per node** — duplicate port IDs cause connection issues
- **`PortVisibility.Hover` is default** — ports only show on hover; set `PortVisibility.Visible` to always display them
- **`SourcePortID`/`TargetPortID` must match an existing port ID** on the referenced node
- **Node-to-node vs port-to-port:** node connections auto-route; port connections stay fixed at the port position
- **Port `Offset` is relative to the node** (0–1), not the diagram canvas
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |