Skip to Content
Kokonut UI

MD-03Media

Focal Point Picker

Set where a photo's subject is and see every crop follow it live. Hover a crop to see what it cuts.

Install with
no extra packages

PROAudio Player Card and more like it are in Kokonut UI Pro

Installation

Focal Point Picker is a free, open-source React component in the Kokonut UI Media collection. Add it with the shadcn CLI, which copies the source into components/kokonutui/focal-point-picker.tsx, so the code is yours to change.

npx shadcn@latest add @kokonutui/focal-point-picker

Usage

import FocalPointPicker from "@/components/kokonutui/focal-point-picker";

export default function Example() {
  return <FocalPointPicker />;
}

Props

src
stringDefault built-in
alt
stringDefault "Peaks above a sea of clouds"
imageRatio
numberDefault 3 / 2

The image's natural width over height.

defaultValue
FocalPointDefault { x: 0.68, y: 0.38 }
crops
FocalCrop[]Default built-in

The crops your layouts use; each previews the point live.

onValueChange
(point: FocalPoint) => void
className
string

Extra classes for the root element.

FocalPoint

xrequired
number

0 to 1 from the left.

yrequired
number

0 to 1 from the top.

FocalCrop

labelrequired
string
ratiorequired
number

Width over height.

Dependencies

NeedsVersionComes from
cn from lib/utils.tsshadcn init
React19Your app
Tailwind CSS4Your app

No provider, font or global CSS to set up: the file works as soon as it lands.