Skip to content

Flex ​

Flexbox layout container.

Props ​

Container ​

PropTypeDefaultDescription
direction"row" | "column""column"Main axis direction
wrap"nowrap" | "wrap""nowrap"Line wrapping
alignItems"start" | "center" | "end" | "stretch""stretch"Cross-axis alignment
justifyContent"start" | "center" | "end" | "space-between" | "space-around""start"Main-axis alignment
gapnumber—Gap between items in px (sets both row-gap and column-gap)
rowGapnumber—Row gap in px (overrides gap)
columnGapnumber—Column gap in px (overrides gap)

With overflow="clip", child paint is clipped to the Flex layout box using the same resolved borderRadius as its background. With overflow="visible", rounded backgrounds and borders do not clip children.

The clipping boundary also cuts the Flex's own border and shadow at its rounded corners.

That explicit clip also excludes pointer hits on the Flex and its descendants outside its rectangle or resolved rounded corners. With overflow="visible", the background radius does not clip child paint or hits.

Flex Item (when Flex is a child of another Flex) ​

PropTypeDefaultDescription
flexGrownumber0Flex grow factor
flexShrinknumber1Flex shrink factor
flexBasisnumber | "auto""auto"Flex basis in px or "auto"
alignSelf"auto" | "start" | "center" | "end" | "stretch""auto"Self alignment override

Grid Item (when Flex is a child of Grid) ​

PropTypeDescription
gridColumnstringGrid column placement (e.g. "1 / 3")
gridRowstringGrid row placement (e.g. "1 / 2")

Also accepts common box props (width, height, minWidth, maxWidth, minHeight, maxHeight, aspectRatio, padding, margin, background, boxShadow, border*, stroke*, strokeScaling, overflow, opacity, zIndex, meta, transform, animate, position, top, right, bottom, left). strokeScaling?: "transform" | "canvas" controls whether a solid border scales with post-layout transforms or keeps its canvas-space width; the default is "transform". animate?: AnimationSpec attaches a declarative opacity/transform track; see Animation.

Event / Identity ​

PropTypeDescription
onClickstringClick handler reference
onDoubleClickstringDouble-click handler reference
onContextMenustringContext menu handler reference
onPointerMovestringPointer move handler reference
onPointerEnterstringPointer enter handler reference
onPointerLeavestringPointer leave handler reference
idstringStable NodeId for hit-testing
layerstringLayer id for Layered Export

All 21 event handler props are supported. See Event Handlers for the full list.

Example ​

Row Layout ​

tsx
<Canvas width={400} height={120} background="#0f172a">
  <Flex
    direction="row"
    gap={16}
    alignItems="center"
    width={400}
    height={120}
    padding={16}
  >
    <Box width={80} height={80} background="#3b82f6" borderRadius={8} />
    <Box width={80} height={80} background="#8b5cf6" borderRadius={8} />
    <Box width={80} height={80} background="#ec4899" borderRadius={8} />
  </Flex>
</Canvas>
flex-row example
Generated SVG
xml
<svg xmlns="http://www.w3.org/2000/svg" data-boundsvg-node-id="auto:0" viewBox="0 0 400 120" width="400" height="120">
  <rect x="0" y="0" width="400" height="120" fill="#0f172a"/>
  <g data-boundsvg-node-id="auto:0.0">
    <g data-boundsvg-node-id="auto:0.0.0">
      <rect x="16" y="20" width="80" height="80" rx="8" ry="8" fill="#3b82f6"/>
    </g>
    <g data-boundsvg-node-id="auto:0.0.1">
      <rect x="112" y="20" width="80" height="80" rx="8" ry="8" fill="#8b5cf6"/>
    </g>
    <g data-boundsvg-node-id="auto:0.0.2">
      <rect x="208" y="20" width="80" height="80" rx="8" ry="8" fill="#ec4899"/>
    </g>
  </g>
</svg>

Space Between ​

tsx
<Canvas width={400} height={100} background="#0f172a">
  <Flex
    direction="row"
    justifyContent="space-between"
    alignItems="center"
    width={400}
    height={100}
    padding={16}
  >
    <Box width={60} height={60} background="#3b82f6" borderRadius={8} />
    <Box width={60} height={60} background="#8b5cf6" borderRadius={8} />
    <Box width={60} height={60} background="#ec4899" borderRadius={8} />
  </Flex>
</Canvas>
flex-space-between example
Generated SVG
xml
<svg xmlns="http://www.w3.org/2000/svg" data-boundsvg-node-id="auto:0" viewBox="0 0 400 100" width="400" height="100">
  <rect x="0" y="0" width="400" height="100" fill="#0f172a"/>
  <g data-boundsvg-node-id="auto:0.0">
    <g data-boundsvg-node-id="auto:0.0.0">
      <rect x="16" y="20" width="60" height="60" rx="8" ry="8" fill="#3b82f6"/>
    </g>
    <g data-boundsvg-node-id="auto:0.0.1">
      <rect x="170" y="20" width="60" height="60" rx="8" ry="8" fill="#8b5cf6"/>
    </g>
    <g data-boundsvg-node-id="auto:0.0.2">
      <rect x="324" y="20" width="60" height="60" rx="8" ry="8" fill="#ec4899"/>
    </g>
  </g>
</svg>