Enable Dark Mode in Init Live Search

Init Live Search is the official live search plugin from Init HTML for WordPress, designed for speed, smooth performance, and great user interface compatibility. In this article, we’ll show you how to enable dark mode for the search interface — a handy feature if your website uses a dark background or wants to provide a modern, consistent user experience.

Enable Dark Mode in Init Live Search

What is Dark Mode in Init Live Search?

Dark mode helps reduce eye strain at night by minimizing blue light and is increasingly popular across the web. Init Live Search fully supports dark mode — you can enable it via JavaScript or by setting a config before the plugin initializes.

1. Enable dark mode via dark class

The quickest way to enable dark mode is by adding the dark class to the search modal after it has been rendered. For example:

document.querySelector('#ils-modal')?.classList.add('dark');

Note: Make sure this code runs after the modal is rendered. You can trigger it when the user focuses on the search input.

2. Configure dark mode before plugin loads

This is the cleaner approach if you want the plugin to always initialize with dark mode:

window.InitPluginSuiteLiveSearchConfig = {
    theme: 'dark'
};

Place this script before including the plugin file (or inline in the <head>). Available values include:

  • 'light' – Always use light mode
  • 'dark' – Always use dark mode
  • 'auto' – Automatically detect light/dark mode based on user’s system preference

Example: Automatically use dark mode if body has class uk-light:

document.addEventListener('DOMContentLoaded', function () {
    if (document.body.classList.contains('uk-light')) {
        window.InitPluginSuiteLiveSearchConfig = {
            theme: 'dark'
        };
    }
});

The code above automatically enables dark mode if your site uses the uk-light class on the <body>.

Benefits of Enabling Dark Mode

  • Consistent UI: If your site already supports dark mode, the search UI should follow the same theme for consistency.
  • Better night experience: A dark background reduces glare for users browsing at night.
  • Mobile friendly: Many mobile browsers support dark mode by default, and Init Live Search will respect that if you choose the auto setting.

Tips for Using Dark Mode

  • Ensure the modal’s colors aren’t overridden by external CSS. Use DevTools to debug if dark mode doesn’t display properly.
  • Double-check background, text, and icon colors for good contrast on dark themes.
  • Try all three modes 'light', 'dark', 'auto' to find the best fit for your site’s overall design.

Why Init Live Search Stands Out

Written entirely in Vanilla JavaScript and powered by the WordPress REST API, Init Live Search offers a smooth and modern search experience:

  • No page reloads
  • Responsive modal UI
  • Remembers previous search terms
  • Supports dark mode, result caching, and UTM parameters

The plugin supports both Vietnamese and English interfaces, automatically adapting to your WordPress language setting.

Download Init Live Search Plugin

You can download the plugin here:

Comments


  • No comments yet.

Init Toolbox

Press Ctrl + \ on desktop, or swipe left anywhere on mobile.

Login