Web制作、Web開発の歩き方

エンジニアにも使いやすいFigma入門

■第4話:コンポーネントのバリアント、プロパティ

(最終更新日:2023.07.27)

Figmaのイメージ
この記事は4分で読めます!
(絵が小さい場合はスマホを横に)

「一部変更して使いたい」
ボタンのアイコン部分を変えるだけ、文字を変えるだけという具合に、 元のデザインはそのまま、デザインを一部変更して別のサイトに使いたいということは結構あるはずだ。 それに加えて、ボタンを押したときの動作、選択されているときの色や文字を変えたいといった、要望もある。 これらを実現してくれる機能がバリアントとプロパティである。 今回は、そんなFigmaのコンポーネントのバリアントとプロパティについて説明する。 


1.コンポーネントのバリアント

バリアントとは、hover(マウスをオブジェクトの上に置く)やclickなどを取り扱うもので、 同じボタンでも少し異なったものを保存するための機能である。 バリアントを作成するのは簡単だ。作成したいコンポーネントを選択し、 プロパティの+を押したら、バリアントを選択する。 すると、紫の枠と+ボタンが出現するので、変化させたい数だけ+ボタンを押す。

バリアントの作成(プロパティでバリアントを選択)

バリアントを作成したら、各々のインスタンスに対して明るさや色を変化させて、違いをつける。 変化はFigma右側のデザインのタブで簡単に変更できる。 下記の場合、作成した三つのバリアント(左)に対して、右上が通常時(変化なし)、 右の真ん中がhoverに、右下がdisabledに相当するように変化をつけた。

hover(真ん中)、disabled(下)の作成

これらを実装すると、以下のように簡単にインスタンス状で3つの状態の違いを変えることができる。 以下の動画では、更にプロパティとして、アイコンを2つ登録し、それぞれを入れ替えている。 ボタンの種類を余計に作らず、スッキリまとめられることが分かるだろう。

ボタンの3つの状態とアイコンの変更

2.コンポーネントのプロパティ

上記ではバリアントに加え、アイコンの入れ替えを簡単に説明した。 アイコンの違いだけでなく、プロパティは他にも設定を変えられる。 設定項目としては、先ほどのバリアント、インスタンスの入れ替え(上記のアイコンの入れ替え)に加えて、 テキストの変更とブール値が設定できる。

プロパティの設定項目

テキストの変更は、上記の「access」の部分を「test」など違う文字に入れ替えられる(下記動画)。 これにより、テキスト毎にデザイン変えて保存しなくて良い。 また、下記の動画には示していないが、ブール値の設定では、画像の有無をスイッチ一つで切り替えられるようになる。 イメージは簡単に沸くだろう。

プロパティのテキストの変更

3.まとめ

今回はFigmaのコンポーネント、バリアントとプロパティについて説明した。 アイコンや文字をプロパティに指定すれば、簡単に見た目を切り替えられる。 また、バリアント機能を使えば、動作に関する部分もシミュレーションできる。 Figmaをより便利に使いこなすにあたり、ぜひ、これらの機能はマスターしておこう。

▼参考図書、サイト

   のんびり学ぶ Figma 〜コンポーネント編〜(2) SAKURA internet
   Figmaのコンポーネントプロパティ入門 ICS MEDIA

A Beginner-Friendly Guide to Figma for Engineers ■ Episode 4: Variants and Properties of Components (Last updated: 2023.07.27) Figma image This article takes about 4 minutes to read! (Rotate your phone for a better view if the images appear small) "I want to make slight changes and reuse it" There are often situations where you want to reuse a design with just slight changes—for example, changing only the icon or text of a button while keeping the original design intact. You may also want to change the color or text when the button is clicked or selected. The features that make this possible in Figma are called *variants* and *properties*. In this episode, we’ll explain these powerful features of Figma components. [Table of Contents] Component Variants Component Properties Summary 1. Component Variants Variants are used to handle different states like *hover* or *click*. They let you save slightly different versions of the same button, for example. Creating variants is easy: select the component you want to work with, click the "+" in the properties panel, and choose "Variant". A purple outline and a "+" button will appear—click the "+" button as many times as needed for the number of variations you want to create. Creating a variant (selecting "Variant" in properties) Once you've created the variants, change their colors or brightness to distinguish them. You can easily make these changes using the Design tab on the right side of Figma. In the example below, three variants were created (left side), with the top right representing the default state, the middle right for hover, and the bottom right for disabled. Creating hover (middle) and disabled (bottom) states By implementing these, you can easily toggle between the three states in the component instance. The video below also shows how two icons are registered as properties and switched between them. You can see how this helps keep your components organized without needing to create separate versions for each type. Three button states and icon switching 2. Component Properties In the previous section, we briefly mentioned switching icons in addition to using variants. Properties allow you to control more than just icon differences. Besides variants and instance swapping (as shown above), properties can be used to change text and toggle boolean values. Available component property settings For example, you can replace the word “access” with something like “test” as shown in the video below. This way, you don’t need to save separate designs for each text. Although it’s not shown in the video, you can also toggle the presence of an image using boolean settings—it's quite intuitive. Changing text using properties 3. Summary In this article, we explained component variants and properties in Figma. By assigning icons or text as properties, you can easily switch appearances. With variants, you can also simulate behavior changes such as hover or click. Mastering these features will help you use Figma more effectively and efficiently. ▼ References    Learn Figma at Your Own Pace: Components (2) — SAKURA internet    Introduction to Figma Component Properties — ICS MEDIA