> This page is for Designer API.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.webflow.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.webflow.com/_mcp/server.

# Create a variant (Beta)

> Creates a new variant of a component

## `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

```typescript
interface CreateVariantOptions {
  /** The name for the new variant (required) */
  name: string;
  /** Whether to select this variant after creation (optional, defaults to false) */
  isSelected?: boolean;
}
```

To create a variant, pass the options for the variant, including its name and whether to select it automatically:

```typescript
component.createVariant(options: CreateVariantOptions): Promise<Variant>
```

To duplicate an existing variant, add the ID of the variant to duplicate as the second parameter:

```typescript
component.createVariant(options: CreateVariantOptions, sourceVariantId: string): Promise<Variant>
```

### 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 to `false`.

* **`sourceVariantId`**: *string* — The ID of the variant to duplicate.

### Returns

**Promise\<*Variant*>**

A Promise that resolves to the newly created `Variant` object.

| Property     | Type      | Description                                                   |
| :----------- | :-------- | :------------------------------------------------------------ |
| `id`         | `string`  | The unique identifier of the new variant.                     |
| `name`       | `string`  | The name of the new variant (may differ if auto-incremented). |
| `isSelected` | `boolean` | Whether this variant is currently selected in the Designer.   |

### Example

Create a variant:

```typescript
const component = await webflow.getCurrentComponent()

if (component) {
  // Create a variant and select it immediately
  const variant = await component.createVariant({
    name: 'Secondary Hero',
    isSelected: true,
  })
  console.log(variant)
  // { id: 'variant-123', name: 'Secondary Hero', isSelected: true }

  // Name conflicts auto-increment
  const variant2 = await component.createVariant({ name: 'Secondary Hero' })
  console.log(variant2.name) // 'Secondary Hero 2'
}

// Name auto-increments on conflict
const variant2 = await component.createVariant({ name: 'Secondary Hero' });
console.log(variant2.name); // 'Secondary Hero 2'
```

Duplicate a variant:

```typescript
const component = await webflow.getCurrentComponent()

if (component) {
  // Get the selected variant or the base variant as default
  const selectedVariant = await component.getSelectedVariant()

  // Duplicate the selected variant
  const duplicateVariant = await component.createVariant({
    name: 'Duplicate of Secondary Hero',
    isSelected: true,
  }, selectedVariant.id)
  console.log(duplicateVariant.name) // 'Duplicate of Secondary Hero'
}
```

[Try this example](https://webflow.com/oauth/authorize?response_type=code\&client_id=19511de1ec410f9228d8dcbc9420e67916dea80d86d18f0c9a533eb475ea0f62)

### Designer Ability

| Designer Ability        | Permission | Locale | Branch | Workflow | Sitemode |
| :---------------------- | :--------- | :----- | :----- | :------- | :------- |
| **canModifyComponents** | any        | any    | any    | Canvas   | Design   |