Skip to content

Components

Aspect Ratio

Keeps a preview, video or image at a fixed ratio while its width follows the layout.

Customize
Ombelle · light

Installation

Run in a project initialized with an Ombelle preset (see Get started). The component uses the saved project preset. Run the command from your app folder; it shows the changes and asks before writing.

pnpm dlx @ombelle-ui/cli@1.1.2 add aspect-ratio

Adds components/ui/aspect-ratio.tsx and installs react, clsx, tailwind-merge with lifecycle scripts disabled.

In a liquid glass project the plan adds a notice that accessibility is not guaranteed, because text contrast depends on the background behind the glass.

Usage

example.tsx
import { AspectRatio } from '@/components/ui/aspect-ratio'
export function Example(){return <AspectRatio ratio={16 / 9} style={{ maxInlineSize: '32rem' }}><img src="/preview.png" alt="The Ombelle preset gallery in light mode" /></AspectRatio>}

API and states

API
AspectRatio (ratio, a number such as 16 / 9)
Minimum states
Empty, with media
Native basis
The CSS aspect-ratio property, one server template for both editions
Styles
Stable in Ombelle, Papier, Organic, Retro futurism, minimalist, neo-brutalism and flat, light and dark. Liquid glass: stable, accessibility not guaranteed.