Guide
Accessibility
Dialog semantics, keyboard, focus and labels.
The dialog
- The viewer is a
role="dialog"witharia-modal="true", named by thelabels.dialogoption. - Focus moves into the dialog when it opens. Tab and Shift + Tab go round its buttons and never leave it.
- On close, focus returns to the page image the viewer closed into — or, when opened from code without an element, to whatever had focus before
open(). - Slides other than the current one are
aria-hidden; the counter is a polite live region, so screen readers announce3 / 7as you scroll. - Every button has an accessible name and visible focus (
--image-viewer-focus-color).
Page images
<ZoomImage>is focusable (tabindex="0") and opens with Enter or Space.altfalls back to the caption. Passaltexplicitly when the caption isn't a good description.- Page images get
cursor: zoom-inand a focus ring — restyle them with[data-image-viewer].
Custom labels
All names are options, globally or per call. Override only the ones you want to change — the rest keep their English defaults:
nuxt.config.ts
export default defineNuxtConfig({
imageViewer: {
labels: {
dialog: 'Photo gallery',
close: 'Close gallery',
prev: 'Previous photo',
next: 'Next photo',
},
},
})
For other languages, pass translated labels per call — with @nuxtjs/i18n: open(items, 0, { labels: { close: t('viewer.close') } }). See the i18n recipe.
Motion
prefers-reduced-motion: reduce turns the animations off — see Gestures.