Skip to main content
Question

Get CodeConnect to read variable modes.

  • August 19, 2025
  • 4 replies
  • 227 views

gmwilliamson

To reduce component weight, my design system team has been exploring using variable modes to toggle between different “variants” of a component, rather than just using variants. The benefit of this is that for these “style” specific properties, where just styles are changed like fill and stroke, using modes significantly reduces the weight of a component in the system. In this example I use a Badge component, and variables to change between the colors of the badge.

However, my component code still has a “color” prop. Because I don’t have a color prop on my Figma component, but rather a “BadgeColor” mode that controls this property, is there a way in which CodeConnect can still map this to the correct code property? Currently it doesn’t seem like CodeConnect can read anything that is not a property. Realistically all I need is the CodeConnect to be able to read the string value of the mode, and map that to the actual code prop.

4 replies

David_Cortizo1

I’m also running into this issue.
 

When using code connect with storybook, I can't get the variable modes from my component to map to code props.

With the introduction of variables and variable modes I've been reducing the amount of variants that each component has. The less component variants the better for file memory when using those in another file. But now I can't map the variable modes to the storybook component code props.

Please add variable modes to be able to connect to a component prop via code-connect.

It seems counter productive to take advantage of the variables and variable modes to build better components because then I can't use code-connect to match the correct props and now code-connect is useless without accessing the variable modes.


Rob Berrones
  • New Participant
  • April 20, 2026

I’m running into this as well. Please add variable modes in code connect.


Abla AMMAMI
  • New Member
  • June 26, 2026

Same here, we would really appreciate of you can add variable modes in code connect.


Rob Berrones
  • New Participant
  • July 16, 2026

OK, my team and I have found a workaround. We’re using a combination of Modes with a controller variable, and adding a text prop hack/workaround.

Set up the mode, in this case, size. We have Medium (default), Small, Large
 

 

Set up a “Size” text variable, and name it the EXACT same thing as the mode name. 

 

Create a “Code only props” frame, and add the Size text field, assign the Size variable to the text property.

 

On “Code only Props” frame, use “clip Content” and set the width/height to 0.01/0.01. This in essence hides it, but makes Size accessible to Code Connect to target. 

 

 

Code Connect should be able to target this prop now, and make it available:
 

const sizeProp = instance.getEnum('Size', {
Small: 'size="small"',
Medium: '', // default
Large: 'size="large"'
});
export default {
example: figma.code`
<template>

<MyButton
${sizeProp}
>
${buttonText}
</MyButton>
</template>
`,
id: 'my-button',
imports: ["import { MyButton } from '@my-design-system'"],
};

Anyway, We got our inspiration from this Nathan Curtis Article. Hope this helps, may the force be with you.