addNativeElement

API reference for the addNativeElement method.

Adds a native element to a user's design.

import { getDesignInteraction } from "@canva/design-interaction";
const designInteraction = getDesignInteraction();
designInteraction.addNativeElement({
type: "TEXT",
children: ["Hello world"],
});

The expected parameters depend on the type of element being added to the design:

  • Embeds
  • Groups
  • Images
  • Shapes
  • Text
  • Videos

To add an embed element to the user's design, set the following parameters:

#typestring
Required

The type of the element to add to the design. For an embed element, this must be "EMBED".

#urlstring
Required

The URL of the embed. This URL must be supported by the Iframely API. To learn more, see What URLs to send to Iframely.

#widthnumber
Required

The width of the element, in pixels.

#heightnumber
Required

The height of the element, in pixels.

#topnumber
Required

The distance from the top edge of the user's design, in pixels.

#leftnumber
Required

The distance from the left edge of the user's design, in pixels.

#rotationnumber
Optional

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

void