figma.to.website Docs Device-specific content

How to show different content per device

Show a different component variant on touch or mouse, portrait or landscape, screen or print: name a variant property @media with a media query.

Last updated

figma.to.website can change your site’s content based on the visitor’s device, using Figma component variants. A variant can target:

  • the input: mouse or touch;
  • the screen orientation: portrait or landscape;
  • whether the device can hover;
  • the output: screen or print;
  • and many other combinations.

Add an @media variant property

Create a component with a variant property named @media. Each variant’s value is a CSS media query; on the published site, the variant whose query matches the device is shown.

A component with two variants, “Your device has a mouse input” and “Your device has touch input”, and an @media property with the values pointer:fine and pointer:coarse.

Which values can I use?

Values follow the CSS media queries syntax. For example:

ValueMatches when
pointer:fineThe main input is an accurate pointing device, such as a mouse.
pointer:coarseThe main input is a pointing device of limited accuracy, such as a finger on a touchscreen.
pointer:noneThe main input isn’t a pointing device.
orientation:portraitThe viewport is portrait: its height is greater than or equal to its width.
orientation:landscapeThe viewport is landscape: its width is greater than its height.
hover:hoverThe main input can conveniently hover over elements.
hover:noneThe main input can’t hover, or not conveniently (many phones emulate hover with a long tap), or there is no main pointing input.
screenThe site is shown on a screen.
printThe site is being printed.

Combine conditions with and, or with a comma for “or”:

  • (pointer:coarse) and (orientation:portrait): touch input and portrait.
  • (pointer:coarse), (orientation:portrait): touch input or portrait.

Figma doesn’t accept the = character in property values, so a query like width <= 600px won’t work; write width < 601px for the same result. Width-based queries are rarely needed here, though: responsive design has more convenient tools for screen sizes.

See it live: the Device-specific content demo in the Designer’s Guide, a site built with figma.to.website.