Text elements

What are text elements? How do I create them?

A text element is a type of element that renders a string of characters. Apps can use the Design Interaction capability to add text elements to a user's design.

Creating text elements

There are two ways to add a text element to a design:

  • As a native element
  • As part of an app element

The following snippet demonstrates how to add a text element to a design as a native element:

import React from "react";
import { getDesignInteraction } from "@canva/design-interaction";
export const App = () => {
const designInteraction = getDesignInteraction();
const handleClick = () => {
designInteraction.addNativeElement({
type: "TEXT",
children: ["Hello world"],
});
};
return (
<div>
<button onClick={handleClick}>Add text element</button>
</div>
);
};

To learn more, see Creating native elements.

Limitations

  • Apps can't set the font family of text elements
  • Apps can't set the line spacing of text elements
  • Apps can't create text elements with multiple paragraphs
  • Apps can't create text elements with a vertical writing mode
  • Text elements can't have a predefined height.