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;
}| Variable | Used for |
|---|---|
--dp-bg, --dp-surface, --dp-canvas | Toolbar and panels, raised surfaces, the area behind pages |
--dp-text, --dp-muted | Text and secondary text |
--dp-border | Dividers and outlines |
--dp-accent, --dp-accent-text, --dp-accent-strong | Selection, focus rings, active controls |
--dp-font, --dp-mono | UI and code fonts |
--dp-radius, --dp-page-shadow | Corner 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.
File type detection
How AnyPreview identifies a file from its bytes (magic numbers, ZIP and compound-file structure, text sniffing) and how to use detect() on its own.
Search and navigation
Full-text search across PDF, Word, PowerPoint, Excel, Markdown, code, CSV and JSON, plus thumbnails, outlines and keyboard navigation in AnyPreview.