Friday, November 13, 2020

How to Turbocharge Your Components with Figma Variants

How to Turbocharge Your Components with Figma Variants
Final product image
What You'll Be Creating

In this tutorial you’ll learn how to use variants in Figma. Variants are a relatively new Figma feature; with them you can easily group and organize multiple versions of the same component.

Figma Skills You Will Learn in This Tutorial:

  • How to save color styles in Figma
  • How to use Figma auto layouts
  • How to create and use Figma components
  • How to convert components into variants in Figma
  • How to add a property for a variant in Figma
  • How to make a poker app

For more inspiration on how to adjust or improve your game UI design you can find plenty of resources on Envato Elements. Elements is home to thousands of UI and UX kits, compatible with your favorite design tools (including Figma) for one single subscription price!

What You Will Need:

You will need the following resources, available with your Envato Elements subscription, in order to complete this tutorial (but feel free to use your own alternatives if you prefer):

15 Gambling and Casino Icons
15 Gambling and Casino Icons
Odudo Mono Font
Odudo Mono Font

In this tutorial we’ll use the iPad game UI design shown at the top of the page to demonstrate how to work with variants in Figma. 

What is a Figma Variant?

If you’ve ever worked with components in Figma, you’ll know that they can speed up your UI design process where you need to reuse objects. Buttons are a perfect example of where you’d want to use components. 

Figma variants allow you to create a single component where you’d otherwise create several, instead allowing you to switch between variants of that component. For example, in a minute we’ll be creating a poker chip component which has several variants depending on the color we want to use:

poker chip component variants
7 variants of the same poker chip component

Let’s jump in!

1. How to Create Variants in Figma

Select the Ellipse Tool (O) and hold down the Shift key while you click and drag to easily create a 24 px circle.

Focus on the right sidebar and change the Fill color of this shape to #FFB400, and then click the quadruple dot icon to open the Color Styles flyout panel. Click the Create Style button (+), name it Yellow, and then click the Create style button. 

Your color should now show up in the Color Styles panel and you can easily use it whenever you wish.

circle

Step 2

Make sure that your circle stays selected and click the Stroke section from the right sidebar to add a Stroke.

Change the color to white (#FFFFFF) and increase the size to 3. Make sure that the alignment is set to Inside, and then click that triple dot icon to open the Advanced Stroke flyout panel. Enter 5, 5 in the Dashed box to make the stroke dashed, as shown below.

Once you’re done, open the Color Style flyout panel and save the color use for this stroke as a color style. Name it White.

dashed stroke

Step 3

Using the Ellipse Tool (O), create an 18 px circle and place it as shown in the first image.

Don’t bother to fill this new shape, but add a Stroke. Change its color to #EBA000 and keep the alignment set to Inside and the size to 1.

Select both circles made in this step and Group them (Control-G). Move to the left sidebar, inside the Layers panel, and rename this new group Chip 5.

group

Step 4

Hold down the Alt key and simply click and drag a copy of your group. Select the main circle from this new group and replace the Fill color with #F5444C. Save this color as a color style and name it Red.

Select the smaller circle inside this new group and change the Stroke color with #E13038.

Move to the Layers panel and rename this new group "Chip 10".

duplicate group

Step 5

Add four more copies of your group and replace the existing colors with the ones shown below.

Don’t forget to save the five colors indicated in the following image.

Once you’re done, move to the Layers panel to rename these new groups: Blue - "Chip 25", Green - "Chip 50", Purple - "Chip 100", LightBlue - "Chip 500".

recolor

Step 6

Using the Ellipse Tool (O), create one more 24 px circle. Fill this new shape with #CED4DD and add a White stroke. Increase the stroke size to 3 and make sure that the alignment is set to Inside.

Switch to the Text Tool (T) and type in a simple "D". Use the Montserrat font, set the style to Bold and the size to 14, and then change the color to DarkBlue. Place this small piece of text as shown in the second image.

dealer chip

Step 7

Select that small piece of text along with the circle that lies in the back and Group them (Control-G). Move to the Layers panel to rename this new group "Chip Dealer".

Now, select all your chip groups and click the Create Multiple Components button from the toolbar to turn all your groups into separate Figma components.

create multiple components

Step 8

Make sure that all your components are selected and click the Combine as Variants button from the right sidebar. This will merge all your components into one component with seven variants.

You can easily rename this new component in the Layers panel. To rename a variant or a property all you have to do is double click it, in the right sidebar.

combine as variants

Step 9

Now you can click and drag your Figma component from the Assets panel and add it to your design. 

component assets panel

You can easily select the desired Figma variant from the drop-down menu in the right sidebar.

chip component

2. How to Use Figma Variants for a Button

Step 1

Using the Text Tool (T) add the "DESK:50$" piece of text. Use the Motserrat font, set the style to Bold and the size to 10, and change the color to White.

Make sure that this text is selected and press Shift-A to add Auto Layout. Move to the right sidebar to increase the Horizontal Padding for the auto layout to 15, and keep the Vertical Padding and the Spacing Between Elements set to 10.

auto layout

Step 2

Keep focusing on the right sidebar and add a Fill and a Stroke for your auto layout.

Set the Fill color to DarkBlue and the Stroke color to White. Increase the stroke size to 2 and make sure that the alignment is set the Inside.

Go to the top of the right sidebar and set the Corner Radius to 20, and then move to the Layers panel to rename your auto layout "Command".

rounded corners

Step 3

Make sure that your auto layout is still selected and turn it into a Figma component using the Create Component button (Control-Alt-K) from the toolbar.

create component

Step 4

With this new component still selected, focus on the right sidebar and use the + button from the Variants panel to add a new variant for your component. Name it "All In".

add variant

Step 5

Select the element that makes up this second variant, change the Stroke color to Purple and replace the text with "ALL IN:50$".

You can also return to the Variants panel and pick a different name for that Default variant.

all in variant

Step 6

You can also add a new variant for a component using the + button from the bottom right corner of the frame. Let’s click it and select the newly added button.

Change the Stroke color to Yellow and replace the text with "CHECK:50$". Don’t forget to rename this new variant "Check".

check variant

Step 7

Let’s also add an icon for this "Check" variant. Using the Pen Tool (P), create a tiny arrow, as shown in the following image. You can go to View > Pixel Grid to enable the Pixel Grid which will make it a lot easier to create this path.

Set the Stroke color to White and increase the size to 2.

arrow icon

In order to make this arrow button a part of your variant, all you have to do is drag it inside the button.

icon auto layout

Step 8

Enlarge the frame of your component to make some space for the next variants. 

Add a fourth variant, rename it "Call" and select it. Change the Stroke color to Blue and replace the text with "CALL:50$", and then select that arrow icon and rotate it 90 degrees, as shown below.

call variant

Step 9

Add a fifth variant, rename it "Raise" and select it. Change the Stroke color to Green and replace the text with "RAISE:50$", and then select that arrow icon and rotate it 90 degrees, as shown in the second image.

Add one last variant, rename it "Fold" and select it. Change the Stroke color to Red and replace the text with "FOLD", and then remove that arrow icon.

raise fold variant

Step 10

Using the Pen Tool (P) or the Line Tool (L), create an oblique path, as shown in the first image. Duplicate this path (Control-C > Control-V) and rotate the copy 90 degrees.

Select both copies to Group them (Control-G) and move this icon inside the fold button, as shown in the final image.

fold icon

Step 11

As with the other component, you can drag your button component from the Assets panel and add it to your design.

component button

You can easily select the desired Figma variants and keep in mind that you can adjust the text as you wish.

button variant

3. How to Use Properties and Variants in Figma

Step 1

Using the Rectangle Tool (R), create an 80 x 104 px shape, make sure that it stays selected and focus on the right sidebar. 

Set the Corner Radius to 5, change the Fill color to Red and the Stroke color to White, and then increase the stroke size to 5.

rounded rectangle

Step 2

Using the Rectangle Tool (R), create two, 35 x 37 px shapes. Fill both rectangles with #E13038 and place them as shown below.

rectangle

Step 3

Select these three rectangles and Group them (Control-G). Move to the Layers panel and rename this new group "Card/Back/Large".

Using slash / for names makes it a lot easier to convert components into variants. You’ll learn more about this technique and exactly how it works a few steps later.

group card

Step 4

Pick the Rectangle Tool (R) and create an 80 x 104 px shape. Set the Corner Radius to 5 and change the Fill color to White.

corner radius

Step 5

Using the Text Tool (T), add a simple "A". Use the Odudo Mono font, set the style to Bold and the size to 38. Remember to check the Text Align Right button and change the text color to DarkBlue, and then place your text as shown in the first image. Having the text aligned to right will come in handy if you will choose to replace the "A" with a "10".

Next, you will need the clubs icon from this 15 Gambling and Casino Icons Pack. Copy it inside your document and focus on the right sidebar. Make sure that you have the Constrain Proportions option active, set the Height to 25 px and change the Fill color to DarkBlue. Place your icon as shown in the second image.

Select the clubs icon and the "A" along with the white rounded rectangle and Group them (Control-G). Move to the Layers panel and rename this new group "Card/Clubs/Large".

card suit icon

Step 6

Add three copies of your latest group and replace the clubs icon with the other three icons.

Once you’re done, move to the Layers panel and rename the new groups accordingly.

group slash component variant

Step 7

Pick the Rectangle Tool (R) and this time create a 40 x 52 px shape. Set the Corner Radius to 5, change the Fill color to Red and the Stroke color to White, and then increase the stroke size to 3.

Using the same tool, create two, 17x 23 px shapes. Fill both rectangles with #E13038 and place them as shown in the second image.

Select these three rectangle, Group them (Control-G) and rename this new group "Card/Back/Small".

card small

Step 8

Pick the Rectangle Tool (R) and create another 40 x 52 px shape. Set the Corner Radius to 5 and change the Fill color to White.

Switch to the Text Tool (T) to add an "A" and use that same Odudo Mono font, set the style to Bold and the size to 19. Remember to check the Text Align Right button and change the text color to DarkBlue, and then place this text as shown in the second image. 

Add a copy of your clubs icon, lower the Height to 12.5 px and place it as shown in the second image. 

Select all three elements and Group them (Control-G). Move to the Layers panel and rename this new group "Card/Clubs/Small".

card small front

Step 9

Add three copies of your latest group and replace the clubs icon with the other three icons, and then move to the Layers panel to rename the new groups accordingly.

cards small

Step 10

Before we turn all these groups into variants let’s better understand the use of this slash naming system. The text before the first slash is always used to name your component. The text after the first slash will be used to name all variants that will be available for the first property while the text after the second slash will be used to name the variants that will be available for the second property. Let’s turn all these groups into variants and see how easy it can be.

Make sure that you have all the groups selected, go to Create Multiple Components and then click the Combine as Variants button.

As you can see in the right sidebar, this will create the "Card" component (text before the first slash), with two Properties. Property 1 contains the 5 variants (Back, Clubs, Spades, Hearts, Diamonds) that were set after the first slash and Property 2 contains the 2 variants (Large, Small) that were set after the second slash. You can always double click a Property to rename it as you wish.

variant property

Step 11

As with any component, you can easily drag it from the Assets panel and add it to your design, and you can select the desired Figma variants from the drop-down menu in the right sidebar. 

Don’t forget that you can also adjust the text making it so much easier to create different cards.

variant property
component

Congratulations! You’re Done!

Here is how it should look. I hope you’ve enjoyed this tutorial and can apply these techniques in your future projects. Don’t hesitate to share your final result in the comments section.

Feel free to adjust the final design and make it your own. You can find some great sources of inspiration at Envato Elements, with interesting solutions to improve your design.

Variants in Figma

Want to Learn About More Figma Features?

We have loads of tutorials on Tuts+, beginner to intermediate level, take a look!


No comments:

Post a Comment