setAppElementData

API reference for the setAppElementData method.

Creates an app element if one isn't already selected or overwrites an app element's data if one is selected.

To learn more, see Setting app element data.

import { getDesignInteraction } from "@canva/design-interaction";
const designInteraction = getDesignInteraction();
designInteraction.setAppElementData({
name: "David",
age: 32,
location: "Australia",
});
#dataobject
Required

The data to attach to the app element.

#placementobject
Optional

The dimensions and position of the app element.

#placement.widthnumber | 'auto'
Required

The width of the app element, in pixels.

If height is a number, this can be set to "auto". Otherwise, it must be an integer between 0 and 32767.

#placement.heightnumber | 'auto'
Required

The height of the app element, in pixels.

If width is a number, this can be set to "auto". Otherwise, it must be an integer between 0 and 32767.

#placement.topnumber
Required

The distance from the top edge of the user's design, in pixels. This must be an integer between -32768 and 32767.

#placement.leftnumber
Required

The distance from the left edge of the user's design, in pixels. This must be an integer between -32768 and 32767.

#placement.rotationnumber
Optional

The rotation of the element, in degrees. This must be an integer between -180 and 180.

void