---
title: "Options"
description: "Global defaults in nuxt.config and overrides per open() call."
canonical_url: "https://kukson777.github.io/nuxt-image-viewer/docs/customization/options"
---
# Options

> Global defaults in nuxt.config and overrides per open() call.

Set the options under the `imageViewer` key. All of them are optional.

```ts [nuxt.config.ts]
export default defineNuxtConfig({
  modules: ['nuxt-image-viewer'],
  imageViewer: {
    bgOpacity: 0.9,
    maxZoom: 6,
    ui: { fullscreen: false },
    hide: ['#intercom-container'],
  },
})
```

Options marked **per call** can also be passed to [`open()`](https://kukson777.github.io/nuxt-image-viewer/docs/guide/open-from-code) for one viewer — the rest of the options still come from `nuxt.config`:

```ts
useImageViewer().open(items, 0, { loop: false, ui: { counter: false } })
```

## Behaviour

### zIndex

`number` · default `1000` · per call

z-index of the viewer layer. Raise it above your own fixed bars and chat widgets.

### bgOpacity

`number` · default `0.8` · per call

Opacity of the backdrop, `0`–`1`. `1` hides the page completely. The colour is the [`--image-viewer-bg`](https://kukson777.github.io/nuxt-image-viewer/docs/customization/theming) variable.

### loop

`boolean` · default `true` · per call

Endless strip: the first image follows the last one. Needs at least 3 images — with two, the neighbour on both sides would be the same slide.

### spacing

`number` · default `0.1` · per call

Gap between slides as a share of the viewport width.

### maxZoom

`number` · default `4` · per call

Upper zoom limit relative to the image fitted into the screen. Images zoom up to their natural size, but at least 2×, and never above this value.

### closeOnVerticalDrag

`boolean` · default `true` · per call

Close by dragging the image up or down. When off, a vertical drag scrolls the strip like a horizontal one.

### closeOnBackdropClick

`boolean` · default `true` · per call

Close by a click or a tap outside the image.

### idleDelay

`number` · default `4000` · per call

Fade the controls — buttons, arrows, counter — out after the mouse rests for this long, in milliseconds, so the image is left alone. Any mouse move or key brings them back; over a button they stay. `0` keeps the controls shown. Only on devices with a mouse: touch screens keep the controls.

### idleHidesCaption

`boolean` · default `true` · per call

Fade the caption out together with the controls. `false` leaves the image with its caption.

```ts
// A clean image after 2 s, but keep the caption
const viewer = useImageViewer()

viewer.open(items, 0, { idleDelay: 2000, idleHidesCaption: false })
```

## Interface

### ui

`object` · per call, partial

Which controls to show. All `true` by default.

<table>
<thead>
  <tr>
    <th>
      Key
    </th>
    
    <th>
      
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        counter
      </code>
    </td>
    
    <td>
      <code>
        2 / 5
      </code>
      
       in the top left corner. Hidden for a single image.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        zoom
      </code>
    </td>
    
    <td>
      Zoom in / out button.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        fullscreen
      </code>
    </td>
    
    <td>
      Fullscreen button — only where the Fullscreen API exists (not on iPhone).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        close
      </code>
    </td>
    
    <td>
      Close button.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        arrows
      </code>
    </td>
    
    <td>
      Previous / next buttons. Hidden on touch screens anyway.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        caption
      </code>
    </td>
    
    <td>
      Caption under the image.
    </td>
  </tr>
</tbody>
</table>

### labels

`object` · per call, partial

Accessible names of the dialog and its buttons. English by default.

```ts
labels: {
  dialog: 'Image viewer',
  close: 'Close',
  zoomIn: 'Zoom in',
  zoomOut: 'Zoom out',
  fullscreen: 'Fullscreen',
  exitFullscreen: 'Exit fullscreen',
  prev: 'Previous',
  next: 'Next',
}
```

## Page integration

### openClass

`string` · default `'image-viewer-open'`

Class added to `<html>` while the viewer is open — handy to hide or adjust things of your own:

```css
.image-viewer-open .cookie-banner {
  display: none;
}
```

### hide

`string[]` · default `[]`

CSS selectors hidden while the viewer is open. Chat widgets and other things that sit above every layer are the usual suspects.

```ts
hide: ['jdiv', '#intercom-container', '.crisp-client']
```

### autoOpen

`boolean` · default `true`

Open the viewer on click, Enter and Space on any `img[data-image-viewer]`. Turn it off to open it only from code.

## Build

These are read when the app builds and can't be changed per call.

### componentName

`string | false` · default `'ZoomImage'`

Name of the image component. `false` — don't register it and mark images with the [data attributes](https://kukson777.github.io/nuxt-image-viewer/docs/guide/plain-images) yourself.

### nuxtImage

`boolean | 'auto'` · default `'auto'`

Render `<NuxtImg>` inside the image component. `'auto'` — when `@nuxt/image` is installed.

### css

`boolean` · default `true`

Include the default styles. Turn off to [style from scratch](https://kukson777.github.io/nuxt-image-viewer/docs/customization/styling).

## Runtime config

The runtime options also live in `useRuntimeConfig().public.imageViewer`, so they can be overridden with environment variables:

```bash [.env]
NUXT_PUBLIC_IMAGE_VIEWER_Z_INDEX=2000
NUXT_PUBLIC_IMAGE_VIEWER_BG_OPACITY=1
```


## Sitemap

See the full [sitemap](https://kukson777.github.io/nuxt-image-viewer/sitemap.md) for all pages.
