Get style by name or path

webflow.getStyleByName(nameOrPath)

Retrieve a Style by its name or path.

Syntax

1webflow.getStyleByName(nameOrPath: string | Array<string>): Promise<Style | null>

Parameters

  • nameOrPath: string | Array<string> - The name of the style to retrieve or the path to the style to retrieve, consisting of the name of the parent and the name of the style.

Returns

Promise<Style | null>

A Promise that resolves to a style object, or null if the named style doesn’t exist.

Examples

Getting a style by name:

1// Retrieve the style by name
2const retrievedStyle = await webflow.getStyleByName(styleName);
3
4if (retrievedStyle) {
5 // Get and print properties of the retrieved style
6 const styleProperties = await retrievedStyle.getProperties();
7 console.log("Style properties:", styleProperties);
8} else {
9 console.log(`Style ${styleName} not found.`);
10}

Getting a style by path:

1// Retrieve the style by parent name and style name
2const retrievedStyle = await webflow.getStyleByName([styleParentName, styleName]);
3
4if (retrievedStyle) {
5 // Get and print properties of the retrieved style
6 const styleProperties = await retrievedStyle.getProperties();
7 console.log("Style properties:", styleProperties);
8} else {
9 console.log(`Style ${styleName} with parent ${styleParentName} not found.`);
10}

Designer Ability

Checks for authorization only

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasAnyAnyAnyAny