Customization

Theming

Restyle the viewer with CSS variables — try them live.

The look of the viewer is a handful of CSS variables. Set them on :root, on .image-viewer or on any ancestor of the viewer.

Theme builder

Pick a preset or your own colours, then click a preview. The code below the previews is ready to paste.

Preset

Click a preview to open it with this theme.

export default defineNuxtConfig({
  modules: ['nuxt-image-viewer'],
})

Variables

VariableDefault
--image-viewer-bg#000Backdrop colour. Its opacity is the bgOpacity option.
--image-viewer-color#fffText and icons.
--image-viewer-fontinheritFont family.
--image-viewer-counter-color--image-viewer-colorThe 2 / 5 counter.
--image-viewer-button-bgrgb(255 255 255 / 0.12)Button backing.
--image-viewer-button-bg-hoverrgb(255 255 255 / 0.22)Button backing on hover and press.
--image-viewer-button-color--image-viewer-colorButton icon.
--image-viewer-button-size44pxWidth and height of buttons.
--image-viewer-button-radius9999pxButton corners.
--image-viewer-icon-size24pxIcon size.
--image-viewer-caption-bgrgb(0 0 0 / 0.6)Caption backing.
--image-viewer-caption-color--image-viewer-colorCaption text.
--image-viewer-caption-radius8pxCaption corners.
--image-viewer-caption-font-size14pxCaption text size.
--image-viewer-focus-color#fff in the viewer, #2563eb on page imagesFocus ring.

Following your colour mode

Variables follow your own selectors, so a dark-mode viewer on a light site — or the other way round — is a few lines:

assets/css/main.css
:root {
  --image-viewer-bg: #fff;
  --image-viewer-color: #18181b;
  --image-viewer-button-bg: rgb(0 0 0 / 0.06);
  --image-viewer-button-bg-hover: rgb(0 0 0 / 0.12);
  --image-viewer-caption-bg: rgb(255 255 255 / 0.9);
}

.dark {
  --image-viewer-bg: #000;
  --image-viewer-color: #fff;
  --image-viewer-button-bg: rgb(255 255 255 / 0.12);
  --image-viewer-button-bg-hover: rgb(255 255 255 / 0.22);
  --image-viewer-caption-bg: rgb(0 0 0 / 0.6);
}

With Tailwind or Nuxt UI

Point the variables at your design tokens:

assets/css/main.css
:root {
  --image-viewer-button-bg: var(--ui-primary);
  --image-viewer-button-bg-hover: color-mix(in srgb, var(--ui-primary) 85%, white);
  --image-viewer-focus-color: var(--ui-primary);
  --image-viewer-font: var(--font-sans);
}

Need more than variables? Every part has a BEM class.