# Dark mode

Control whether surveys and messages render in their light or dark look, or let Screeb follow your app.

Surveys and messages follow the dark mode of your site. In dark mode they draw the dark values of their theme. A theme without dark values looks the same in both modes. You set the dark values in the theme editor of the Screeb admin.

## Automatic detection

By default the color scheme is `"auto"`.

Screeb picks the first signal it finds, in this order:

1. The appearance of the mobile app, when the page runs in the webview of an app.
2. A marker your page sets on `<html>`: a `dark` or `light` class, a `data-theme`, `data-color-scheme`, `data-mode` or `data-bs-theme` attribute set to `dark` or `light`, or a single `color-scheme` value.
3. The device setting of the visitor.

Most sites that have a dark mode toggle already set one of these markers, so you need no code.

## Force a color scheme

Set `colorScheme` in `window.ScreebConfig` before the tag loads to force `"light"` or `"dark"` from the start:

```html
<script>
  window.ScreebConfig = { colorScheme: "dark" };

  (function(s,c,r,ee,b){
    s.ScreebObject=r;
    if(typeof s[r]!="function")s[r]=function(){var d=arguments;return new Promise(function(o,k){(s[r].q=s[r].q||[]).push({v:1,args:d,ok:o,ko:k})})};
    b=c.createElement("script");b.id=r;b.src=ee;c.head.appendChild(b);
  })(window,document,"$screeb","<TAG-ENDPOINT>/tag.js");

  $screeb("init", "<YOUR-CHANNEL-ID>");
</script>
```

## Change it at runtime

If your app has its own light and dark toggle, tell Screeb when it changes. The call overrides `colorScheme` from `window.ScreebConfig`:

```js
$screeb("color-scheme.set", "light");
```

Pass `"auto"` to go back to automatic detection. The call is allowed before `init`, so the first survey or message already uses the right scheme.

> [!NOTE]
> `@screeb/sdk-browser` and the framework modules do not expose a `setColorScheme` method yet. It comes in a later release; until then, call `$screeb("color-scheme.set", scheme)`.
