Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

Use CSS relative color syntax to darken/lighten colors for borders, backgrounds, etc. 🔥 .success { --c: green; } aside { background: oklch(from var(--c) calc(l * 0.75) c h / 0.5); color: oklch(from var(--c) calc(l * 1.5) c h); } Magic! ✨

256,603 Aufrufe • vor 2 Jahren •via X (Twitter)

10 Kommentare

Profilbild von jhey ▲🐻🎈
jhey ▲🐻🎈vor 2 Jahren

Here's the @CodePen link! 🚀 Firefox doesn't support relative color syntax... yet. You can get a similar behavior using color-mix though! 🔥 aside { background: color-mix( in oklch, var(--c) 50%, oklch(0% 0 0 / 50%) ); }

Profilbild von Igor bedesqui
Igor bedesquivor 2 Jahren

holy shit this is so much easier than the manual alternative of having a variant for each scale

Profilbild von jhey ▲🐻🎈
jhey ▲🐻🎈vor 2 Jahren

Totally! 💯 This one was quickly thrown together too so its a little rough around the edges 😅 The technique holds though 🙌 Definitely gonna spend some more time with it for some upcoming projects

Profilbild von Charlie Joseph
Charlie Josephvor 2 Jahren

This.. combined with Tailwind v4 variables will be superb 👌 Thanks for sharing such a clever method

Profilbild von jhey ▲🐻🎈
jhey ▲🐻🎈vor 2 Jahren

Oh yes! Magical ✨💯 Firefox doesn't support the relative color syntax yet. But does support color-mix which allows you to create a pretty similar set of behaviors 🙌

Profilbild von Tycho Tatitscheff
Tycho Tatitscheffvor 2 Jahren

Oklch is so good for this use case cc @CipolleschiR @jamonholmgren

Profilbild von Jake Vollkommer
Jake Vollkommervor 2 Jahren

Someone drop the tailwind

Profilbild von 楷鹏Dev
楷鹏Devvor 2 Jahren

Hey, bro. Can you tell me how you made this smooth video?

Profilbild von Tim Wilson
Tim Wilsonvor 2 Jahren

Very nice 👌

Profilbild von Pavee Udomkarnpaisarn
Pavee Udomkarnpaisarnvor 2 Jahren

This is neat!

Ähnliche Videos

L I C H A 😤
0:20

Sensitive content

L I C H A 😤

Manchester United

301,051 Aufrufe • vor 1 Jahr