Aspect Ratio

Aspect Ratio with accessible presentation and local state.
Landscape · 16:9
Abstract artwork by mymind on Unsplash
Ultrawide · 21:9
Abstract artwork by mymind on Unsplash
Square · 1:1
Abstract artwork by mymind on Unsplash
Portrait · 9:16
Abstract artwork by mymind on Unsplash
RTL
عمل فني تجريدي
عمل فني تجريدي

Installation

Install the shared package once in your Exact app. This version is a beta.
bun add --exact @rightui/ui@0.4.0-beta.4
The Exact compiler requires Bun 1.4.2, regardless of which package manager installs the package.
Complete the font, app metadata and root provider setup (required for both installation methods).
Import
use AspectRatio, AspectRatioFrame from "@rightui/ui"

Usage

Import AspectRatio from @rightui/ui and supply ratio plus slotted content. Use AspectRatioFrame(ratio, radius) for an explicit corner radius. Ratios must be positive; nonpositive values fall back to a square. Copy the packaged assets/card directory into your app assets when using the example cover.

API Reference

Properties from the component source. State lives in your component; actions receive the updated value.
AspectRatio.ratio
number
AspectRatioFrame.ratio
number
AspectRatioFrame.radius
string