Skip to Content
AnyPreview

Theming

Switch AnyPreview between light and dark, and restyle the viewer to match your app with --dp-* CSS variables.

theme is 'auto' by default, following the reader's system setting. Set 'light' or 'dark' to follow your app's own switch.

<DocViewer source={file} theme={isDark ? 'dark' : 'light'} />

CSS variables

Every colour, the font and the radius are CSS variables on .dp-root. Override them in your stylesheet:

.dp-root {
  --dp-font: 'Inter Variable', system-ui, sans-serif;
  --dp-accent: #7c3aed;
  --dp-radius: 12px;
}
.dp-root[data-theme='dark'] {
  --dp-bg: #0b0b12;
}
VariableUsed for
--dp-bg, --dp-surface, --dp-canvasToolbar and panels, raised surfaces, the area behind pages
--dp-text, --dp-mutedText and secondary text
--dp-borderDividers and outlines
--dp-accent, --dp-accent-text, --dp-accent-strongSelection, focus rings, active controls
--dp-font, --dp-monoUI and code fonts
--dp-radius, --dp-page-shadowCorner radius and page shadow

Search matches use the CSS Custom Highlight API, so you can restyle them with ::highlight(dp-search) and ::highlight(dp-search-current).

A document's own colours, fonts and tables are shown as authored in both themes.

On this page