Skip to content
Ballpoint

Aspect Ratio

A box that keeps its shape while its content loads, optionally with a pencilled frame round the edge.

From shadcn/ui
A doodled portrait

16 : 9

Installation

pnpm dlx shadcn@latest add @ballpoint/aspect-ratio

Usage

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

<AspectRatio ratio={16 / 9} framed>
  <img src="/photo.jpg" alt="…" className="size-full object-cover" />
</AspectRatio>

Examples

Ratios

Square, four to three, widescreen and portrait.

1 : 1
1.00
4 : 3
1.33
16 : 9
1.78
9 : 16
0.56

Holding a place

An image box that does not jump when the picture arrives.

A doodled portrait

The box holds its shape while the picture loads, so nothing below it jumps.

API reference

ratio
default 1
number

Width over height: 16 / 9, 4 / 3, 1.

framed
default false
boolean

Draws a pencilled frame round the box.

seed
string | number

Pins the drawing.

Pen settings

The drawing also takes draw, roughness, passes, radius, corners, weight and speed, as props or from the nearest InkProvider. What each one does.