For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
0
Sponsor

Aspect Ratio

Displays content within a desired ratio.

A scenic landscape
import { AspectRatio } from "@/components/aspect-ratio/aspect-ratio";

export function AspectRatioDemo() {
  return (
    <div style={{ maxWidth: 450, width: "100%" }}>
      <AspectRatio

Installation

$ pnpm dlx shadcn@latest add https://shadcn-cssinjs.vercel.app/r/aspect-ratio.json

Usage

import { AspectRatio } from "@/components/ui/aspect-ratio/aspect-ratio";
<AspectRatio ratio={16 / 9}>
  <img src="..." alt="Image" />
</AspectRatio>

Examples

Square

Use ratio={1} for a square.

A scenic landscape
import { AspectRatio } from "@/components/aspect-ratio/aspect-ratio";

export function AspectRatioSquare() {
  return (
    <div style={{ maxWidth: 300, width: "100%" }}>
      <AspectRatio

Portrait

Use a ratio below 1 for a portrait orientation.

A scenic landscape
import { AspectRatio } from "@/components/aspect-ratio/aspect-ratio";

export function AspectRatioPortrait() {
  return (
    <div style={{ maxWidth: 260, width: "100%" }}>
      <AspectRatio

RTL

To enable right-to-left support, see the RTL guide.

Photo
منظر طبيعي جميل
"use client";

import Image from "next/image";
import * as React from "react";

import { useTranslation } from "@/components/language-selector";

API Reference

AspectRatio

The AspectRatio component displays content within a desired ratio.

PropTypeDefaultRequired
rationumber1No
classNamestring-No