Fragiola

API: primitives (@fragiola/flow-react, @fragiola/flow-vue, @fragiola/flow-svelte, @fragiola/flow-angular)

Background

Flow.Background draws a pattern of dots, lines or crosses that pans and zooms with the flow, in currentColor, behind the viewport.

Flow.Background goes inside Flow.Root, before Flow.Viewport. It renders an SVG filled with one tile of a pattern (background-pattern): dots, lines or crosses, at gap flow units apart, moved and scaled with the viewport. The marks are drawn in currentColor: set the color (and the background itself) in your style.

Backgrounds
Gallery
<Flow.Root<Types, typeof features> features={features} defaultNodes={nodes} className="bg-gray-50">
    <Flow.Background variant="dots" gap={20} size={2} className="text-gray-300" />
    <Flow.Background variant="lines" gap={100} className="text-gray-200" />
    <Flow.Viewport>…</Flow.Viewport>
</Flow.Root>

Several layers combine (a fine grid and a coarse one). Its variant is a prop, so a CSS theme cannot switch it: the examples render the three variants and let the theme's tokens show one.

Props

BackgroundProps extends the common primitive props and every SVG attribute of an svg but children and offset.

proptypedefaultdescription
variantBackgroundVariant"dots"the marks: "dots", "lines" or "cross"
gapnumber | readonly [number, number]20the distance between two marks, in flow units ([x, y] for two)
sizenumber1 (dots, lines), 6 (cross)dots: a dot's diameter, in flow units; lines: the stroke width, in screen pixels (not scaled by the zoom); cross: the length of each bar (an arm is half of it), in flow units
offsetnumber | readonly [number, number]0the pattern's shift from the flow's origin, in flow units

State

BackgroundState, what className, style and render receive:

fieldtypedescription
patternBackgroundPatternthe pattern's tile on the screen, at the current viewport (engine reads)

Data attributes

attributevalue
data-flow-part"background"; inside it "background-pattern" (the pattern), "background-mark" (its circle or path) and "background-fill" (the rect)

Structural style

Absolute, 100% of the root, pointer-events: none. The marks' fill or stroke is currentColor.