Skip to content
synccn

Aspect Ratio

Keeps media at a fixed shape like 16/9.

16 / 9
1 / 1

Installation

$ pnpm dlx shadcn@latest add @synccn/aspect-ratio

First time in this project? Connect synccn with one command.

Usage

import { AspectRatio } from "@/components/ui/collapsible";<AspectRatio ratio={16 / 9}>…</AspectRatio>

API reference

Generated from the component's TypeScript types, so it always matches the code.

AspectRatio

Keeps media at a fixed ratio, e.g. 16/9.

  • ratio
    number

    Default 16 / 9

    Width divided by height, e.g. 16 / 9.

  • className
    string

    Extra classes for the root element.

  • children
    React.ReactNode

    Content to render.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

  • lib/utilscn (merges class names)
  • lib/hooksuseControllable (works controlled or uncontrolled)

npm packages

Accessibility

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA attributes: aria-controls, aria-expanded