Import
import { DraggableText } from "../components/DraggableText";
Usage
Basic usage
<DraggableText>Drag me into the design</DraggableText>
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.
<DraggableTextstyle={{fontStyle: "italic",fontWeight: "bold",textAlign: "center",textDecoration: "underline",}}>Drag me into the design</DraggableText>
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 properties that are distinct from the style
prop.
<DraggableTextstyle={{fontStyle: "italic",fontWeight: "bold",textAlign: "center",textDecoration: "underline",}}decoration="none"fontStyle="normal"fontWeight="normal"textAlign="end">Drag me into the design</DraggableText>
Props
The text to render within the app's user interface. This is also the text that's added to the user's design at the end of a drag event.
Type
string
The decoration of the text. The default value is "none"
.
Type
'none' | 'underline'
The style of the text. The default value is "normal"
.
Type
'normal' | 'italic'
The weight of the text. The default value is "normal"
.
Type
'normal' | 'bold'
The alignment of the text. The default value is "start"
.
Type
'start' | 'center' | 'end'