shadimage
nostalgia-ui
uiretro-aspect-ratiosource: ok · refreshed

RetroAspectRatio

A Mac OS 9 styled aspect ratio container with optional inset border, built on Radix UI Aspect Ratio.

npx shadcn add "https://nostalgia-ui.com/r/retro-aspect-ratio.json"
free

Visual style

retro

Tags auto-generated by rules on 9/24/2026 — empty means no evidence, not lack of support.

Dependencies

Bundle weight · light
ui-primitives@radix-ui/react-aspect-ratio

Registry dependencies

https://nostalgia-ui.com/r/nostalgia-theme.json

Files1 · source cached 10/7/2026, 7:19:03 PM

registry/new-york/ui/retro-aspect-ratio.tsx
"use client"

import * as React from "react"
import * as AspectRatioPrimitive from "@radix-ui/react-aspect-ratio"

import { cn } from "@/lib/utils"

interface RetroAspectRatioProps
  extends React.ComponentProps<typeof AspectRatioPrimitive.Root> {
  /** When true, wraps the content in an OS9-style inset border. Defaults to false. */
  bordered?: boolean
}

function RetroAspectRatio(
  { className, bordered = false, children, ...props }: RetroAspectRatioProps,
  ref: React.ForwardedRef<React.ComponentRef<typeof AspectRatioPrimitive.Root>>
) {
  if (bordered) {
    return (
      <div
        className="border border-[var(--os9-black)] bg-[var(--os9-white)]"
        style={{
          boxShadow:
            "inset 1px 1px 0 var(--os9-gray-700), inset -1px -1px 0 var(--os9-white)",
        }}
      >
        <AspectRatioPrimitive.Root
          ref={ref}
          className={cn(className)}
          {...props}
        >
          {children}
        </AspectRatioPrimitive.Root>
      </div>
    )
  }

  return (
    <AspectRatioPrimitive.Root
      ref={ref}
      className={cn(className)}
      {...props}
    >
      {children}
    </AspectRatioPrimitive.Root>
  )
}

const ForwardedRetroAspectRatio = React.forwardRef(RetroAspectRatio)
ForwardedRetroAspectRatio.displayName = "RetroAspectRatio"

export { ForwardedRetroAspectRatio as RetroAspectRatio }
export type { RetroAspectRatioProps }

More from nostalgia-ui

Browse all components in this library →