Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71025

Dark Mode Theme

$
0
0

@Jignesh2810 wrote:

Hii,
I have tried below code to apply “Dark Mode” theme but is not working in ionic 3 and 4 also try in ionic 1 but the same result.

  • I used the android system by default dark mode get but not getting.

    // Use matchMedia to check the user preference
    const prefersDark = window.matchMedia(’(prefers-color-scheme: dark)’);

    toggleDarkTheme(prefersDark.matches);

    // Listen for changes to the prefers-color-scheme media query
    prefersDark.addListener((mediaQuery) => toggleDarkTheme(mediaQuery.matches));

    // Add or remove the “dark” class based on if the media query matches
    function toggleDarkTheme(shouldAdd) {
    document.body.classList.toggle(‘dark’, shouldAdd);
    }

  • In the above code, "const prefersDark " value always returns a false value

Please tell me anything wrong on my side.
Thanks you

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71025

Trending Articles


FLASHBACK WITH SIRASA FM AT GALGAMUWA 2022


Mp3 Download: Mdu - Mazola


Imitation gun was fired at motorist in Leicester road-rage incident


Ndebele names


MCKINNEY EMALINE “EMMA” OF WES...


Okra & Motia — The Workshop (Prod by Hammer)


Skint TV teen to be sentenced


Moondru Mudichu 19-09-2017 – Polimer tv Serial


YOSVANI JAMES Arrested by Miami-Dade County Corrections on Jan 10, 2017


Stories • Goddess Stepmom



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>