Skip to content

Shape ​

Low-level geometry primitive resolved into an internal SVG fragment before layout.

No children allowed.

Props ​

PropTypeRequiredDescription
geometryGeometryDocEitherInline geometry document
geometryIdstringEitherEngine registry key for a preloaded geometry
widthnumberYesDisplay width in px
heightnumberYesDisplay height in px
fillstringDefault fill applied to emitted geometry
strokestringDefault stroke applied to emitted geometry
strokeWidthnumberStroke width
fillRule"nonzero" | "evenodd"Default fill rule
strokeLinecap"butt" | "round" | "square"Stroke line cap
strokeLinejoin"miter" | "round" | "bevel"Stroke line join
strokeDasharraystringStroke dash pattern
strokeMiterlimitnumberStroke miter limit
preserveAspectRatio"none" | "meet" | "slice"How to fit the geometry into the display box
opacitynumberOpacity (0–1)
zIndexnumberSibling-local paint order (integer; higher paints later)
metaRecord<string, string>Metadata emitted as data-boundsvg-meta-* attributes and into the layered manifest (max 16 keys, [a-z][a-z0-9-]{0,31} keys, 256-char values)
emitPartIdsbooleanEmit one path per addressable geometry part tagged with data-boundsvg-part-id (opt-in; overlapping parts paint separately)
transformTransform2DStatic post-layout paint transform
animateAnimationSpecDeclarative opacity/transform track; see Animation
marginnumber | [number, number, number, number]Margin
partPaintRecord<string, PartPaintOverride>Per-part fill/stroke overrides keyed by part id. Splits the geometry into parts on its own; emitPartIds is only needed to also emit the data-boundsvg-part-id attributes
layerstringLayer id for Layered Export. Always rendered as an atomic island

Also accepts the same positioning, flex item, grid item, event, and id props as Svg.

Example ​

tsx
import { Canvas, Shape, type GeometryDoc } from "@boundsvg/core";

const badge: GeometryDoc = {
  viewBox: { width: 140, height: 64 },
  root: {
    kind: "path",
    d: "M12 0H128C134.627 0 140 5.373 140 12V52C140 58.627 134.627 64 128 64H12C5.373 64 0 58.627 0 52V12C0 5.373 5.373 0 12 0Z",
  },
};

<Canvas width={220} height={120} background="#0f172a">
  <Shape geometry={badge} width={180} height={82} fill="#38bdf8" />
</Canvas>;
shape-basic example
Generated SVG
xml
<svg xmlns="http://www.w3.org/2000/svg" data-boundsvg-node-id="auto:0" viewBox="0 0 220 120" width="220" height="120">
  <rect x="0" y="0" width="220" height="120" fill="#0f172a"/>
  <g data-boundsvg-node-id="auto:0.0">
    <svg data-boundsvg-node-id="auto:0.0" x="0" y="0" width="180" height="82" overflow="hidden">
      <path d="M15.43,0L164.57,0C173.09,0 180,6.88 180,15.38L180,66.63C180,75.12 173.09,82 164.57,82L15.43,82C6.91,82 0,75.12 0,66.63L0,15.38C0,6.88 6.91,0 15.43,0Z" fill="#38bdf8"/>
    </svg>
  </g>
</svg>