Aspect Ratio

Displays content within a desired ratio.

Installation

The CLI is not yet available. For now, manually copy the component source into your project.

rust-shadcn-ui add aspect-ratio

Usage

use yew::prelude::*;

use crate::components::ui::aspect_ratio::AspectRatio;

#[component]
fn Usage() -> impl IntoView {
    view! {
        <div class="w-[450px]">
            <AspectRatio ratio={16.0 / 9.0}>
                <img src="..." alt="Image" class="rounded-md object-cover" />
            </AspectRatio>
        </div>
    }
}

See Also