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/styling.md
View on GitHub# Styling in Blazor Diagram
## Table of Contents
- [Node and Connector Styles](#node-and-connector-styles)
- [Annotation Text Style](#annotation-text-style)
- [CSS Class Override](#css-class-override)
- [Key CSS Classes Reference](#key-css-classes-reference)
- [Common Gotchas](#common-gotchas)
---
## Node and Connector Styles
Use `ShapeStyle` to style nodes and connectors programmatically:
```razor
new Node
{
Style = new ShapeStyle
{
Fill = "#6495ED",
StrokeColor = "#2c3e50",
StrokeWidth = 2,
StrokeDashArray = "5,2", // dashed border
Opacity = 0.85
}
}
new Connector
{
Style = new ShapeStyle
{
StrokeColor = "#e74c3c",
StrokeWidth = 2,
StrokeDashArray = "4,2"
}
}
```
**ShapeStyle properties:**
| Property | Type | Description |
|----------|------|-------------|
| `Fill` | string | Background fill color (hex, rgb, named) |
| `StrokeColor` | string | Border/line color |
| `StrokeWidth` | double | Border/line thickness in pixels |
| `StrokeDashArray` | string | Dash pattern (e.g., `"5,3"`) |
| `Opacity` | double | 0.0 (transparent) to 1.0 (opaque) |
| `Gradient` | `GradientBrush` | Linear or radial gradient fill |
**Gradient fill example:**
```razor
new Node
{
Style = new ShapeStyle
{
Gradient = new LinearGradientBrush
{
X1 = 0, Y1 = 0, X2 = 0, Y2 = 1,
GradientStops = new DiagramObjectCollection<GradientStop>
{
new GradientStop { Color = "#ffffff", Offset = 0 },
new GradientStop { Color = "#6495ED", Offset = 100 }
}
}
}
}
```
---
## Annotation Text Style
```razor
new ShapeAnnotation
{
Style = new TextStyle
{
Color = "#ffffff",
FontSize = 14,
FontFamily = "Segoe UI",
Bold = true,
Italic = false,
TextDecoration = TextDecoration.None, // or Underline, LineThrough
Fill = "transparent", // annotation background
StrokeColor = "none"
}
}
```
---
## CSS Class Override
`SfDiagramComponent` does **not** have a `CssClass` property. To scope CSS overrides to a single diagram instance, wrap it in a `<div>` with a custom class and target `.e-diagram` and its child classes beneath that wrapper:
```razor
<div class="my-diagram">
<SfDiagramComponent Width="100%" Height="600px" Nodes="@nodes" />
</div>
<style>
/* Canvas background */
.my-diagram .e-diagram {
background-color: #f0f4f8;
}
/* Selection border */
.my-diagram .e-diagram-border {
stroke: #3498db !important;
stroke-width: 2px !important;
}
/* Resize handles */
.my-diagram .e-diagram-resize-handle {
fill: white !important;
stroke: #3498db !important;
}
</style>
```
---
## Key CSS Classes Reference
Override these classes globally or scoped under your wrapper `div` class:
| CSS Class | Target |
|-----------|--------|
| `.e-diagram` | Diagram canvas background |
| `.e-diagram-border` | Selection bounding box border |
| `.e-diagram-endpoint-handle` | Connector endpoint handle |
| `.e-diagram-endpoint-handle.e-connected` | Endpoint handle when connected |
| `.e-diagram-endpoint-handle.e-disabled` | Endpoint handle when port is disabled |
| `.e-diagram-bezier-handle` | Bezier control point handle |
| `.e-diagram-bezier-line` | Bezier tangent line |
| `.e-diagram-ortho-segment-handle` | Orthogonal segment thumb |
| `.e-diagram-bezier-segment-handle` | Bezier/Straight segment handle |
| `.e-diagram-resize-handle` | Node resize corner handle |
| `.e-diagram-rotate-handle` | Node rotation handle |
| `.e-diagram-pivot-line` | Pivot line from node to rotate handle |
| `.e-diagram-first-selection-indicator` | First selected element highlight |
| `.e-diagram-selection-indicator` | All selected elements highlight |
| `.e-diagram-highlighter` | Hover highlight on connectors/ports |
| `.e-diagram-helper` | Alignment guide/helper lines |
| `.e-diagram-thin-grid` | Thin grid lines |
| `.e-diagram-thick-grid` | Thick grid lines |
| `.e-diagram .e-diagram-text-edit` | Inline annotation text editing box |
| `.e-diagram-text-edit::selection` | Text selection color in edit mode |
| `.e-symbolpalette .e-symbol-hover:hover` | Symbol palette item hover state |
| `.e-symbolpalette .e-symbol-selected` | Symbol palette item selected state |
| `.e-symbol-draggable` | Symbol palette item background |
| `.e-diagram .e-ruler` | Ruler background and font |
| `.e-diagram .e-ruler-overlap` | Corner overlap area of horizontal and vertical rulers |
| `.overviewresizer` | Overview component resize handle |
### Example: Customize selection border and rotate handle
```html
<style>
.e-diagram-border {
stroke: #3498db;
stroke-width: 2px;
}
.e-diagram-rotate-handle {
fill: #3498db;
stroke: #2c3e50;
}
.e-diagram-resize-handle {
fill: white;
opacity: 1;
stroke: #3498db;
}
</style>
```
### Example: Customize diagram background and grid
```html
<style>
.e-diagram {
background-color: #1a1a2e;
}
.e-diagram-thin-grid {
stroke: #2a2a4a;
}
.e-diagram-thick-grid {
stroke: #3a3a6a;
}
</style>
```
---
## Common Gotchas
- **`ShapeStyle.Fill`** applies to nodes only — connectors use `StrokeColor` for their line color
- **`!important` may be needed** for CSS class overrides that conflict with Syncfusion's default specificity
- **`CssClass` does NOT exist** on `SfDiagramComponent` — causes `InvalidOperationException`. Wrap the component in a `<div class="my-diagram">` and scope styles beneath that class instead
- **CSS classes apply globally** unless scoped under a wrapper `<div>` with a custom class around `SfDiagramComponent`
- **Gradient fills** require both `X1/Y1` (start) and `X2/Y2` (end) coordinates as 0–1 fractions of the element
- **`TextStyle.Fill`** controls the annotation label's background, not the node's fill; set it to `"transparent"` unless you need a colored label box
- **Themes (Bootstrap, Material, etc.)** are loaded via the `SyncfusionBlazorThemes` CSS link — switching themes changes many default diagram colors automatically
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 |