selection.setContent

API reference for the selection.setContent method.

Updates the content of one or more selected elements.

To learn more, see Transforming elements.

import { selection } from "@canva/preview/design";
(async () => {
await selection.setContent("<SELECTION_EVENT>", async (state) => {
return state;
});
})();

This method has a rate limit of 20 requests every 10 seconds.

#eventobject
Required

A selection event.

#applierfunction
Required

A function that transforms the element(s) in a selection event.

Promise<void>