---
title: "Theming"
description: "Restyle the viewer with CSS variables — try them live."
canonical_url: "https://kukson777.github.io/nuxt-image-viewer/docs/customization/theming"
---
# Theming

> Restyle the viewer with CSS variables — try them live.

The look of the viewer is a handful of CSS variables. Set them on `:root`, on `.image-viewer` or on any ancestor of the viewer.

## Theme builder

Pick a preset or your own colours, then click a preview. The code below the previews is ready to paste.

<theme-builder>



</theme-builder>

## Variables

<table>
<thead>
  <tr>
    <th>
      Variable
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        --image-viewer-bg
      </code>
    </td>
    
    <td>
      <code>
        #000
      </code>
    </td>
    
    <td>
      Backdrop colour. Its opacity is the <a href="https://kukson777.github.io/nuxt-image-viewer/docs/customization/options#bgopacity">
        <code>
          bgOpacity
        </code>
      </a>
      
       option.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --image-viewer-color
      </code>
    </td>
    
    <td>
      <code>
        #fff
      </code>
    </td>
    
    <td>
      Text and icons.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --image-viewer-font
      </code>
    </td>
    
    <td>
      <code>
        inherit
      </code>
    </td>
    
    <td>
      Font family.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --image-viewer-counter-color
      </code>
    </td>
    
    <td>
      <code>
        --image-viewer-color
      </code>
    </td>
    
    <td>
      The <code>
        2 / 5
      </code>
      
       counter.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --image-viewer-button-bg
      </code>
    </td>
    
    <td>
      <code>
        rgb(255 255 255 / 0.12)
      </code>
    </td>
    
    <td>
      Button backing.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --image-viewer-button-bg-hover
      </code>
    </td>
    
    <td>
      <code>
        rgb(255 255 255 / 0.22)
      </code>
    </td>
    
    <td>
      Button backing on hover and press.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --image-viewer-button-color
      </code>
    </td>
    
    <td>
      <code>
        --image-viewer-color
      </code>
    </td>
    
    <td>
      Button icon.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --image-viewer-button-size
      </code>
    </td>
    
    <td>
      <code>
        44px
      </code>
    </td>
    
    <td>
      Width and height of buttons.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --image-viewer-button-radius
      </code>
    </td>
    
    <td>
      <code>
        9999px
      </code>
    </td>
    
    <td>
      Button corners.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --image-viewer-icon-size
      </code>
    </td>
    
    <td>
      <code>
        24px
      </code>
    </td>
    
    <td>
      Icon size.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --image-viewer-caption-bg
      </code>
    </td>
    
    <td>
      <code>
        rgb(0 0 0 / 0.6)
      </code>
    </td>
    
    <td>
      Caption backing.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --image-viewer-caption-color
      </code>
    </td>
    
    <td>
      <code>
        --image-viewer-color
      </code>
    </td>
    
    <td>
      Caption text.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --image-viewer-caption-radius
      </code>
    </td>
    
    <td>
      <code>
        8px
      </code>
    </td>
    
    <td>
      Caption corners.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --image-viewer-caption-font-size
      </code>
    </td>
    
    <td>
      <code>
        14px
      </code>
    </td>
    
    <td>
      Caption text size.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --image-viewer-focus-color
      </code>
    </td>
    
    <td>
      <code>
        #fff
      </code>
      
       in the viewer, <code>
        #2563eb
      </code>
      
       on page images
    </td>
    
    <td>
      Focus ring.
    </td>
  </tr>
</tbody>
</table>

## Following your colour mode

Variables follow your own selectors, so a dark-mode viewer on a light site — or the other way round — is a few lines:

```css [assets/css/main.css]
:root {
  --image-viewer-bg: #fff;
  --image-viewer-color: #18181b;
  --image-viewer-button-bg: rgb(0 0 0 / 0.06);
  --image-viewer-button-bg-hover: rgb(0 0 0 / 0.12);
  --image-viewer-caption-bg: rgb(255 255 255 / 0.9);
}

.dark {
  --image-viewer-bg: #000;
  --image-viewer-color: #fff;
  --image-viewer-button-bg: rgb(255 255 255 / 0.12);
  --image-viewer-button-bg-hover: rgb(255 255 255 / 0.22);
  --image-viewer-caption-bg: rgb(0 0 0 / 0.6);
}
```

## With Tailwind or Nuxt UI

Point the variables at your design tokens:

```css [assets/css/main.css]
:root {
  --image-viewer-button-bg: var(--ui-primary);
  --image-viewer-button-bg-hover: color-mix(in srgb, var(--ui-primary) 85%, white);
  --image-viewer-focus-color: var(--ui-primary);
  --image-viewer-font: var(--font-sans);
}
```

Need more than variables? Every part has a [BEM class](https://kukson777.github.io/nuxt-image-viewer/docs/customization/styling).


## Sitemap

See the full [sitemap](https://kukson777.github.io/nuxt-image-viewer/sitemap.md) for all pages.
