Create variable mode
collection.createVariableMode(name, breakpointId)
Create a variable mode in a collection.
Variable modes can be created as one of two types:
- Manual modes are applied manually to elements or pages. Omit the
breakpointIdparameter, or passnull, to create a manual mode. - Automatic modes are driven by a breakpoint and apply automatically at the matching screen size. Pass a
BreakpointIdto create an automatic mode.
Syntax
Parameters
- name: string - The name of the variable mode to create.
- breakpointId: BreakpointId | null (optional) - The breakpoint that drives the mode automatically:
"xxl" | "xl" | "large" | "main" | "medium" | "small" | "tiny". Omit or passnullto create a manual mode.
Returns
Promise<VariableMode>
A Promise that resolves to a VariableMode object.
Example
Each breakpoint can drive only one automatic mode per collection, including the implicit base mode. The breakpoint must also be enabled on the site. Binding to a breakpoint that’s already in use, not enabled, or invalid rejects with a VariableModeInvalid error. See Set variable mode breakpoint for details on handling these errors.