JGuang / JGuang UI
Components组件Base UIBase UI 组件

Aspect Ratio

Displays content within a desired ratio.

Partially translated: Chinese navigation, titles, descriptions, and common headings. The technical body is currently in English.
Loading JGuang UI example…

Installation

Command

Manual

Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.

Install the following dependencies:

npm install @base-ui/react

Copy and paste the following code into your project.

View complete source: components/ui/aspect-ratio.tsx

Update the import paths to match your project setup.

Usage

import { AspectRatio } from "@/components/ui/aspect-ratio"
<AspectRatio ratio={16 / 9}>
  <Image src="..." alt="Image" className="rounded-md object-cover" />
</AspectRatio>

Square

A square aspect ratio component using the ratio={1 / 1} prop. This is useful for displaying images in a square format.

Photo

Portrait

A portrait aspect ratio component using the ratio={9 / 16} prop. This is useful for displaying images in a portrait format.

Loading JGuang UI example…

RTL

To enable RTL support in JGuang UI, see the RTL configuration guide.

Loading JGuang UI example…

API Reference

AspectRatio

The AspectRatio component displays content within a desired ratio.

PropTypeDefaultRequired
rationumber-Yes
classNamestring-No

For more information, see the Base UI documentation.

Source: components/base/aspect-ratio.mdx

Technical documentation for JGuang UI.

On this page