# ImageViewer

> An image you can zoom, pan, rotate and download, with keyboard and touch support.

Status: beta. Category: Viewers.

```ts
import { ImageViewer } from '@glyphui/viewers/media'
```

Exports: `ImageViewer`, `imageViewerStyles`.

## Notes

- No extra packages needed.
- Zoom with the buttons, ⌘ or Ctrl + scroll, a trackpad pinch or two fingers. Plain scrolling still scrolls the page.
- Keyboard: + and − zoom, 0 fits, 1 shows actual size, R rotates, arrow keys pan.

## ImageViewer props

| Prop | Type | Default | Description |
|---|---|---|---|
| `alt` (required) | `string` |  | Alternative text. Required for meaningful images. |
| `source` (required) | `ViewerSource` |  | The image: a URL, a File/Blob, or bytes. |
| `bordered` | `boolean` |  | Draw the viewer as a bordered card. Default true. |
| `className` | `string` |  |  |
| `downloadable` | `boolean` |  | Show a download button. Default true. |
| `height` | `string \| number` |  | Height of the viewer. Default 420. |
| `maxZoom` | `number` |  |  |
| `minZoom` | `number` |  | Zoom limits, as a scale of the natural size. Default 0.05–16. |

## Example: Zoom and pan

Double-click to zoom in, drag to pan.

```tsx
import { ImageViewer } from '@glyphui/viewers/media'
import { fixture } from '../../../lib/fixtures'

export default function Example() {
  return (
    <ImageViewer
      source={fixture('aurora.jpg')}
      alt="A blue-to-green gradient with a faint grid"
      height={400}
      className="w-full"
    />
  )
}
```

Live page: https://glyphui.xyz/components/image-viewer
