Polipo

Configuring Figma layouts

The file src/polipo.ts defines which layouts should be imported from Figma and allows customizing responsiveness.

Name normalization

Layer names in Figma are automatically normalized and converted to PascalCase, in order to be used in the code. The normalization works as follows:

  1. non-alphanumeric characters are converted to spaces,
  2. words are capitalized and joined,
  3. if the resulting name starts with a number, it is prepended by an underscore (_).

For example "1 this-is-a (very) strange layerName!!" is converted to _1ThisIsAVeryStrangeLayerName.

It is not necessary to change the names in Figma to follow this format. The normalization happens automatically and transparently.

Root properties (defineFigmaRoot)

PropTypeDefault
layouts
Record<string, FigmaLayoutOptions>
-

There are more experimental options available, to customize how images and fonts are loaded. These options are not yet stable. Please contact us if you need this feature.

Layout properties (defineFigmaLayout)

Specifying the Figma layer

PropTypeDefault
path
string
-

Use the path property to specify which Figma layer to use.

In order to use a Figma layer, it must satisfy the following:

  1. it must be either a Figma frame or a Figma component,
  2. it must be placed directly under a page or a section (i.e., deeper layers cannot be used directly).

(Note that layers with the above properties will show their name on the canvas in Figma.)

To refer to such a layer, the full path must be used, which consists of:

  1. the normalized name of the Figma page,
  2. the normalized names of the sections containing the layers, from outermost to innermost, if any, and
  3. the normalized name of the layer itself,

separated by a forward slash (/).

Examples: Page1/Frame4, Components/SimpleButton, Page1/Section2/InnerSection/Frame3.

Note that Figma names are normalized.

Adjusting the size

PropTypeDefault
hFill
boolean
false
wFill
boolean
false

Set wFill and hFill to true to make the layer to fill the container horizontally or vertically.

The design will adapt to the new size in the same way as if you were resizing it in Figma.

Selecting nested layers by name

PropTypeDefault
#<layer name>
FigmaLayoutOptions
-

By adding a key formed by a hash character (#) followed by a normalized figma name, you can customize all the occurrences of nested layers with their name.

Media queries

PropTypeDefault
@media <query>
FigmaLayoutOptions
-

By using a media query as a key, you can customize the properties of the layer when the query matches.

Specify a path inside a media query to use a different Figma layout when the query matches.

Pseudo selectors

PropTypeDefault
:hover
FigmaLayoutOptions
-

By using a pseudo-selector as a key, you can customize the properties of the layer when the selector matches.

Specify a path inside a pseudo-selector to use a different Figma layout when the selector matches.

At the moment, :hover is the only supported pseudo-selector. Contact us to request support for more selectors.

On this page