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'],
}):root {
--image-viewer-bg: #000000;
--image-viewer-color: #ffffff;
--image-viewer-button-bg: rgb(255 255 255 / 0.12);
--image-viewer-button-bg-hover: rgb(255 255 255 / 0.22);
--image-viewer-button-size: 44px;
--image-viewer-button-radius: 22px;
--image-viewer-caption-bg: rgb(0 0 0 / 0.6);
--image-viewer-focus-color: #ffffff;
}Variables
| Variable | Default | |
|---|---|---|
--image-viewer-bg | #000 | Backdrop colour. Its opacity is the bgOpacity option. |
--image-viewer-color | #fff | Text and icons. |
--image-viewer-font | inherit | Font family. |
--image-viewer-counter-color | --image-viewer-color | The 2 / 5 counter. |
--image-viewer-button-bg | rgb(255 255 255 / 0.12) | Button backing. |
--image-viewer-button-bg-hover | rgb(255 255 255 / 0.22) | Button backing on hover and press. |
--image-viewer-button-color | --image-viewer-color | Button icon. |
--image-viewer-button-size | 44px | Width and height of buttons. |
--image-viewer-button-radius | 9999px | Button corners. |
--image-viewer-icon-size | 24px | Icon size. |
--image-viewer-caption-bg | rgb(0 0 0 / 0.6) | Caption backing. |
--image-viewer-caption-color | --image-viewer-color | Caption text. |
--image-viewer-caption-radius | 8px | Caption corners. |
--image-viewer-caption-font-size | 14px | Caption text size. |
--image-viewer-focus-color | #fff in the viewer, #2563eb on page images | Focus 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.