Image fit

No dependencies
Code format

Install with shadcn

Needs a free account token. Get a token

npx shadcn@latest add @movin/radio-fit

About this component

An image fit picker with a portrait picture in a landscape frame: contain shows all of it with bars at the sides, cover fills the frame with the cropped parts showing faintly outside, and fill stretches it so the sun turns into an oval.

Dependencies
None
Difficulty
Beginner
Reduced motion
Respected
Theme
Light and dark
Follows page color-scheme

Triggers2

  • Click
  • State change

Techniques2

  • CSS transition
  • Transform only

Accessibility

Keyboard and screen readers

A role="radiogroup" with an aria-label around native radio inputs sharing one name, so the arrow keys move the choice and Tab enters the group once; :focus-visible on the input outlines its option.

Reduced motion

The picture changes at once.

Use it in anything you build, commercial and client work included. Licence

More radios

See all
Bike gearsGet code
GradientGet code
Icon styleGet code
Latte artGet code