Get variable mode breakpoint

mode.getBreakpoint()

Get the breakpoint that drives a variable mode. Automatic modes return their BreakpointId. Manual modes return null.

Syntax

1mode.getBreakpoint(): Promise<BreakpointId | null>

Returns

Promise<BreakpointId | null>: "xxl" | "xl" | "large" | "main" | "medium" | "small" | "tiny"

A Promise that resolves to the BreakpointId for an automatic mode, or null for a manual mode.

Example

1// Get Collection
2const collection = await webflow.getDefaultVariableCollection()
3
4// Get Variable Mode
5const variableMode = await collection?.getVariableModeByName(modeName)
6
7try {
8 // Get the breakpoint that drives the mode
9 const breakpointId = await variableMode?.getBreakpoint()
10
11 if (breakpointId != null) {
12 console.log(`Automatic mode driven by the "${breakpointId}" breakpoint`)
13 } else {
14 console.log("Manual mode")
15 }
16} catch (err) {
17 if (err.cause?.tag === "VariableModeInvalid") {
18 // The mode no longer exists or has been removed
19 console.warn(err.message)
20 } else {
21 throw err
22 }
23}

A getBreakpoint call rejects with a VariableModeInvalid error when the mode no longer exists or has been removed (Variable mode with id "X" not found).

Catch this error to recover gracefully and surface the message to the user.

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canReadVariablesAnyAnyAnyAny