# React quickstart

> Install the React image zoom component and render your first accessible zoomable image.

Source: <https://medium-zoom.francoischalifour.com/docs/react/>

Add the React component and render a zoomable image with `<ImageZoom>`.

## Install the component

In a project configured for shadcn/ui, run:

```sh
npx shadcn@latest add @medium-zoom/image-zoom
```

The registry copies the component and stylesheet into your project and installs `medium-zoom`. You can edit those files to match your application.

## Display an image

Import `<ImageZoom>` from your configured components directory. With the usual shadcn/ui alias:

```tsx title="photo.tsx"
import { ImageZoom } from '@/components/ui/image-zoom'

export function Photo() {
  return (
    <ImageZoom
      src="/assets/images/ocean-sunset.jpg"
      alt="Ocean sunset"
      width={1_920}
      height={1_280}
    />
  )
}
```

Replace the image URL with your own. `alt` describes the image and labels the button. Width and height reserve space while the image loads.

`Enter` or `Space` on the button opens the image.
Press `Esc`, click the enlarged image or
its background, or scroll to close the zoom.

## Browser support

The React component follows the browser requirements of your React application and its build tooling.

## Next steps

- [Custom triggers](https://medium-zoom.francoischalifour.com/docs/guides/custom-react-triggers/): Compose a button with your own label and styles.
- [HD images](https://medium-zoom.francoischalifour.com/docs/guides/hd-images/): Load a larger image when zooming.
- [Controlled state](https://medium-zoom.francoischalifour.com/docs/guides/controlled-state/): Open and close images from another control.
- [\<ImageZoom>](https://medium-zoom.francoischalifour.com/docs/reference/react/image-zoom/): Look up image, zoom, and state props.
