Skip to main content
DocSearch provides flexible theming options, including built-in light and dark modes, plus extensive CSS variable customization.

Theme Modes

DocSearch supports two built-in theme modes:
  • Light: Default theme optimized for light backgrounds
  • Dark: High-contrast theme for dark mode experiences

Setting the Theme

Use the theme prop to control the DocSearch appearance:

Dynamic Theme Switching

You can dynamically change the theme based on user preferences:

Theme Context Integration

Integrate with your site’s theme system:

How Theme Works

The theme prop sets a data-theme attribute on the document root:
This allows CSS to target different themes using attribute selectors:

CSS Variables

DocSearch uses CSS custom properties (variables) for all styling, making it easy to customize without overriding CSS classes.

Complete Variable Reference

Customizing Variables

You can override any CSS variable to match your brand:

Brand Colors

Border Radius

Typography

Complete Custom Theme Example

Here’s a complete example of a custom purple theme:

Scoped Theming

If you need DocSearch to have a different theme than your page:

TypeScript Interface

Best Practices

1

Match your site's theme

Use the theme prop to automatically sync DocSearch with your site’s light/dark mode.
2

Test both themes

If you customize CSS variables, make sure to test both light and dark modes.
3

Use semantic colors

Stick to the semantic variable names (primary, highlight, focus) rather than hardcoding specific colors.
4

Maintain contrast

Ensure text remains readable by maintaining sufficient color contrast, especially in custom themes.
5

Consider accessibility

Follow WCAG guidelines for color contrast ratios (4.5:1 for normal text, 3:1 for large text).

Common Customizations