> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/web/ui-customization/themes.md).

# Changing themes & colors using JavaScript

Easily change themes and colors using JavaScript with this helpful guide. Learn how to switch color themes using an API or custom CSS file path in the constructor. Explore options like setting a CSS f

You can change the color theme by either using an API or providing a path to a custom CSS file in the constructor.

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-65e220fee32585769c17f5bda484452cd26ee98d%2Fac52b6433adef6152f46ffdd12c73728a4440e35-1182x554.png?alt=media)

## Setting WebViewer constructor CSS option

The CSS option allows you to set a css file path while instantiating WebViewer. It's great if you have an external stylesheet file, for example.

**Example**

<pre class="language-js" data-line-numbers><code class="lang-js">WebViewer({
  licenseKey: '<code class="expression">visitor.claims.wvKey || "YOUR_LICENSE_KEY"</code>',
  path: 'lib',
  css: 'path/to/stylesheet.css'
}, document.getElementById('viewer'));
</code></pre>

## Using setTheme API

The API allows you to change the theme to another pre-defined theme on the fly. See [setTheme](https://sdk.apryse.com/api/web/UI.html#.setTheme__anchor) for details.

## Override CSS variables

Another option is to override CSS color variables. Just like changing the theme, this can be done on the fly (without re-instantiating WebViewer).

**Example**

{% tabs %}
{% tab title="JavaScript (SDK v11+)" %}

<pre class="language-js" data-line-numbers><code class="lang-js">WebViewer({
  licenseKey: '<code class="expression">visitor.claims.wvKey || "YOUR_LICENSE_KEY"</code>',
  path: 'lib',
}, document.getElementById('viewer')).then(instance => {
  /* #wc-viewer being the ID of the DOM element containing Webviewer */
  const style = document.querySelector("#wc-viewer").shadowRoot.host.style
  style.setProperty("--faded-text", "red")
});
</code></pre>

{% endtab %}

{% tab title="JavaScript (SDK v8.0+)" %}

<pre class="language-js" data-line-numbers><code class="lang-js">WebViewer({
  licenseKey: '<code class="expression">visitor.claims.wvKey || "YOUR_LICENSE_KEY"</code>',
  path: 'lib',
}, document.getElementById('viewer')).then(instance => {
  const style = instance.UI.iframeWindow.document.documentElement.style;
  style.setProperty(`--primary-button`, 'red');
  style.setProperty(`--primary-button-hover`, 'yellow');
});
</code></pre>

{% endtab %}

{% tab title="JavaScript (SDK v7.0+)" %}

<pre class="language-js" data-line-numbers><code class="lang-js">WebViewer({
  licenseKey: '<code class="expression">visitor.claims.wvKey || "YOUR_LICENSE_KEY"</code>',
  path: 'lib',
}, document.getElementById('viewer')).then(instance => {
  const style = instance.iframeWindow.document.documentElement.style;
  style.setProperty(`--primary-button`, 'red');
  style.setProperty(`--primary-button-hover`, 'yellow');
});
</code></pre>

{% endtab %}
{% endtabs %}

You can find the default css variables for both [light](https://github.com/ApryseSDK/webviewer-ui/blob/7.2/src/constants/light.scss) theme and [dark](https://github.com/ApryseSDK/webviewer-ui/blob/7.2/src/constants/dark.scss) theme in the github repository.

## Other properties

See the [customizing styles](/web/ui-customization/customizing-styles.md) for more information about customizing other properties.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/web/ui-customization/themes.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
