Getting started
Add the Canva Button to a website with the HTML API.
The Canva Button's HTML API is the simplest way to get up and running with the Canva Button.
This tutorial explains how to create a Canva Button with the HTML API and embed it in a web page.
If you’re wondering whether the HTML API is right for you, see HTML API vs. JavaScript API.

Prerequisites

This tutorial assumes you have an API key to use the Canva Button. If you don't have one, sign up for an API key.

Step 1: Generate a Canva Button

Canva provides a tool for generating a Canva Button. You can then use HTML attributes to configure the behavior and appearance of the Button.
To generate a Canva Button:
  1. 1.
  2. 2.
    Enter your API key for the Canva Button.
  3. 3.
    Select a design type. When a user creates a design, the design type determines the dimensions of the design and the templates that Canva shows to the user. For a complete list of the supported design types, refer to Design types.
  4. 4.
    Select a button size.
  5. 5.
    Select a button style.
  6. 6.
    Click Get my button.
The generated code looks like this:
1
<button
2
data-design-type="Poster"
3
data-api-key="API KEY GOES HERE"
4
class="canva-design-button"
5
style="display: none;"
6
>Design with Canva</button
7
>
8
<script>
9
(function (c, a, n) {
10
var w = c.createElement(a),
11
s = c.getElementsByTagName(a)[0];
12
w.src = n;
13
s.parentNode.insertBefore(w, s);
14
})(document, "script", "https://sdk.canva.com/designbutton/v2/api.js");
15
</script>
Copied!
Copy the code into the part of the web page where you want to display the Canva Button.
If you're using the China version of the SDK, replace https://sdk.canva.com/designbutton/v2/api.js with https://sdk.canva.cn/designbutton/v2/api.js.
Because of domain restrictions, it's not possible to simply add the Canva Button to an HTML file on your local machine and open that file in a web browser. You need to serve the HTML file via localhost. To learn more, refer to Local development.

Step 2: Customize the Canva Button

The default Canva Button creates a new design in the Canva editor. This is neat, but the Canva Button can do so much more.
To learn about all of the Canva Button's features, refer to the guides in the sidebar.
If you want even more control over the Canva Button, consider using the JavaScript API.

Example

1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
<meta charset="UTF-8" />
5
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
<title>Canva Button</title>
7
</head>
8
<body>
9
<button
10
data-design-type="Poster"
11
data-api-key="API KEY GOES HERE"
12
class="canva-design-button"
13
style="display: none;"
14
>Design with Canva</button
15
>
16
<script>
17
(function (c, a, n) {
18
var w = c.createElement(a),
19
s = c.getElementsByTagName(a)[0];
20
w.src = n;
21
s.parentNode.insertBefore(w, s);
22
})(document, "script", "https://sdk.canva.com/designbutton/v2/api.js");
23
</script>
24
</body>
25
</html>
Copied!
Last modified 1mo ago