Opens a dialog that allows the user to select from a list of fonts.
To learn more, see Creating text.
Usage
import { requestFontSelection } from "@canva/asset";const fontResponse = await requestFontSelection();console.log(fontResponse.font.name); // => "Arial"
Parameters
A unique identifier that references a font asset in Canva's backend. If this is set, the specified font will be selected when the font picker opens. To learn more, see Creating text.
Returns
A Promise
that resolves with an object.
If the user selects a font, the following object is returned:
The result of selecting a font.
The type of result. If the user selects a font, this is always "COMPLETED"
.
The selected font.
A unique identifier that references a font in Canva's backend.
The name of the font.
An array of font weights that the font is available in.
An individual font weight.
The name of the font weight.
The possible values depend on the font, but may be any combination of the following values:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
The styles the font weight is available in.
The possible values depend on the font, but may be any combination of the following values:
"normal"
"italic"
The URL of an image that contains a preview of the font.
If the user closes the font picker without selecting a font, the following object is returned: