> 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.

# Set variant settings (Beta)

> Updates the settings of a variant

## `component.setVariant(variantId, settings)`

## `component.setVariant(settings)`

Updates the settings of a variant.

> **Note**
>
> Currently only changing the name of a variant is supported.

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

### Syntax

To update a variant by passing its ID and settings as separate arguments:

```typescript
component.setVariant(variantId: string, settings: { name: string }): Promise<Variant>
```

To update a variant by passing a single options object:

```typescript
component.setVariant(options: SetVariantOptions): Promise<Variant>
```

Related interface:

```typescript
interface SetVariantOptions {
  id: string;
  name: string;
}
```

### Parameters

**Two-argument form:**

* **`variantId`**: *string* — The ID of the variant to update.
  Pass `'base'` to update the base variant.
* **`settings`**: *object* — An object specifying the settings to update:
  * **`name`**: *string* — The new name for the variant.

**Options object form:**

* **`options`**: *SetVariantOptions* — An object specifying the variant to update and its new settings:
  * **`id`**: *string* — The ID of the variant to update.
    Pass `'base'` to update the base variant.
  * **`name`**: *string* — The new name for the variant.

### Returns

**Promise\<*Variant*>**

A Promise that resolves to the updated `Variant` object.

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

### Examples

Update a variant using the two-argument form:

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

if (component) {
  const variant = await component.setVariant('variant-123', { name: 'Primary Hero' })
  console.log(variant)
  /*
  {
    id: 'variant-123',
    name: 'Primary Hero',
    isSelected: true,
  }
  */
}
```

Update a variant using the options object form:

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

if (component) {
  const variant = await component.setVariant({
    id: 'variant-123',
    name: 'Primary Hero',
  })
  console.log(variant)
  /*
  {
    id: 'variant-123',
    name: 'Primary Hero',
    isSelected: true,
  }
  */
}
```

Rename the base variant:

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

if (component) {
  const base = await component.setVariant('base', { name: 'Default' })
  console.log(base.name) // 'Default'
}
```

Name conflicts auto-increment:

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

if (component) {
  // 'Primary Hero' already exists
  const variant = await component.setVariant('variant-456', { name: 'Primary Hero' })
  console.log(variant.name) // 'Primary Hero 2'
}
```

[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   |