Detect Darkmode

Share your advanced knowledge/code with the community.
Dirk Geppert
Posts: 282
Joined: Fri Sep 22, 2017 7:02 am

Detect Darkmode

Post by Dirk Geppert »

If you want to dynamically adjust your webapp to the user's preferred color scheme:

Code: Select all

! if(matchMedia('(prefers-color-scheme: dark)').matches) {
  Debug "Darkmode"
! }
 
! if(matchMedia('(prefers-color-scheme: light)').matches) {
  Debug "Lightmode"
! }
Fred
Site Admin
Posts: 1506
Joined: Mon Feb 24, 2014 10:51 am

Re: Detect Darkmode

Post by Fred »

Cool stuff !
Post Reply