# Bring images closer with JavaScript

> Lightweight image zoom for the web. Zero dependencies, any framework, React via shadcn.

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

## Install

```sh
npm install medium-zoom
```

- **3 kB. Zero dependencies.** A lightweight lightbox alternative.
- **Any framework. TypeScript ready.** Use with React, Angular, Vue, Svelte, Astro, or plain HTML.
- **High-resolution on demand.** Load sharper images only when zooming.

## Pick your images.

Add `data-zoomable` to your images, then attach the zoom. Styles come included.

```js title="app.js"
import mediumZoom from 'medium-zoom'

mediumZoom('[data-zoomable]', {
  margin: 24,
  background: 'var(--background, #fff)',
})
```

Set the spacing, match your background, or load a sharper image on zoom. [Read the API reference](https://medium-zoom.francoischalifour.com/docs/reference/javascript/medium-zoom/)

## Start with your stack.

The same zoom, wherever you build.

- [React + TypeScript](https://medium-zoom.francoischalifour.com/react): A component you own. Install with the shadcn CLI. Own the source. Match your theme.
- [Angular](https://medium-zoom.francoischalifour.com/docs/integrations/angular/): A directive for Angular and Angular SSR.
- [Vue](https://medium-zoom.francoischalifour.com/docs/integrations/vue/): A component for Vue and Nuxt.
- [Svelte](https://medium-zoom.francoischalifour.com/docs/integrations/svelte/): A component for Svelte and SvelteKit.
- [Solid](https://medium-zoom.francoischalifour.com/docs/integrations/solid/): A component for Solid and SolidStart.
- [Astro](https://medium-zoom.francoischalifour.com/docs/integrations/astro/): A component for optimized Astro images.
- [JavaScript](https://medium-zoom.francoischalifour.com/docs/javascript/): Attach zoom with a selector.

## Add zoom to your project.

Start with a few lines of JavaScript. [Read the documentation](https://medium-zoom.francoischalifour.com/docs/).
