---
name: svelteflow-custom-nodes
user-invocable: false
description: Use when creating custom Svelte Flow nodes, edges, and handles. Covers custom node components, resizable nodes, toolbars, and advanced customization.
allowed-tools:
- Bash
- Read
---
# Svelte Flow Custom Nodes and Edges
Create fully customized nodes and edges with Svelte Flow. Build complex
node-based editors with custom styling, behaviors, and interactions.
## Custom Node Component
```svelte
```
## Registering Custom Nodes
```svelte
```
## Styled Node with Tailwind
```svelte
{config.icon}
{data.label}
```
## Node with Multiple Handles
```svelte
{#each data.cases as caseLabel, index}
{caseLabel}
{/each}
```
## Resizable Node
```svelte
{data.label}
{data.content}
```
## Node with Toolbar
```svelte
{#if isEditing}
{:else}
{data.label}
{/if}
```
## Custom Edge
```svelte
```
## Registering Custom Edges
```svelte
```
## Group Node (Parent Container)
```svelte
```
```svelte
```
## Custom Handle Component
```svelte
```
## Interactive Node with State
```svelte
```
## CSS Styling
```css
/* Global flow styles */
:global(.svelte-flow__node-custom) {
background: white;
border: 1px solid #1a192b;
border-radius: 8px;
padding: 10px;
font-size: 12px;
}
:global(.svelte-flow__node-custom.selected) {
border-color: #ff0071;
box-shadow: 0 0 0 2px #ff0071;
}
:global(.svelte-flow__handle) {
width: 10px;
height: 10px;
border-radius: 50%;
background-color: #555;
}
:global(.svelte-flow__handle-connecting) {
background-color: #ff0071;
}
:global(.svelte-flow__handle-valid) {
background-color: #55dd99;
}
/* Prevent drag on interactive elements */
:global(.nodrag) {
pointer-events: all;
}
/* Edge styling */
:global(.svelte-flow__edge-path) {
stroke: #b1b1b7;
stroke-width: 2;
}
:global(.svelte-flow__edge.selected .svelte-flow__edge-path) {
stroke: #ff0071;
}
```
## When to Use This Skill
Use svelteflow-custom-nodes when you need to:
- Build nodes with interactive Svelte components
- Create visually distinct node types
- Add node toolbars and context menus
- Build resizable nodes
- Create group/container nodes
- Add custom edge interactions
- Build complex workflow interfaces in Svelte
## Best Practices
- Use Svelte's reactivity for state management
- Define nodeTypes/edgeTypes at component level
- Use the `nodrag` class on interactive elements
- Keep node components focused and reusable
- Use TypeScript for type-safe node data
- Use CSS scoping for node styles
- Test connection validation thoroughly
## Resources
- [Svelte Flow Custom Nodes](https://svelteflow.dev/learn/customization/custom-nodes)
- [Svelte Flow Custom Edges](https://svelteflow.dev/learn/customization/custom-edges)
- [Node Toolbar API](https://svelteflow.dev/api-reference/components/node-toolbar)
- [Node Resizer API](https://svelteflow.dev/api-reference/components/node-resizer)