Tailwind CSS
In this example we are using Tailwind for styling the flow.
Svelte Flow’s styles live in the xyflow CSS layer. Declare the layer order before your imports so that
Tailwind’s reset doesn’t override the default styles, but your utility classes still can.
index.css
@layer theme, base, xyflow, components, utilities;
@import 'tailwindcss';
@import '@xyflow/svelte/style.css';<script lang="ts">
import { SvelteFlow, Controls, type Node, type Edge } from '@xyflow/svelte';
import { initialNodes, initialEdges } from './nodes-and-edges';
import CustomNode from './CustomNode.svelte';
import './index.css';
let nodes = $state.raw<Node[]>(initialNodes);
let edges = $state.raw<Edge[]>(initialEdges);
const nodeTypes = {
custom: CustomNode,
};
</script>
<div class="w-full h-full">
<SvelteFlow
class="bg-teal-50 dark:bg-gray-900"
bind:nodes
{nodeTypes}
bind:edges
fitView
>
<Controls />
</SvelteFlow>
</div>