Thinking UI

Aspect Ratio PickerPRO

Segmented ratios with a live preview frame that morphs and re-crops the image.

Code

2 files · 252 lines of TypeScriptPRO

Aspect Ratio Picker is part of Pro

Get its source, the one-paste agent prompt and all 113 components, for a one-time $99.

Motion notes

  • The frame springs its real width and height rather than scaling, so object-fit: cover recomputes the crop every frame and the image never stretches.
  • Going from wide to tall passes through square on the way, which reads as the same canvas reshaping rather than a swap.
  • The selection pill slides on the same layout spring as the frame, and the output size rolls digit by digit, so all three move as one.
  • A radio group with arrow-key navigation. With reduced motion the frame and pill change instantly.

Usage

Example
const [ratio, setRatio] = useState("3:4");

  <AspectRatioPicker src={reference.url} value={ratio} onValueChange={setRatio} />

Props

PropTypeDefaultDescription
srcstring—Previewed inside the frame, cropped to the chosen ratio.
altstring—Alt text for the preview.
optionsstring[]["1:1", "3:4", "4:3", "16:9", "9:16"]Ratios as "w:h".
valuestring—Controlled ratio.
defaultValuestring—Starting ratio when uncontrolled. Defaults to the first option.
onValueChange(value: string) => void—Called when a ratio is picked.
basenumber1024Output size of the short side, in px, for the readout.
labelstring"Aspect ratio"Accessible name for the options.
classNamestring—Classes for the card; the default is w-80.