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.
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:
- Navigate to canva.com/button/build.
- Enter your API key for the Canva Button.
- 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.
- Select a button size.
- Select a button style.
- Click Get my button.
The generated code looks like this:
<buttondata-design-type="Poster"data-api-key="API KEY GOES HERE"class="canva-design-button"style="display: none;">Design with Canva</button><script>(function (c, a, n) {var w = c.createElement(a),s = c.getElementsByTagName(a)[0];w.src = n;s.parentNode.insertBefore(w, s);})(document, "script", "https://sdk.canva.com/designbutton/v2/api.js");</script>
Copy the code into the part of the web page where you want to display the Canva Button.
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.
Example
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Canva Button</title></head><body><buttondata-design-type="Poster"data-api-key="API KEY GOES HERE"class="canva-design-button"style="display: none;">Design with Canva</button><script>(function (c, a, n) {var w = c.createElement(a),s = c.getElementsByTagName(a)[0];w.src = n;s.parentNode.insertBefore(w, s);})(document, "script", "https://sdk.canva.com/designbutton/v2/api.js");</script></body></html>