Some test text!

Search
Hamburger Icon

Web / Guides / Styles

Customizing WebViewer UI Styles

WebViewer UI supports style customizations using an API, through a CSS file or using the Modular UI.

Modular WebViewer UI

See this guide for more information about styling WebViewer with Modular UI.

Changing color theme

See this guide for more information about changing the theme.

Changing CSS properties

If you want to change more CSS properties, you can use a custom stylesheet to define them using normal CSS selectors.

To make the customization easier and consistent, WebViewer UI provides 5 top level classes:

  • Button
  • Panel
  • Overlay
  • Popup
  • Modal

Example

WebViewer({
  licenseKey: 'YOUR_LICENSE_KEY',
  path: 'lib',
  css: 'path/to/stylesheet.css'
}, document.getElementById('viewer'));
.Button.Icon {
  color: red;
}

.Panel.open {
  transition: all ease 0.5s;
}

Accessing DOM directly

WebViewer's UI will be loaded inside an iframe, so to access the UI DOM elements you can use the iframeWindow property.

WebViewer({
  // ...
}).then(instance => {
  const iframeDoc = instance.UI.iframeWindow.document;
  const zoomOverlay = iframeDoc.querySelector('[data-element="zoomOverlay"]');
});

Applying the :host CSS selector with WebViewer WebComponent

When using an external CSS file in WebViewer with a WebComponent and styling a custom modal panel or an existing panel, you should utilize the :host CSS pseudo-class selector.

The :host CSS pseudo-class targets the shadow host of the shadow DOM where the CSS is applied, enabling you to select the WebViewer WebComponent element.

Here’s an example of how this is used.

WebViewer.WebCompnent({
  css: 'path/main.css'
}).then(instance => {
  // ...
});

And here is the content of our main.css file.

.DocumentContainer {
    background: tomato;
}

:host {
    --icon-color: #00a5e4 !important;
}

WebViewer with new background color and changed icon color WebViewer UI

Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales