For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Resources
Get started
ReferenceGuidesExamplesChangelog
ReferenceGuidesExamplesChangelog
  • Designer API
    • Introduction
    • Getting Started
    • Webflow CLI
    • Error Handling
    • App Modes
  • Elements
    • Creating & Retrieving Elements
    • Element Properties & Methods
    • Element Types & Methods
  • Styles
    • Managing Style Properties
    • Managing Variable Modes
  • Components
      • Get all components
      • Get component by name
      • Get component by ID
      • Search for components
      • Get the selected component
      • Get all variants of a component
      • Get selected variant
      • Get a variant by ID
      • Create a variant
      • Set variant settings
      • Reorder variants
      • Delete a variant
      • Get component instance count
      • Create a component
      • Delete a component
  • Variables & Collections
    • Variable Collections
    • Variables
    • Variable Modes
  • Assets
  • Pages & Folders
  • Utilities
    • User Events & Notifications
    • App Intents & Connections
  • Additional Resources
    • API Playground
    • FAQs
LogoLogo
Resources
Get started
On this page
  • component.getVariant(variantId)
  • Syntax
  • Parameters
  • Returns
  • Example
  • Designer Ability
ComponentsCreating & Retrieving Components

Get a variant by ID (Beta)

Was this page helpful?
Previous

Create a variant (Beta)

Next
Built with

component.getVariant(variantId)

Retrieves a component variant by its ID.

Beta

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

Syntax

1component.getVariant(variantId: string): Promise<Variant>

Parameters

  • variantId: string — The ID of the variant to retrieve. Pass 'base' to retrieve the base variant.

Returns

Promise<Variant>

A Promise that resolves to the Variant object with the given ID.

PropertyTypeDescription
idstringThe unique identifier of the variant.
namestringThe name of the variant.
isSelectedbooleanWhether this variant is currently selected in the Designer.

Example

1const component = await webflow.getCurrentComponent()
2
3if (component) {
4 // Get a specific variant by ID
5 const variant = await component.getVariant('variant-123')
6 console.log(variant)
7 /*
8 {
9 id: 'variant-123',
10 name: 'Secondary Hero',
11 isSelected: true,
12 }
13 */
14
15 // Get the base variant
16 const base = await component.getVariant('base')
17 console.log(base)
18 /*
19 {
20 id: 'base',
21 name: 'Primary',
22 isSelected: false,
23 }
24 */
25}

Try this example

Designer Ability

Checks for authorization only

Designer AbilityPermissionLocaleBranchWorkflowSitemode
canAccessCanvasanyanyanyanyany