Create a variant (Beta)
Create a variant (Beta)
component.createVariant(options)
component.createVariant(options, sourceVariantId)
Creates a variant of an existing component or duplicates an existing variant.
If a variant with the given name already exists, the name is automatically incremented (for example, 'Variant' becomes 'Variant 2').
Beta
These methods are in public beta and may change with future releases.
Syntax
To create a variant, pass the options for the variant, including its name and whether to select it automatically:
To duplicate an existing variant, add the ID of the variant to duplicate as the second parameter:
Parameters
-
options: CreateVariantOptions — An object specifying the new variant’s settings:name: string — The name for the new variant.isSelected: Boolean — (optional) Whether to select this variant immediately after creation. Defaults tofalse.
-
sourceVariantId: string — The ID of the variant to duplicate.
Returns
Promise<Variant>
A Promise that resolves to the newly created Variant object.
Example
Create a variant:
Duplicate a variant: