Reorder variants (Beta)

component.reorderVariants(variantIds)

Reorders the variants of a component by specifying the desired order as an array of variant IDs.

Beta

These methods are in public beta and may change with future releases.

Syntax

1component.reorderVariants(variantIds: string[]): Promise<void>

Parameters

  • variantIds: string[] — An array of variant IDs in the desired order. Pass 'base' to refer to the base variant. For a partial reorder, include only the variants to reposition. Remaining variants shift to follow the last repositioned variant.

Returns

Promise<void>

A Promise that resolves when the reorder is complete.

Examples

Fully reorder all variants:

1const component = await webflow.getCurrentComponent()
2
3if (component) {
4 await component.reorderVariants(['base', 'variant-2', 'variant-1', 'variant-3'])
5}

Partially reorder variants:

1const component = await webflow.getCurrentComponent()
2
3if (component) {
4 // Before: base, variant-1, variant-2, variant-3
5 await component.reorderVariants(['variant-1', 'variant-3'])
6 // After: base, variant-1, variant-3, variant-2
7}

Designer Ability

Designer AbilityPermissionLocaleBranchWorkflowSitemode
canModifyComponentsanyanyanyCanvasDesign