height (required) | number | | Height of the shape. |
shapeId (required) | string | | Unique identifier for the shape, to aid in data handling. |
width (required) | number | | Width of the shape. |
x (required) | number | | x-axis offset of the shape. |
y (required) | number | | y-axis offset of the shape. |
onChange | func | ()=>{} | Listener for transformation of this shape triggered by interactions with resize handles, panning, or keyboard shortcuts. Required for user-triggered shape transformations to work. Signature: (newRect: { x: number, y: number, height: number, width: number }, WrappedShapeProps: object) => void |
onDelete | func | ()=>{} | Listener for the deletion of this shape via backspace or delete keys. Required for user-triggered shape deletion to work. Signature: (event: Event, WrappedShapeProps: object) => void |
active | bool | false | If true , the shape is rendered as focused (particularly important when using a SelectionLayer ). When not using a selection layer, this prop can be left unset, as native HTML focus will handle focus state. |
constrainMove | func | non-constraining function | A callback for restricting movement during shape transformations (e.g., to lock movement to one axis, keeping the shape inside a predefined boundary or snapping it to a grid). Signature: ({ originalX: number, originalY: number, x: number, y: number, width: number, height: number }) => ({ x: number, y: number }) |
constrainResize | func | non-constraining function | A callback for restricting resizing during shape transformations (e.g., to lock resizing to one axis, keeping the shape inside a predefined boundary or snapping it to a grid). Signature: ({ originalMovingCorner: { x: number, y: number }, startCorner: { x: number, y: number }, movingCorner: { x: number, y: number }, lockedDimension: one of "x" or "y" }) => ({ x: number, y: number }) |
disabled | bool | false | If true , the shape cannot be moved or resized, and shows no resize handles. |
isInSelectionGroup | bool | false | Whether or not the shape is in a group of two or more selected shapes (when using the SelectionLayer component). Prop is merely forwarded to the wrapped component to be used in customized rendering, e.g., hiding the resize handles when selected in a group, or adding an outline. |
keyboardTransformMultiplier | number | 1 | Multiplier for keyboard-triggered transforms, such as ↑↓←→ keys to move or shift +↑↓←→ keys to resize. For example, with the default setting of 1 , pressing → would move the shape 1 px to the right. With a setting of 5 , it would move 5px. |
onKeyDown | func | ()=>{} | Listener for shape keydown event. If event.preventDefault() is called inside, it will override the default keyboard shortcut behavior. Signature: (event: Event, WrappedShapeProps: object) => void |
onBlur | func | ()=>{} | Listener for shape blur event. Signature: (event: Event, WrappedShapeProps: object) => void |
onFocus | func | ()=>{} | Listener for shape focus event. Signature: (event: Event, WrappedShapeProps: object) => void |
ResizeHandleComponent | Component | DefaultResizeHandleComponent | The component to use for shape handles. |
wrapperProps | object | {} | Extra props to add to the SVG <g> element wrapping the shape. |
extraShapeProps | object | {} | A way to pass props down as-is to the shape component being wrapped. |