• Resolved snippet24

    (@snippet24)


    So currently I’m using the following plugin https://www.ads-software.com/plugins/wp-night-mode/
    which adds the class .wp-night-mode-on to the body, so what is the best way for both (this plugin and Wp Nigh Mode) to play along?

    body.wp-night-mode-on .cards-otras-caracteristicas-servicios {
      background-color: #212121;
    }
    • This topic was modified 4 years ago by snippet24.
    • This topic was modified 4 years ago by snippet24.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter snippet24

    (@snippet24)

    I can of course just change the colors via css… but maybe there’s a better way

    • This reply was modified 4 years ago by snippet24.
    Plugin Author GusRuss89

    (@gusruss89)

    Hi @snippet24,

    Sorry for the slow reply, I’ve just had the power come back on in Cairns after tropical cyclone Niran came through.

    The dark theme of material design just works by adding a class to your form’s parent element. So to get it to work with your dark theme toggle button, just toggle that class when the theme changes. You can use JavaScript like this, just make sure to update the selector for the dark theme switch if necessary.

    jQuery('.wp-night-mode').click(function() {
      jQuery('.cf7md-form').each(function() {
        jQuery(this).toggleClass('cf7md-theme--dark');
      });
    });

    Thanks,
    Angus

    Thread Starter snippet24

    (@snippet24)

    Hi Angus,
    No problem ??
    That should work but I forgot to add: WP Night Mode seems to use a cookie for saving the dark mode, so that if I load another page it keeps the preference i.e dark mode. Perhaps I should actually ask WP N.M. plugin Dev. on this regard.
    Have a nice week!

    CF7 Addons

    (@cf7addons)

    Hi @snippet24

    In that case, you’ll need to figure out how to read the cookie (or get the current dark theme state from somewhere) in JavaScript and toggle the class on your forms accordingly ??

    Thanks,
    Angus

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to set darkmode with WP Night Mode plugin?’ is closed to new replies.