shadcn-templ 2.0 beta. Switch to templUI v1
1.7k

Aspect Ratio

Displays content within a desired ratio.

Photo
package examples import "github.com/axadrn/shadcn-templ/v2/components/aspectratio"

Installation

shadcn-templ add aspect-ratio

Usage

import "github.com/axadrn/shadcn-templ/v2/components/aspectratio"
@aspectratio.AspectRatio(aspectratio.Props{Ratio: "16/9"}) {	<img src="..." alt="Image" class="absolute inset-0 h-full w-full rounded-md object-cover"/>}

Square

A square aspect ratio component using the Ratio: "1/1" prop. This is useful for displaying images in a square format.

Photo
package examples import "github.com/axadrn/shadcn-templ/v2/components/aspectratio"

Portrait

A portrait aspect ratio component using the Ratio: "9/16" prop. This is useful for displaying images in a portrait format.

Photo
package examples import "github.com/axadrn/shadcn-templ/v2/components/aspectratio"

API Reference

AspectRatio

The AspectRatio component displays content within a desired ratio.

Prop Type Default
Ratio string -
Class string -