Aspect Ratio

Displays content within a desired ratio.

Mountain views

Installation

ng g @spartan-ng/cli:ui aspect-ratio

Usage

import { HlmAspectRatioImports } from '@spartan-ng/helm/aspect-ratio';
<div [hlmAspectRatio]="16 / 9">
    <img src="..." alt="Image" class="rounded-md object-cover"  />
  </div>

Examples

Square

A square aspect ratio component using the [hlmAspectRatio]="1 / 1" prop. This is useful for displaying images in a square format.

Mountain views

Portrait

A portrait aspect ratio component using the [hlmAspectRatio]="9 / 16" prop. This is useful for displaying images in a portrait format.

Mountain views

RTL

To enable RTL support in spartan-ng, see the RTL configuration guide.

Mountain views
منظر طبيعي جميل

Helm API

HlmAspectRatio

Selector: [hlmAspectRatio]

Inputs

PropTypeDefaultDescription
hlmAspectRatio number 1 Aspect ratio of the element, defined as width / height.
Autocomplete Alert Dialog