Create

Layout

Aspect Ratio

Copy page View as Markdown Open in ChatGPT Open in Claude

Displays content within a desired ratio.

Usage#

app.component.ts
import { WdsAspectRatioComponent } from '@wds/angular/aspect-ratio';

Examples#

Default#

ratio="16/9": the shape of video players. The width comes from the layout, the height from the ratio.

16 / 9

Square#

1/1 for product shots, covers and grid tiles.

1 / 1

Portrait#

9/16 for stories and vertical video.

9 / 16

Ultrawide#

21/9 for banners and page headers.

21 / 9

Other ratios#

4/3 (photos from phones), 3/2 (cameras), 4/5 (portrait posts) and 16/10 (laptop screens). 16:9 and a number such as 1.5 also work.

4 / 3
3 / 2
4 / 5
16 / 10

Image#

An <img>, <video> or <iframe> inside fills the box (object-fit: cover).

Portrait of a man in a grey shirt

API References#

wds-aspect-ratio#

Keeps its content at a width-to-height ratio, e.g. 16/9 for video or 1/1 for a square tile. The width comes from the layout; the height follows from ratio. An image or video inside fills the box.

Attributes

AttributeTypeDefaultDescription
ratiostring'1'Width to height: 16/9, 16:9, 4/3 or a number such as 1.5.

Slots

SlotDescription
(default)Content: an image, a video, a map or any element.

Accessibility#

Screen reader#

wds-aspect-ratio only sizes its content and has no role. Give an image inside an alt text, or alt="" when it is decorative.

Keyboard support#

wds-aspect-ratio is not focusable and has no keyboard interaction.

Footer