# Fumadocs UI (the default theme of Fumadocs): Zoomable Image
URL: /docs/ui/components/image-zoom
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/ui/components/image-zoom.mdx

Allow zoom-in images in your documentation

Install to your codebase:

```bash
npx @fumadocs/cli@latest add image-zoom
```

## Usage [#usage]

Replace `img` with `ImageZoom` in your MDX components.

```tsx title="components/mdx.tsx"
import { ImageZoom } from 'fumadocs-ui/components/image-zoom';
import defaultComponents from 'fumadocs-ui/mdx';
import type { MDXComponents } from 'mdx/types';

export function getMDXComponents(components?: MDXComponents) {
  return {
    ...defaultComponents,
    // [!code ++]
    img: (props) => <ImageZoom {...(props as any)} />,
    ...components,
  } satisfies MDXComponents;
}
```

Now every image opens in a viewer built on [ramka](https://ramka.dev). Zoom in with a double click, pinch or the `+`/`-` keys, and swipe down to close it on touch screens.

```mdx
![Test](/banner.png)
```

### Image Optimization [#image-optimization]

On Next.js, a default [`sizes` property](https://nextjs.org/docs/app/api-reference/components/image#sizes) will be defined for `<Image />` component if not specified.

## Lightbox [#lightbox]

Zoomable images inside `<Lightbox />` open in one viewer. Browse them with arrow keys, swipes or the thumbnails.

<Wrapper>
<Lightbox>
<div className="not-prose grid grid-cols-2 gap-2">
  
<ImageZoom src="/docs/notebook-tab-mode.png" width={1453} height={963} alt="Notebook layout" title="Tab mode: navbar" />

  
<ImageZoom src="/docs/notebook-nav-mode.png" width={1451} height={954} alt="Notebook layout" />

</div>
</Lightbox>
</Wrapper>

Wrap your page content to browse every image of the page:

```tsx title="app/docs/[[...slug]]/page.tsx"
import { Lightbox } from 'fumadocs-ui/components/image-zoom';

<DocsBody>
  {/* [!code ++] */}
  <Lightbox>
    <MDX components={getMDXComponents()} />
    {/* [!code ++] */}
  </Lightbox>
</DocsBody>;
```

### Caption [#caption]

The image title is shown as caption.

```mdx
![Notebook Layout](/notebook.png 'Tab mode: navbar')
```

Pass `caption` for rich content like links.

```tsx
<ImageZoom
  src="/notebook.png"
  alt="Notebook Layout"
  caption={
    <>
      See <a href="/docs/ui/layouts/notebook">Notebook Layout</a>
    </>
  }
/>
```

### Gallery [#gallery]

To browse a set of images on its own, wrap them in another `<Lightbox />`, for example as a grid:

```mdx
<Lightbox>
<div className="not-prose grid grid-cols-2 gap-2">

![Light Mode](/light.png)

![Dark Mode](/dark.png)

</div>
</Lightbox>
```