File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -365,6 +365,16 @@ Click on a color name to change the color scheme of the theme:
365365  }) 
366366</script> 
367367
368+ The color scheme can also be set based on _user preference_, which makes use of 
369+ the `prefers-color-scheme` media query. This can be done by adding the following 
370+ to `mkdocs.yml` :
371+ 
372+ ` ` `  yaml
373+ theme: 
374+   palette: 
375+     scheme: preference 
376+ ` ` ` 
377+ 
368378# ## Color palette
369379
370380The Material Design [color palette][10] comes with 20 hues, all of which are 
Original file line number Diff line number Diff line change 8686  {% else %}
8787    < body  dir ="{{ direction }} "> 
8888  {% endif %}
89-     {% if "prefers " == palette.scheme %}
89+     {% if "preference " == palette.scheme %}
9090      < script > matchMedia ( "(prefers-color-scheme: dark)" ) . matches && document . body . setAttribute ( "data-md-color-scheme" , "slate" ) </ script > 
9191    {% endif %}
9292    < input  class ="md-toggle " data-md-toggle ="drawer " type ="checkbox " id ="__drawer " autocomplete ="off "> 
Original file line number Diff line number Diff line change 181181  {% endif %}
182182
183183    <!-- Experimental: set color scheme based on preference --> 
184-     {% if "prefers " == palette.scheme %}
184+     {% if "preference " == palette.scheme %}
185185      < script > 
186186        if  ( matchMedia ( "(prefers-color-scheme: dark)" ) . matches ) 
187187          document . body . setAttribute ( "data-md-color-scheme" ,  "slate" ) 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments