Skip to content

Rect

The <Rect> primitive renders an SVG rectangle. It supports rounded corners, fill, stroke, and dashed outlines — useful for bounding boxes, containers, highlights, and background regions.

0.00s / 2.97s · F0
PropTypeDefaultDescription
xnumber0X coordinate of the top-left corner
ynumber0Y coordinate of the top-left corner
widthnumber0Width of the rectangle
heightnumber0Height of the rectangle
fillstring'none'Fill color
strokestring'currentColor'Stroke color
strokeWidthnumber1Width of the stroke
rxnumber0Corner radius for rounded rectangles
strokeDasharraystringundefinedDash pattern (e.g. "6 3")
opacitynumber1Opacity from 0 to 1
elements: {
card: {
id: 'card',
type: 'rect',
props: { type: 'rect', x: 50, y: 50, width: 180, height: 100, stroke: '$accent', strokeWidth: 2, fill: 'rgba(108,92,231,0.15)', rx: 8 },
},
outline: {
id: 'outline',
type: 'rect',
props: { type: 'rect', x: 280, y: 80, width: 120, height: 120, stroke: '$secondary', strokeWidth: 2, fill: 'none' },
},
}