Main

Backing color styles with variables

Edit your existing color styles to use a color variable instead of a hex value for an easier transition to using variables with components and designs. Plugins: Styles to Variables Converter - https://www.figma.com/community/plugin/1253585487427690087 Destroyer - https://www.figma.com/community/plugin/1076733710017310027 Learn more about Variables by duplicating the Community playground file: https://www.figma.com/community/file/1234936397107899445 ____________________________________________________ Figma is free to use. Sign up here: https://bit.ly/3msp0OV ____________________________________________________ Find us on ⬇️ Twitter: https://twitter.com/figma Instagram: https://www.instagram.com/figma LinkedIn: https://www.linkedin.com/company/figma Figma forum: https://forum.figma.com/ ____________________________________________________ #Figma #Config #FigJam #Tutorial #NothingGreatIsMadeAlone #design #tips #DesignSystems #Config2023

Figma

9 months ago

Hey everyone. Today we're going to take a look at backing our color styles with variables to make it easier to begin using the color variable type in our libraries and design files. Here I have this world peas design, and if I select it, we can see that it is using color styles from our styles library, as well as the components within it are also using some of those styles. So we actually want to go to our style library, and this is where we're going to create variables to match each of our colo
r styles. Ultimately, we want to create those color variable types, and then we want to go in to each color style and update the property to use the variable instead of this hex value. Now we could do this manually, or there's a plugin in the community that we can use to help us. So I'm going to go to the resources menu and I'm going to look for the styles to variables converter plugin. Once I run this, it's going to automatically create variables for all of these styles in a new collection. So
if I now open the local variables, we can see that all of these color styles have been converted over to variables, and the groupings are also carried over to groups in the variables. Now, maybe for in the variables, I want to eliminate those groups and just see them all up. So I'm going to select all of them in Ungroup to see all of my variables here, and maybe I also want to rename this collection to just be colors. Awesome. Now, we would normally want to update the color styles to use those v
ariables, but by running that plugin, it's already updated them for us. So we now have all of our color styles backed by color variables. So from here I can go ahead and publish this library and we can see we're adding that new variable collection with all of the variables. And we're also updating all of the styles. So once I publish that out, we can go to our downstream libraries and accept those updates. In this example, we're just going to go into this sample component library where we'll rev
iew the changes and we'll accept those updated styles. From here, we'll also want to publish out our component library, so that way the add product file gets the updates. Now, once all of the downstream libraries have been published any product design files will get the update prompt right here, and we can see all of the components have been updated as well as any of the color styles that we're using right here in this file. So by updating all we noticed nothing has changed in the design. Everyt
hing is still intact, and if I click into this header, it's still using the color style. Our components are still using their styles, but here's where I could start to detach styles to expose the variables attached to them. So with the header selected here, I'm just going to go and detach that fill and we can see it's now using the color white variable. So we could also do this for our components. We could go into the library, select all, and we could manually detach each style. At the same time
, we could also use a plugin like destroyer where we might want to run this and just hit destroy all color styles, and we can now see we're just using the variables for all of our components here. I'll publish this update once again, and from here we can now see that in our product, once we accept those updates, our components are now all using the variables. So by having your color styles backed with variables, you can then go back and detach styles and instantly start using those color variabl
e types. This will make it a lot easier as you transition over eventually being able to just delete those styles from your style library and publish an update after you've had plenty of time for folks to accept updates in their consuming files. I hope that this will help you out. Check out the variables playground file if you haven't duplicated it yet to learn even more about how to use variables in Figma.

Comments

@marcinukleja

Thank you so much, Chad and Figma, for using my plugin in this amazing tutorial. I am extremely honored because I am not a professional developer, but I couldn't resist creating something that could make work easier for others. And I'm not stopping here: soon I will add options for dividing styles into collections and modes… and other make some other plugins as well :)

@BentoBox

Omg, this plugin is such a time saver. I started to create the variables manually and gave up after 5mins thinking there must've been a better way. This video showed up right on time!

@imstevencraig

Great video. Would love to know more about why this is a good thing. And how/does it relate to Design Tokens.

@samuelsmith620m

AWESOME! Our design system team was just trying to figure out the best way to handle the migration from Styles to Variables for our Primitives and Semantic tokens. This is going to be super helpful; thanks so much! 🥳

@Connor-BJJ

Can someone please explain (in simple terms) the benefit of using variables over styles when it comes to colours?

@BenMurga

WOW! That's some crazy time-saving plugins. Thanks for sharing such a concise video!

@karenbeal2387

The one benefit to me at the moment (someone who doesn't work in a team) of variable colours is that I can add additional 'layers' to a fill. Previously if I wanted to use my colour styles as a fill along with an image for example I had to detach the colour style in the element, then I could add multiple layers within an element. Now I can fill a shape with a variable and then add an image or an overlay in the same element. As I don't work in a team I can't see myself getting much into tokens and to be honest I find it all baffling for my old brain, but I can see the huge benefit in the long term! I'll give the plugin a go but keep my styles just in case!

@nikolajvonarenstorff5886

Okok good to know this replaces styles. I was a bit confused, but thanks for the summary!

@user-mh8ws8xp1y

Hey, thank you for the video! What about variables tokenization which is mentioned in one of your videos called "Figma tutorial: Intro to variables", what are the next steps?

@user-bn8zi9yg8j

Would be really great if library swap worked with variables too, is this on the roadmap?

@HeroNinja

Thanks for that 💙 (I had overlooked this plugin)

@NickaManu

Thank you so much for that update! Also, did you consider making rearrangeable sidebars, so that they could be placed in a different window? That would make working with Figma on 2 monitors so much more productive!

@NOBODY754

Why? Why do I need to transfer styles to variables?

@austinandriese

This is so lit Chad. Thanks for making it so easy 🔥

@KunalSharma-tx5bg

Is it possible to swap the variables, such as in the case of a design system used for multiple websites where only the colors differ?

@MaherSinjary

Thanks for this, so if the Styles are coming from Variables you can’t use Styles anymore to get Variables functionality until they are detached?

@harmanabiwardani5568

Thanks, great tutorial! But also it made me super confused, since we're gonna using "variables" all the time, then "color styles" will be unused. - What is the real purpose of color style? - When we should use color style? - What is the best practice of using color style, instead of variables?

@weeweeweelliam

You could follow up a second video that looks at how you set up artboard layer modes: light and dark. That includes setting up color variables to have light and dark variables matched for theme use.

@dansilver8555

Thank you for this video. Massive time saver.

@AnshMehraa

Really helpful. Is there a dedicated Blog/Video that explains in detail what the difference is between Styles and Variables?