Customization
Styling with classes
BEM classes on every part, a cascade layer, or no default styles at all.
The cascade layer
The default styles live in the image-viewer cascade layer. Any rule of yours outside a layer wins over them regardless of specificity — no !important, no fighting selectors:
.image-viewer__caption-text {
font-style: italic;
letter-spacing: 0.01em;
}
.image-viewer__counter {
font-family: ui-monospace, monospace;
}
The layer is declared after base, so Tailwind's preflight never breaks the viewer images.
Classes
.image-viewer the dialog layer — --zoomed, --closing, --idle, --idle-caption
├─ .image-viewer__backdrop backdrop, opacity set inline
├─ .image-viewer__track the strip, moved by transform
│ └─ .image-viewer__slide one slide — --current
│ └─ .image-viewer__frame fitted image box, positioned inline
│ └─ .image-viewer__zoom zoomed and panned layer
│ └─ .image-viewer__img --thumb (page copy), --full, --loaded
└─ .image-viewer__ui controls layer
├─ .image-viewer__toolbar
│ ├─ .image-viewer__counter
│ └─ .image-viewer__buttons
│ └─ .image-viewer__button --zoom, --fullscreen, --close
├─ .image-viewer__button.image-viewer__arrow --prev, --next
└─ .image-viewer__caption
└─ .image-viewer__caption-text
Icons are inline SVG with the .image-viewer__icon class, drawn with stroke: currentColor.
Examples
Buttons as squares in the corner:
.image-viewer__buttons {
gap: 0;
}
.image-viewer__button {
border-radius: 0;
}
Caption at the top instead of the bottom:
.image-viewer__caption {
top: 72px;
bottom: auto;
}
Arrows on touch screens too:
@media (pointer: coarse) {
.image-viewer__arrow {
display: inline-flex;
}
}
From scratch
Turn the default styles off and write your own:
nuxt.config.ts
export default defineNuxtConfig({
imageViewer: {
css: false,
},
})
Without the default styles you own the layout too. The minimum for a working viewer:
.image-viewer is position: fixed over the window with overflow: hidden and touch-action: none; __backdrop, __track and __ui are position: absolute; inset: 0; __slide and __frame are position: absolute; __zoom and __img fill their parent. Start from the default stylesheet.