API: primitives (@fragiola/flow-react, @fragiola/flow-vue, @fragiola/flow-svelte, @fragiola/flow-angular)
ResizeHandle
ResizeHandle is a grab area on a corner or a side of a node; a press on it resizes the node from there, with resize() installed.
ResizeHandle comes from @fragiola/flow-react/resize (@fragiola/flow-vue/resize) and goes inside NodeResizer, inside its
node's element: the engine finds the node a press resizes from the DOM (the closest node part),
and nodeId only names the node in the state. A press on it
resizes its node from its position, a ResizePosition: a corner (top-left, top-right,
bottom-right, bottom-left) moves both dimensions, a side (top, right, bottom, left)
one. A corner is centred on its corner and sits above the two sides it joins; a side spans its
whole side. Give it its size (a side's thickness) and look. RESIZE_POSITIONS lists every
position, corners then sides.
import { NodeResizer, RESIZE_POSITIONS, ResizeHandle } from "@fragiola/flow-react/resize";
<NodeResizer className="outline outline-blue-500">
{RESIZE_POSITIONS.map((position) => (
<ResizeHandle
key={position}
position={position}
className={position.includes("-") ? "size-2 bg-blue-500" : "data-[position=left]:w-1 data-[position=right]:w-1 data-[position=top]:h-1 data-[position=bottom]:h-1"}
/>
))}
</NodeResizer>;Its own direction, and a line
A handle's direction ("horizontal", "vertical") overrides its resizer's for that handle: a
press or an arrow key on it moves only the width (and x), or only the height (and y). It carries
data-direction, read when the press or the key starts. Without it, the handle follows its
NodeResizer's direction, as before.
variant="line" marks a side's handle as a line: data-variant="line", for your styles (a thin
bar along the whole side, a resize cursor). The structural style is the same as a handle's; the
look is yours. A corner is always data-variant="handle": its "line" is ignored.
Here a card grows freely from its corner, while its right and bottom sides are thin lines that each move one dimension:
import { NodeResizer, ResizeHandle } from "@fragiola/flow-react/resize";
<NodeResizer>
<ResizeHandle position="bottom-right" aria-label="Resize card" className="size-2.5 bg-palette-ring" />
<ResizeHandle
position="right"
variant="line"
direction="horizontal"
aria-label="Resize card: width"
className="w-px cursor-ew-resize bg-palette-ring data-[variant=line]:w-0.5"
/>
<ResizeHandle
position="bottom"
variant="line"
direction="vertical"
aria-label="Resize card: height"
className="h-px cursor-ns-resize bg-palette-ring data-[variant=line]:h-0.5"
/>
</NodeResizer>;Props
ResizeHandleProps extends the common primitive props and
every div attribute.
| prop | type | default | description |
|---|---|---|---|
position | ResizePosition | required | the corner or side it moves |
nodeId | string | the enclosing Flow.Node's | the node its state names (the node a press resizes is the one it is rendered in) |
direction | ResizeHandleDirection | its resizer's | the sides it moves, over its resizer's direction: "horizontal" only the width (and x), "vertical" only the height (and y) (data-direction) |
variant | ResizeHandleVariant | "handle" | how it is drawn, for your styles (data-variant): "handle" or "line", a side's whole length; a corner's "line" is ignored |
children | ReactNode | none | its content |
State
ResizeHandleState, what className, style and render receive:
| field | type | description |
|---|---|---|
nodeId | string | its node |
position | ResizePosition | its corner or side |
direction | ResizeHandleDirection | undefined | its own direction; none: its resizer's |
variant | ResizeHandleVariant | how it is drawn: a corner is always "handle" |
Data attributes
| attribute | value |
|---|---|
data-flow-part | "resize-handle" |
data-position | its ResizePosition |
data-variant | "handle" or "line" (a side's only) |
data-direction | its own direction, when it has one |
tabindex | "0" with keyboard() installed |
Structural style
position: absolute; pointer-events: auto and its place: a corner at its corner,
translate(-50%, -50%) and z-index: 1; a side along its side, 100% long, centred on it.