Componentdata1.3 KB gzipZero dependencies
Aspect Ratio
Proportional media container with preset ratios, framed border, and corner guides.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add aspect-ratioOr install the full npm package:
npm install bigbulluiUsage
tsx7 lines
import { AspectRatio } from "@/components/ui/aspect-ratio"; <AspectRatio ratio="16:9" perforated cornerGuides cornerNotches label="STAGE SCREEN"> <div className="flex size-full items-center justify-center bg-secondary/40 font-mono text-xs text-muted-foreground"> PROPORTIONAL STAGE FEED </div></AspectRatio>Source code
aspect-ratio.tsx + 1 helperZero third-party dependencies (2 local files shown in tabs below).
tsxaspect-ratio.tsx159 lines
import * as React from "react";import { cn } from "./lib/utils"; export type AspectRatioPreset = "16:9" | "3:1" | "2:1" | "1:1" | "4:3" | "21:9"; export const ASPECT_RATIO_PRESETS: Record<AspectRatioPreset, { ratio: number; label: string; description: string }> = { "16:9": { ratio: 16 / 9, label: "16:9 STAGE SCREEN", description: "Widescreen stage and cinema monitor" }, "3:1": { ratio: 3 / 1, label: "3:1 BOARDING VOUCHER", description: "Elongated travel pass & wristband voucher" }, "2:1": { ratio: 2 / 1, label: "2:1 ADMISSION PASS", description: "Classic arena ticket and concert stub" }, "1:1": { ratio: 1 / 1, label: "1:1 BADGE", description: "Square accreditation pass and credential badge" }, "4:3": { ratio: 4 / 3, label: "4:3 RETRO SCREEN", description: "Classic broadcast display" }, "21:9": { ratio: 21 / 9, label: "21:9 ULTRA STAGE", description: "Panoramic arena backdrop display" },}; export function isAspectRatioPreset(value: unknown): value is AspectRatioPreset { return typeof value === "string" && value in ASPECT_RATIO_PRESETS;} Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { ASPECT_RATIO_PRESETS } from "@/components/ui/aspect-ratio"; <ASPECT_RATIO_PRESETS />| Prop | Type | Description |
|---|---|---|
| ratio | number | AspectRatioPreset | Configures ratio. (Default: "16:9") |
| perforated | boolean | Toggles perforated. (Default: false) |
| cornerGuides | boolean | Toggles corner guides. (Default: false) |
| cornerNotches | boolean | Toggles corner notches. (Default: false) |
| label | string | Accessible label text rendered or attached to the control. |
| serial | string | Configures serial. |
| variant | "default" | "perforated" | "stub" | "screen" | Visual style variant. (Default: "default") |
| innerClassName | string | Configures inner class name. |