Fragiola

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

FitView

Flow.FitView fits every node into the root with one press, and is disabled until the engine knows the size of a node.

Flow.FitView renders a button (type="button") that runs the engine's "fit-view" action: it fits every node in the root, with a padding of 0.1, within the zoom limits. Before the root and a node have a size the engine refuses it, so the button is disabled (and data-disabled) while engine.can("fit-view") is false; it re-renders when the view changes. It sets no text and no name: give it an icon and an aria-label. Put it in Flow.Controls, or anywhere inside Flow.Root.

import { MaximizeIcon } from "lucide-react";

<Flow.FitView aria-label="Fit view" className="p-1 data-disabled:opacity-40">
    <MaximizeIcon />
</Flow.FitView>;

The same action from code: engine.run("fit-view") (engine). Its props are the action's payload: one left out is not sent, so the engine's default applies. Pixels, per-side padding and hidden nodes: What fit-view frames.

Props

FitViewProps extends the common primitive props and every button attribute; a disabled of yours disables it too.

proptypedefaultdescription
durationnumber0how long its viewport change animates, in milliseconds (the root's easing); 0: at once
paddingFitPadding0.1the room kept free: a share of the root's size, "<n>px", or each side's { top, right, bottom, left }
nodeIdsstring[]every node not hiddenonly these nodes
includeHiddenbooleanfalsewithout nodeIds, the hidden nodes of known size too
minZoomnumberthe root's minZoomthe least zoom it may pick
maxZoomnumberthe root's maxZoomthe greatest zoom it may pick
childrenReactNodenoneits icon or label

State

ControlButtonState (Controls), what className, style and render receive:

fieldtypedescription
disabledbooleanthe engine refuses its action now, or its disabled prop is set

Data attributes

attributevalue
data-flow-part"fit-view"
data-disabledpresent while disabled