theme prop, which controls the visual appearance of the search modal and button.
Theme Type
Thetheme prop accepts a simple string value:
Usage
Controls the visual theme of DocSearch components. The theme affects:
- Search button appearance
- Modal background and text colors
- Search results styling
- Icon colors
- Border and shadow styles
Dynamic Theme Switching
You can dynamically switch themes based on your application’s theme settings:Custom Styling
While thetheme prop provides basic light/dark mode support, you can further customize DocSearch appearance using CSS variables and custom CSS.
CSS Variables
DocSearch uses CSS custom properties that you can override:Custom CSS Classes
You can target specific DocSearch classes for more granular control:Example: Custom Brand Colors
Theme Implementation
The theme implementation in DocSearch uses a React hook that applies the appropriate CSS class to the document:data-theme attribute to your HTML element:
Best Practices
Match Your Site's Theme
Match Your Site's Theme
Always ensure DocSearch’s theme matches your site’s overall theme for a consistent user experience. Use dynamic theme switching to keep them in sync.
Test Both Themes
Test Both Themes
Always test your custom styling in both light and dark modes to ensure readability and proper contrast ratios.
Use CSS Variables
Use CSS Variables
Prefer CSS variables over hard-coded values for easier theme maintenance and consistency.
Respect User Preferences
Respect User Preferences
Consider detecting and respecting the user’s system theme preference using
prefers-color-scheme media query.Related Resources
- Configuration - Full configuration options
- Translations - Localization options
- DocSearch CSS Repository - Full CSS source code
