On September 25th, 2024, we released v2 of the Apps SDK. To learn what’s new and how to upgrade, see Migration FAQ and Migration guide.

DraggableText

API reference for the DraggableText component.

The DraggableText component has been deprecated. Instead, use the TypographyCard component.

Usage

Basic usage

import React from "react";
import { DraggableText } from "components/draggable_text";
export function App() {
return <DraggableText>Drag me into the design</DraggableText>;
}
TSX

Styling the text

You can use the style prop to style the text in the app's iframe. Where possible, Canva will use these styles to determine the style of the text that's dropped into the design.

import React from "react";
import { DraggableText } from "components/draggable_text";
export function App() {
return (
<DraggableText
style={{
fontStyle: "italic",
fontWeight: "bold",
textAlign: "center",
textDecoration: "underline",
}}
>
Drag me into the design
</DraggableText>
);
}
TSX

Customizing the drag data

If you want the text that's dropped into the design to look different from the text that's in the app's iframe, set props that are distinct from the style prop.

import React from "react";
import { DraggableText } from "components/draggable_text";
export function App() {
return (
<DraggableText
style={{
fontStyle: "italic",
fontWeight: "bold",
textAlign: "center",
textDecoration: "underline",
}}
decoration="none"
fontStyle="normal"
fontWeight="normal"
textAlign="end"
>
Drag me into the design
</DraggableText>
);
}
TSX

Props

childrenstring
REQUIRED

The text to make draggable.

decorationstring
OPTIONAL

The decoration of the text.

The available values include:

  • "none"
  • "underline"

The default value is "none".

fontStylestring
OPTIONAL

The style of the text.

The available values include:

  • "normal"
  • "italic"

The default value is "normal".

fontWeightstring
OPTIONAL

The weight of the text.

The available values include:

  • "normal"
  • "bold"

The default value is "normal".

stylestring
OPTIONAL

The style of the text.

The available values include:

  • "none"
  • "italic"

The default value is "none".

textAlignstring
OPTIONAL

The alignment of the text.

The available values include:

  • "start"
  • "center"
  • "end"

The default value is "start".