Skip to content

AspectRatio

[axAspectRatio] constrains its host to a fixed width-to-height ratio. It sets the modern aspect-ratio CSS property (via Renderer2, SSR-safe), so any ratio works.

import { AxAspectRatioDirective } from '@axisui-ng/primitives';
<!-- 16:9 video wrapper (the default) -->
<div [axAspectRatio]="16 / 9">
<iframe src=""></iframe>
</div>
<!-- square -->
<div [axAspectRatio]="1">
<img src="/cover.jpg" alt="Cover" />
</div>
InputTypeDefaultNotes
axAspectRationumber16 / 9Width ÷ height ratio (selector and input share this name).

Presentational only; provide proper alt/labels on the media inside it.

Interactive examples live in Storybook under Primitives / AspectRatio. Run pnpm storybook to explore them.