Layout

Aspect ratio

@xui/aspect-ratio

Locks content to a fixed width : height ratio. Give it a width; the height follows. Handy for images, video embeds and placeholder tiles.

Install

pnpm add @xui/aspect-ratio

Add the barrel to a standalone component's imports:

import { XuiAspectRatioImports } from '@xui/aspect-ratio';

@Component({
  imports: [XuiAspectRatioImports],
  // …
})

Examples

Ratios

Loading preview…

With image

Loading preview…

API

XuiAspectRatio

componentxui-aspect-ratio

Locks its content to a fixed width : height ratio, so media and embeds keep their shape as the column resizes. Give it a width (the default is 100%); the height follows from the ratio.

Inputs

NameTypeDefaultclassClassValueExtra classes, merged into the component's own rather than replacing them.''rationumberWidth divided by height, e.g. 16 / 9 or 1.1

Source

libs/ui/aspect-ratio/xui

xUI 2.0.0 — Apache 2.0 licensed. Built with Angular and Tailwind CSS.