selectFont()

Opens a font picker panel in the editor, prompting the user to select a font. This function is intended for use in the settings panel of a site widget or plugin implemented with a custom element.

Syntax

Copy
function selectFont(value: FontPickerValue, options: { onChange: (value: FontPickerValue) => void }): Promise<FontPickerValue>

Parameters

NameTypeDescription
valueFontPickerValueOptional. Value of the associated font and text-decoration CSS shorthand properties.
optionsSelectFontOptionsOptional. Options to use when opening the font picker panel.

FontPickerValue object

Copy
{ font: string; textDecoration: string; }
NameTypeDescription
fontstringValue of the associated font CSS shorthand property, which can include the following:
  • Font family
  • Font size
  • Font weight
  • Font style. Supports italic only.
textDecorationstringOptional. Value of the associated text-decoration CSS shorthand property. Can also be undefined.

SelectFontOptions object

Copy
{ onChange: (value: FontPickerValue) => void }
NameTypeDescription
onChangeFunctionOptional. Callback function invoked when the font selection changes. It receives the updated FontPickerValue as a parameter.

Returns

Promise<FontPickerValue>

The font selected by the user.

Example

Copy
import { editor, inputs } from "@wix/editor"; import { createClient } from "@wix/sdk"; const client = createClient({ host: editor.host(), modules: { inputs }, }); async function selectFont(font) { const response = await client.inputs.selectFont(font, { onChange: (value) => { console.log("New font: ", value); }, }); }
Did this help?