Select base theme

Select color scheme

Toggle dark mode

GitHub repository

Aspect Ratio

Displays content within a desired ratio.

Photo by Drew Beamer

Square

Photo by Drew Beamer

Portrait

Photo by Drew Beamer

Anatomy

Import all parts and piece them together.

use leptos::prelude::*;
use singlestage::aspect_ratio::*;

#[component]
pub fn AspectRatioAnatomy() -> impl IntoView {
    view! { <AspectRatio /> }
}

API Reference

AspectRatio

Displays content within a desired aspect ratio.

Custom Attributes
NameTypeDefaultDescription
ratioString"1"

The aspect ratio to use to display the child element. Can be a decimal or a formula.

More aspect-ratio info here.
Implements global attributes.