ThumbnailList
API reference for the "ThumbnailList" control.
Renders a list of thumbnails within the Canva UI.
To learn how controls work, refer to Rich controls.

Usage

1
canva.create("thumbnail_list", {
2
id: "thumbnailListExample",
3
selectedThumbnailId: "beach",
4
items: [
5
{
6
thumbnailId: "beach",
7
label: "Beach",
8
src: "https://picsum.photos/id/100/256/256",
9
},
10
{
11
thumbnailId: "bird",
12
label: "Bird",
13
src: "https://picsum.photos/id/50/256/256",
14
},
15
{
16
thumbnailId: "trees",
17
label: "Trees",
18
src: "https://picsum.photos/id/10/256/256",
19
},
20
],
21
});
Copied!

Parameters

Name
Type
Required
Description
controlType
string
Yes
The type of control. To create a thumbnail list, the value must be "thumbnail_list".
opts
object
Yes
Properties for configuring the control.
opts.id
string
Yes
A unique ID for the control.
opts.items
Yes
The thumbnails to display in the list of thumbnails.
opts.disabled
boolean
No
If true, the user can't interact with the control.
opts.selectedThumbnailId
string
No
The ID of the selected thumbnail.

Event

Name
Type
Required
Description
opts
object
Yes
Information about the event.
opts.message
object
Yes
Information about the event.
opts.message.commit
boolean
Yes
The value of this property is always true.
opts.message.controlId
string
Yes
The id of the control.
opts.message.controlType
string
Yes
The type of control. The value of this property is always "thumbnail_list".
opts.message.message
object
Yes
Additional information about the event.
opts.message.message.type
string
Yes
The type of event. The value of this property is always "selected".
opts.message.message.thumbnailId
string
Yes
The ID of the selected thumbnail.

Types

Item

Represents an individual thumbnail in a list of thumbnails.
Properties
Name
Type
Required
Description
thumbnailId
string
Yes
A unique ID for the thumbnail.
label
string
Yes
A human readable label that appears beneath the thumbnail.
src
string
Yes
The URL or Data URI of an image.

Example

1
const canva = window.canva.init();
2
3
const state = {
4
thumbnailListExample: "beach",
5
};
6
7
canva.onReady(() => {
8
renderControls();
9
});
10
11
canva.onControlsEvent(async (opts) => {
12
if (opts.message.commit) {
13
return;
14
}
15
16
if (opts.message.controlType === "thumbnail_list") {
17
state[opts.message.controlId] = opts.message.message.thumbnailId;
18
}
19
20
renderControls();
21
});
22
23
function renderControls() {
24
const controls = [
25
canva.create("thumbnail_list", {
26
id: "thumbnailListExample",
27
selectedThumbnailId: state.thumbnailListExample,
28
items: [
29
{
30
thumbnailId: "beach",
31
label: "Beach",
32
src: "https://picsum.photos/id/100/256/256",
33
},
34
{
35
thumbnailId: "bird",
36
label: "Bird",
37
src: "https://picsum.photos/id/50/256/256",
38
},
39
{
40
thumbnailId: "trees",
41
label: "Trees",
42
src: "https://picsum.photos/id/10/256/256",
43
},
44
],
45
}),
46
];
47
48
canva.updateControlPanel(controls);
49
}
Copied!
Last modified 3d ago