Sabil UI

Search documentation

Search for a command to run...

Components

Aspect Ratio

Displays content within a desired ratio.

Photo

Installation#

  1. Install the dependencies

    npm install radix-ui
  2. Copy the source into your project

    components/ui/aspect-ratio.tsx
    "use client"import { AspectRatio as AspectRatioPrimitive } from "radix-ui"function AspectRatio({  ...props}: React.ComponentProps<typeof AspectRatioPrimitive.Root>) {  return <AspectRatioPrimitive.Root data-slot="aspect-ratio" {...props} />}export { AspectRatio }
  3. Make sure the foundation is in place

    Components read their colors, radius and surfaces from the tokens in app/globals.css. See Theming.

Usage#

import { AspectRatio } from "@/components/ui/aspect-ratio"

Examples#

Portrait

Photo

Square

Photo