Start Using color-scheme CSS Property When Working With Dark/Light Themes

  Рет қаралды 7,116

CSS Weekly

CSS Weekly

Күн бұрын

Пікірлер: 22
@wajdwael8775
@wajdwael8775 Жыл бұрын
Simple and clear explanation.
@CSSWeekly
@CSSWeekly Жыл бұрын
Thank you so much, Wajd! I'm thrilled to hear this! 🙏
@CSSWeekly
@CSSWeekly 2 жыл бұрын
A few more websites I found that should probably use color-scheme property: - hashnode.com/ - web.dev/ - jsfiddle.net/ - vercel.com/ Have you found any? 🙂
@galliumwang5089
@galliumwang5089 2 жыл бұрын
howerer, It doesn't provide a button to switch theme, it's really annoying😅
@CSSWeekly
@CSSWeekly 2 жыл бұрын
True. But if they did everything for us, we wouldn't have an opportunity to play with new features. 😅
@clevermissfox
@clevermissfox Жыл бұрын
If you’re using set colors on your page , can you set up custom properties and tell the browser “these are the set of colours for light mode” and “these are the set of colours for dark mode”? Other than using media query of (@prefers-color-scheme: dark) but still with css? Eg if (light mode) { -body-bg: lightpink; -card-bg: lightgrey; -primary-txt: black; } Then if(darkmode) { -body-bg: charcoal; -card-bg: black; -body-text: white; }
@CSSWeekly
@CSSWeekly Жыл бұрын
This is a fantastic question! 🙏 There isn't a simple way really to accomplish this, as far as I know. 🙁 There is light-dark() function that lets you specify light and dark colors in one line. And we might new schemed-value() function that would help with this. Bramus Van Damme has a nice article on the subject: www.bram.us/2023/10/09/the-future-of-css-easy-light-dark-mode-color-switching-with-light-dark/
@thedacian123
@thedacian123 2 жыл бұрын
Hello,So when we are setting color-scheme property ,you are telling the browser to render the page/elements using OS system prefs color scheme?
@CSSWeekly
@CSSWeekly 2 жыл бұрын
Hello Alex. The color-scheme tells the browser to render page/elements in the color-scheme you specify. It doesn't have to match the system color-scheme. A website could support only a dark scheme, for example, while you use light in your OS. And you would use this with `prefers-color-scheme` media query, not instead. Does this answer your question?🙂
@clevermissfox
@clevermissfox Жыл бұрын
@@CSSWeeklyif you have a light theme OS , where would you specify that you prefer a dark theme to have those styles applied?
@danieladu3923
@danieladu3923 8 ай бұрын
What is the title of the yellow book om your table
@CSSWeekly
@CSSWeekly 8 ай бұрын
"Show Your Work!" by Austin Kleon. It's a short book encouraging you to share your work openly and publicly. 🙂
@nathan_wind
@nathan_wind 2 жыл бұрын
Cool video! Though I knew about light/dark modes, I didn’t know they could both be specified, and I also didn’t know about the meta tag for them.
@CSSWeekly
@CSSWeekly 2 жыл бұрын
Thank you so much, Nathan! I’m delighted to hear that you learned something new! 🙏
@bonsayeb9620
@bonsayeb9620 Жыл бұрын
Thank you for this awesome video. Is it possible to add animation to the color-scheme property? I tried adding a transition of 2s but it didn't work.
@CSSWeekly
@CSSWeekly Жыл бұрын
Thanks for your comment, Bonsaye! 🙏 Unfortunately, color-scheme is not animatable. You can find a list of all properties that are here: developer.mozilla.org/en-US/docs/Web/CSS/CSS_animated_properties Hope this helps. 🙂
@svenson95
@svenson95 2 жыл бұрын
Even KZbin doesnt use color-scheme :D although it would look much better if they would Greets from Berlin!
@CSSWeekly
@CSSWeekly 2 жыл бұрын
Indeed it seems like KZbin doesn't use `color-scheme`, but I think they do a great job with their dark theme-their attention to detail is on point. 🙂
@loiuxxx
@loiuxxx Жыл бұрын
how about if there is a defined colors? will color-scheme work?
@CSSWeekly
@CSSWeekly Жыл бұрын
No, it will not work automatically in that case, John. Or rather, only native UI elements would be affected. So you will have to redefine those colors manually. And this is probably the most common way people would use the color-scheme.
@loiuxxx
@loiuxxx Жыл бұрын
@@CSSWeekly thanks!
@CSSWeekly
@CSSWeekly Жыл бұрын
Glad I could help! 🙂
A Practical Guide to Aspect Ratio in CSS
10:20
CSS Weekly
Рет қаралды 6 М.
5 super useful CSS properties that don't get enough attention
16:23
Kevin Powell
Рет қаралды 147 М.
Car Bubble vs Lamborghini
00:33
Stokes Twins
Рет қаралды 39 МЛН
When u fight over the armrest
00:41
Adam W
Рет қаралды 24 МЛН
Hoodie gets wicked makeover! 😲
00:47
Justin Flom
Рет қаралды 112 МЛН
A deep dive into CSS color-mix()
18:06
Kevin Powell
Рет қаралды 28 М.
How is this Website so fast!?
13:39
Wes Bos
Рет қаралды 951 М.
All Your Color-Scheme Are Belong to Us
9:04
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 1,3 М.
The problems with viewport units
13:23
Kevin Powell
Рет қаралды 365 М.
Avoid These 5 Awful CSS Mistakes
20:42
Kevin Powell
Рет қаралды 196 М.
Animate HTML Details & Summary Elements Using Pure CSS
17:07
CSS Weekly
Рет қаралды 6 М.
Why Are Open Source Alternatives So Bad?
13:06
Eric Murphy
Рет қаралды 672 М.
#FutureCSS - The AMAZING Prefers-Color-Scheme - Native Dark Mode
14:39
Car Bubble vs Lamborghini
00:33
Stokes Twins
Рет қаралды 39 МЛН