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 thetheme 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
Thetheme prop sets a data-theme attribute on the document root:
CSS Variables
DocSearch uses CSS custom properties (variables) for all styling, making it easy to customize without overriding CSS classes.Complete Variable Reference
Light Theme Variables
Light Theme Variables
Dark Theme Variables
Dark Theme Variables
Customizing Variables
You can override any CSS variable to match your brand:Brand Colors
Modal Size
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
Match your site's theme
Use the
theme prop to automatically sync DocSearch with your site’s light/dark mode.Use semantic colors
Stick to the semantic variable names (primary, highlight, focus) rather than hardcoding specific colors.
Maintain contrast
Ensure text remains readable by maintaining sufficient color contrast, especially in custom themes.
Common Customizations
Match Tailwind CSS Colors
Match Tailwind CSS Colors
Rounded Modal
Rounded Modal
Compact Layout
Compact Layout
High Contrast Mode
High Contrast Mode
