CSS aspect-ratio and Figma's Lock Aspect Ratio: How Intrinsic Sizing Maps Between Them

Figma's Lock aspect ratio and CSS aspect-ratio both keep proportions. Here is how each interacts with Hug, Fill, Fixed and explicit sizes.

REFERENCEDEVELOPERPublished

Introduction

CSS aspect-ratio and Figma's Lock aspect ratio do the same basic job: they keep a box at a width-to-height proportion while one side changes. Neither is absolute. In CSS the ratio is only a preference. In Figma the lock gives way to the sizing mode you pick on each axis.

This article maps the two. You'll see where Figma's lock lives, how Hug contents, Fill container and Fixed interact with it, what the CSS property needs before it does anything, and where the two models only roughly match.

What Lock aspect ratio does in Figma

Where the setting lives and the key overrides

Select a layer and turn on Lock aspect ratio in the Layout or Auto layout section of the right sidebar. Once it is on, you can resize from the canvas or type into the W and H fields, and Figma updates the other value to match. The Figma help page on dimensions also documents two temporary overrides:

  • With the ratio locked, hold Control while resizing from the canvas to disable it for that drag.
  • With the ratio turned off, hold Shift while resizing to enable it for that drag. Releasing the key does not leave the layer locked.

Min and max with a locked ratio

A locked ratio carries into minimum and maximum sizes. Figma's own example is a layer with a 1:2 ratio. Set a minimum height of 100px and Figma sets a minimum width of 200px for you. Set a limit on one axis and you have set a proportional limit on the other.

The component instance limit

The setting is not available on child layers of component instances. If a layer inside an instance needs a locked ratio, you change it on the main component. Plan for that before you wire up a card component with an image slot.

Hug, Fill and Fixed

Lock aspect ratio sits next to the three resizing modes, and the modes decide how much room the lock has to work with. The auto layout guide defines them:

ModeWhere it appliesWhat it does
Hug contentsAuto layout frames onlySizes the frame to its children and spacing
Fill containerChildren of auto layout frames, not top-level framesTakes the space the parent offers
FixedAny auto layout frame and its childrenKeeps the size you typed or dragged

Three details matter for ratios:

  1. Typing a value into W or H, or resizing by hand, sets that axis to Fixed.
  2. If any child is set to Fill container, a parent that was hugging stops hugging and becomes Fixed on that axis.
  3. A frame set to Hug contents, or to a Fixed size smaller than its padding, still grows to fit the padding, as the auto layout flows page explains.

In practice, a locked ratio is easiest to reason about when one axis is Fill container and the other follows from the lock. If you set both axes to Fixed values, you have decided both sizes yourself, and the lock only matters the next time you resize.

How the CSS aspect-ratio property decides

MDN defines aspect-ratio as the property that lets you define the desired width-to-height ratio of an element's box. The value is the keyword auto, a <ratio>, or both. A ratio is written 16 / 9. If you leave out the height and the slash, the height defaults to 1, so aspect-ratio: 2 means 2 / 1.

The rule that trips people up: the ratio is a preference, not a command. MDN states that at least one of the box's sizes needs to be automatic for aspect-ratio to have any effect. When both width and height are explicit, the property value is ignored.

That is the CSS version of Figma's Fixed on both axes. In both tools, once you size both sides yourself, the ratio has nothing left to decide.

As of 2026, you can rely on the property. MDN marks it Baseline, available across browsers since September 2021.

Replaced elements and intrinsic ratio

An img is a replaced element with an intrinsic ratio of its own. That is what the auto keyword refers to. MDN says that with auto, replaced elements with an intrinsic aspect ratio use that ratio, and any other box has no preferred ratio.

You can combine both values, as in aspect-ratio: auto 3 / 4. For an img, the given ratio is used until the content loads. After that, the intrinsic ratio of the loaded content takes over. For a box that is not a replaced element, the given ratio is used.

MDN's guide to aspect ratios adds a condition for replaced elements: only one dimension may be set. Set both or neither and the property does not apply. With only a width, the browser resizes the other dimension and keeps the media's original ratio.

The same placeholder idea explains why web.dev recommends giving images width and height attributes, or an aspect-ratio, so the page does not shift as media loads. For how the image itself is cropped inside its box, see how object-fit and image fit carry over.

When content outgrows the ratio box

A ratio box can still grow when its content is bigger than the box. MDN's guide covers this for grid items: to stop content from growing past the preferred height, set min-height to 0 and overflow to a value other than visible. For content that is intrinsically larger than the available space, set max-height (or max-width) to 100% on that content.

In Figma, the equivalent decision is whether the frame clips its content. That topic has its own page: Clip content and overflow.

Mapping the two

The closest match for a responsive image box looks like this:

.card-image {
  width: 100%;
  aspect-ratio: 16 / 9;
}

In Figma, that is an image layer with its width set to Fill container and Lock aspect ratio on. Figma's own guidance for social post images describes the same pairing: set the width to Fill container and toggle the aspect ratio on so the image keeps its proportions when the frame resizes.

CSSFigmaHow close
width: 100% with aspect-ratio: 16 / 9Width Fill container with Lock aspect ratio onClose in behaviour
width and height both explicit, ratio ignoredBoth axes FixedClose
aspect-ratio: auto 3 / 4 on an imgNo matching setting documentedNot covered by the Figma help pages cited here
Padding-top percentage hack, for example padding-top: 56.25%Not neededweb.dev notes aspect-ratio: 16 / 9 replaces the hack in CSS
min-height: 0 and overflow: hidden on a grid itemClip contentApproximate

The mapping is by behaviour, not by identical rules. Figma's lock is a property of one layer that you toggle. CSS aspect-ratio is part of how the browser resolves a box's size against its container and its content. When you read an imported page, treat a ratio as a hint about intent and check each axis.

Conclusion

Before you trust a ratio in either tool, ask which axis is automatic. In CSS, one has to be, or the ratio is ignored. In Figma, Fill container or Hug contents on one axis leaves room for the lock. Fixed on both axes means you chose both sizes.

If you are working with a page that arrived in Figma as layers, the next step is usually making its frames respond to different widths. See making an imported page responsive for that.

Frequently Asked Questions

How do I lock the aspect ratio of a frame in Figma?

Select the layer and turn on Lock aspect ratio in the Layout or Auto layout section of the right sidebar. After that, editing width or height updates the other value.

Does CSS aspect-ratio work when width and height are both set?

No. MDN says at least one of the box's sizes needs to be automatic. When both are explicit, the ratio has no effect on the box's preferred sizes.

What is the Figma equivalent of CSS aspect-ratio?

A locked aspect ratio on a layer whose width is Fill container is the closest match to width: 100% with aspect-ratio. The match is by behaviour, not an exact one-to-one.

Questions

How do I lock the aspect ratio of a frame in Figma?
Select the layer and turn on Lock aspect ratio in the Layout or Auto layout section of the right sidebar. After that, editing width or height updates the other value.
Does CSS aspect-ratio work when width and height are both set?
No. MDN says at least one of the box's sizes needs to be automatic. When both are explicit, the ratio has no effect on the box's preferred sizes.
What is the Figma equivalent of CSS aspect-ratio?
A locked aspect ratio on a layer whose width is Fill container is the closest match to width: 100% with aspect-ratio. The match is by behaviour, not an exact one-to-one.