Skip to content

Set color-scheme by default #710

Open
@jimmywarting

Description

Providing both a dark and a light color scheme should be on anyones radar now and it should not be forgotten by the developer that there are two kind of ppl in this world

i think it would be useful if when you create a new html:5 or with ! template
...then it should include a simple style sheet that is just marly a:

@media (prefers-color-scheme: dark) {
  * { color-scheme: dark; }
}

cuz most often ppl

  • forget to add a dark mode
  • or they override a heck of a lot default html/css rules with a bunch of css
    • and then they forget to change the color of some weird native element such as the <select>, <input type=file> element that is a bit harder to style and hence why they also tend to completely write custom component with select2 and lots of included html, css and javascript cuz it's hard to style the <select> or the file input element and also changing the color of the button in the file input
    • another common issue by not using color-scheme is that ppl add a dark background and a light text color but things such as the date icon in eg <input type="date"> still inherit the light theme so the calendar icon is dark on a dark background
      evident by this jsfiddle demo: https://jsfiddle.net/uj1Ltfxs/

so i would wish for a default but tiny and powerful css is added by default so it becomes:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    @media (prefers-color-scheme: dark) {
      * { color-scheme: dark; }
    }
  </style>
</head>
<body>
  
</body>
</html>

the color-scheme is often overlooked/forgotten and everyone should be using it i think. it takes care of a lot of fixes and reduces the amount of css you really have to write for having both a dark and light theme

while at it i also think the users own system/OS font should be used by default too.

necolas/normalize.css#665

font-family: -apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif
so something like this:

    * {
      font-family: -apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif 
    }
    @media (prefers-color-scheme: dark) {
      * { color-scheme: dark; }
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions