<Background />
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.
| Name | Type | Default |
|---|---|---|
id | stringWhen multiple backgrounds are present on the page, each one should have a unique id. | |
bgColor | stringColor of the background | |
patternColor | stringColor of the pattern | |
patternClass | stringClass applied to the pattern | |
class | ClassValueClass applied to the container | |
gap | number | [number, number]The gap between patterns. Passing in a tuple allows you to control the x and y gap independently. | 20 |
size | numberThe radius of each dot or the size of each rectangle if | |
lineWidth | numberThe stroke thickness used when drawing the pattern. | 1 |
variant | BackgroundVariantVariant of the pattern. | BackgroundVariant.Dots |