Export Figma frames to responsive HTML and CSS. A Figma version of ai2html, with additional features. Created by The DataFace.
Install the plugin on Figma.
#[width]px
(e.g. #640px
).Page settings
panel.'f2h-settings
on the current page in your Figma doc, or you can write your current settings to a YAML text node.Check out this demo Figma file if you need a reference to get started!
#[width]px
on your current page, unframes all children (turns frames into groups to get positions relative to the parent frame), hides all text layers, and exports as a PNG
, JPG
, or SVG
, at a specified scale.<p>
(or header) elements. A style is applied based on the most frequently used style within that frame, with inline styles applied to text that differs. This should match what you see in Figma.width=auto
, while text frames with set widths include that width as inline css.Include Resizer Script
is turned on, the outputted HTML will include JS to show and hide the correct image at the appropriate size, based on the named width of the frame.html
. svelte
is coming soon!Testing Mode
to keep text visible on exported images. Useful for comparing layouts in the exported HTML vs the designs in Figma.Image scale
to export images at a specified scale.Image format
options include PNG
, JPG
, and SVG
.Path
field allows you to specify an image path, which will be referenced in the image paths in the outputted HTML. Useful if you will be dropping your outputted files into a larger codebase.Alt text
allows you to add an alt text tag to images in your outputted HTML. This field is required to export.Include resizer script
to include JS in your outputted file which will show and hide the appropriate image at the appropriate size.Center HTML output
to center your page content in the outputted HTML.Fluid
to have the f2h containers fill the width of the screen. If off, f2h containers will maintain the widths at which they were designed in Figma.Max width
in pixels to apply a max width to your page content.Custom scripts
, like Typekit tags, to your outputted HTML.Style text elements
to include inline styles to match the text styles you see in Figma.Include figma styles
as Classes to include any named styles in Figma as classes on your text elements. Ex. Desktop/Utility Sans
will be included as class="utility-sans"
.Include Google Fonts
to include a Google Fonts tag for included Google Fonts in the outputted HTML.[f2h]
followed by a list of attributes in HTMl attribute format. For example, a text layer named [f2h]class="text-sm font-sans" id="my-text-layer"
will render as <p class="font-sans text-sm" id="my-text-layer">
. This can be useful for including Tailwind and other utility classes. You also can use a reserved tag
attribute to change the default <p>
tag to one of your choosing (ex: [f2h] tag="h1" id="hed" class="text-xl font-bold"
will render <h1 id="hed" class="text-xl font-bold">
). Note that naming your layers like this will not turn off Style text elements
for that node, and will still include inline styling for child spans. To rely purely on class names for styling, turn off the Style text elements
option.Variable text is supported for exportable frames (frames prefixed with #
). Variables can be added in the UI under the Variables
panel. All variables values are strings and can be used in any text node in your Figma file.
To use a variable, edit any desired visible text node's name to be the key (e.g. hed
) in double curly brackets (e.g. {{hed}}
) in a visible text node. The exported files with replace the key with the appropriate value (e.g. {{hed}}
-> figma2html
).
This replacement occurs on the exported files and on Figma itself everytime a key or value changes.
We welcome feedback, bug reports and feature requests in the form of Issues or PRs. Alternatively, comments can be left on the Figma plugin community page.
Further information on contributing can be found in CONTRIBUTING.md.
Figma2html is not possible without ai2html, created by Archie Tse at The New York Times. Figma2html sprung from the same codebase, modified in time to add additional features specific to the Figma API. The plugin was inspired by Thomas Lowry's Figma Plugin DS Svelte library.
The core team from The DataFace features Sam Vickars, Sawyer Click, and Michael Hester.