
package examples import "github.com/axadrn/shadcn-templ/v2/components/aspectratio"package examples import "github.com/axadrn/shadcn-templ/v2/components/aspectratio" templ AspectRatioDemo() { @aspectratio.AspectRatio(aspectratio.Props{ Ratio: "16/9", Class: "w-full max-w-sm rounded-lg bg-muted", }) { <img src="/assets/img/aspect_ratio_placeholder.jpeg" alt="Photo" class="absolute inset-0 h-full w-full rounded-lg object-cover grayscale dark:brightness-20" /> }}Installation
Usage
Square
A square aspect ratio component using the Ratio: "1/1" prop. This is useful for displaying images in a square format.

package examples import "github.com/axadrn/shadcn-templ/v2/components/aspectratio"package examples import "github.com/axadrn/shadcn-templ/v2/components/aspectratio" templ AspectRatioSquare() { @aspectratio.AspectRatio(aspectratio.Props{ Ratio: "1/1", Class: "w-full max-w-[12rem] rounded-lg bg-muted", }) { <img src="/assets/img/aspect_ratio_placeholder.jpeg" alt="Photo" class="absolute inset-0 h-full w-full rounded-lg object-cover grayscale dark:brightness-20" /> }}Portrait
A portrait aspect ratio component using the Ratio: "9/16" prop. This is useful for displaying images in a portrait format.

package examples import "github.com/axadrn/shadcn-templ/v2/components/aspectratio"package examples import "github.com/axadrn/shadcn-templ/v2/components/aspectratio" templ AspectRatioPortrait() { @aspectratio.AspectRatio(aspectratio.Props{ Ratio: "9/16", Class: "w-full max-w-[10rem] rounded-lg bg-muted", }) { <img src="/assets/img/aspect_ratio_placeholder.jpeg" alt="Photo" class="absolute inset-0 h-full w-full rounded-lg object-cover grayscale dark:brightness-20" /> }}API Reference
AspectRatio
The AspectRatio component displays content within a desired ratio.