Back to the main demo

Shadow DOM style isolation

This page has its own heading and button styles and does not import the viewer's stylesheet. Mount the viewer to see that its styles do not reset this page, and the page's broad button rule does not style the viewer's controls.

Viewer is not mounted.

Standard integration

The constructor creates an open shadow root automatically; no separate Shadow DOM API is needed. CSS variables on the host are inherited by the viewer.

<div id="viewer"></div>
<style>
  #viewer { --iiif-accent: #1d4ed8; --iiif-accent-hover: #1e40af; }
</style>
<script type="module">
  import { IIIFViewer } from '@micropasts/iiif-viewer';
  const viewer = new IIIFViewer('#viewer', {
    manifestUrl: './examples/caryatid-manifest.json',
    theme: 'light',
  });
  // Call viewer.destroy() when removing the viewer.
</script>