Appearance
Media viewer
Shows a mediafile in the viewer that fits its type, under one shared toolbar.
base-mediaviewernew--defaultOpen in Storybook ↗When to use
- Mediafiles on a record's detail page, in a media panel or in the preview.
- Whenever people need to look closely: zoom into an image, page through a PDF, play a recording.
When not to use
- Thumbnails in lists and cards: show the image itself, not a viewer.
- Actions on the mediafile record (edit, delete, link): those belong in the panel or the list row, not in the viewer toolbar.
Anatomy
- Toolbar: a white bar over the top of the viewer,
--viewer-toolbar-heighthigh, with a soft shadow. Viewer actions on the left, the file arrows in the middle when there are several files, mode actions on the right. Below 768px it moves to the bottom of the viewer and scrolls sideways when the buttons don't fit. - Viewer buttons: icon buttons of
--viewer-button-widthby--viewer-button-height, with a--color-accent-washhover on--viewer-button-radius. Text buttons such as Reset get--viewer-text-button-padding-x. A disabled button uses--color-text-disabled. - Viewer: the file itself, on a checkerboard background.
- File arrows (optional): Previous file and Next file, when the record has more than one mediafile.
The viewer is picked from the file's type:
| Type | Viewer |
|---|---|
| image | deep-zoom image viewer (OpenSeadragon, IIIF) |
| page-by-page PDF viewer | |
| text | the text, sanitised, with adjustable size |
| audio, video | the browser's own player |
| external link | the linked page in a frame, or a link to open it |
Variants
The toolbar shows what the viewer can do:
| Mode | Left | Right |
|---|---|---|
| Image | fullscreen, zoom in, zoom out, rotate, crop tools (when cropping is on), download, recrop, Show original / Show cropped | Download resized image, Reset |
| fullscreen, zoom in, zoom out, download | ‹ page number / count › | |
| Text | zoom in, zoom out, download | — |
| Audio, video | download | — |
components-viewertoolbar--modesOpen in Storybook ↗base-pdfviewer--defaultOpen in Storybook ↗- Image: drag to pan, scroll to zoom. Reset fits the image again. With cropping on, the crop button draws a selection and the clear button removes it; both are disabled with the tooltip Select an item first to enable this tool until a file is selected.
- PDF: the arrows are disabled on the first and last page. A typed page number outside the document is corrected to the nearest page.
- Text: the size goes from 50% to 300% in steps of 25%. When unsafe content was removed, a warning band under the toolbar says so (
--color-warning-bgwith a--viewer-banner-accent-widthbar in--color-warning), with Dismiss.
base-textviewer--defaultOpen in Storybook ↗States
| State | What you see | Trigger |
|---|---|---|
| Loading | a spinner | the file loads |
| Processing | Processing the image... with a crossed-out image icon | the image has no display version yet |
| Downloading | a spinner in place of the download button | download |
| No viewer | There is currently no viewer available for files with type '{mimetype}' and Download file | a type without a viewer |
| No file type | No viewer available for this file | the file has no type |
| External link | a frame with the URL and Open link, or only Open link | the mediafile is a link |
base-mediaviewernew--unsupportedOpen in Storybook ↗Keyboard & accessibility
- The toolbar is a
role="toolbar"named Viewer actions. - Every toolbar button is a real
<button>with a name: Fullscreen, Zoom in, Zoom out, Rotate, Download file, Previous page, Next page. The page field is named Page number. - Entering fullscreen is announced: Fullscreen. Press Escape to exit. Escape leaves fullscreen.
- Audio and video use the browser's controls, which are keyboard accessible.
Content
- Button names are short verbs or nouns, the same in every viewer: Zoom in, Download file.
- Translation keys live under
media-viewer.*, plustooltip.media-viewer.*for the crop tools andtext-viewer.*for the warning band.
Related
Map viewer · Preview panel · Upload · Loading