Skip to Content
✨ Svelte Flow 1.0 is here! Rewritten for Svelte 5 with many new features and improvements.
ReferenceComponents<Background />

<Background />

Source on GitHub 

The <Background /> component makes it convenient to render different types of backgrounds common in node-based UIs. It comes with three variants: lines, dots and cross.

<script lang="ts"> import { SvelteFlow, Background, BackgroundVariant } from '@xyflow/svelte'; let nodes = $state.raw([]); let edges = $state.raw([]); </script> <SvelteFlow bind:nodes bind:edges> <Background bgColor="#ccc" variant={BackgroundVariant.Dots} /> </SvelteFlow>

Props

The type for props of <Background /> component is exported as BackgroundProps.

NameTypeDefault
idstring

When multiple backgrounds are present on the page, each one should have a unique id.

bgColorstring

Color of the background

patternColorstring

Color of the pattern

patternClassstring

Class applied to the pattern

classClassValue

Class applied to the container

gapnumber | [number, number]

The gap between patterns. Passing in a tuple allows you to control the x and y gap independently.

20
sizenumber

The radius of each dot or the size of each rectangle if BackgroundVariant.Dots or BackgroundVariant.Cross is used. This defaults to 1 or 6 respectively, or ignored if BackgroundVariant.Lines is used.

lineWidthnumber

The stroke thickness used when drawing the pattern.

1
variantBackgroundVariant

Variant of the pattern.

BackgroundVariant.Dots
Last updated on