This is a great example of why you need more control when implementing dark mode than just reversing the color scheme or overriding basic variables like "--color-primary" or similar.
Short thread pointing out some of the neat design decisions here 👉
1. The top banner – the background color changes a bit and so does the link, but it doesn't *invert*, it's still light on dark in both versions.
Dark sections shouldn't be inverted to light in dark mode, you'd get a blinding light block — bad in dark environments.
2. The background switches from light to dark, but in the light design it's a solid color, and in the dark design it's a gradient. You can't do this by changing a color variable.
3. The little badge/well above the headline is already dark, but it gets darker in dark mode to retain enough contrast against the background. A naive dark implementation would make this well light, and it wouldn't look like a well anymore.
From Refactoring UI:
4. Call to action buttons switch from indigo in light mode to pink in dark mode, again not an inversion.
Light indigo is dull because indigo is inherently dark. Pink is inherently light, so you can saturate it to bits while still maintaining high contrast over a dark background.
Here's a related tip again from Refactoring UI, about how rotating the hue instead of (or in combination with) adjusting the lightness can lead to more vivid results when you need a lighter version of an existing color:
To learn more about how dark mode works in Tailwind, check out this great video @simonswiss put together when Tailwind CSS v2.0 was released 🥳
• • •
Missing some Tweet in this thread? You can try to
force a refresh
.@bradlc who built the entire website. I absolutely did not expect us to have time for all the insane interactions and animations. He managed to do everything I ever dreamed of plus more, and the APIs he created for it are a delight to work with.
.@malfaitrobin who worked side-by-side with me to develop all of the new features in Tailwind CSS v2.0, and took on the massive job of updating Tailwind UI to take advantage of all the new features. He built an entire automated system that can idempotently update our templates 🤯
❌ Not an alternative to Tailwind UI
❌ Not a predesigned UI kit
❌ Not styled at all
❌ Not in any way tied to Tailwind, there is no CSS or classes or anything of any kind in the library
Instead, it’s a set of low-level completely unstyled primitives that let you build *custom* versions of common components faster, *with your own design you bring yourself*.
This is what a menu button renders by default (that’s the default browser focus ring, not bundled CSS):
If you haven't seen us hinting at it, Headless UI is a set of completely unstyled, fully accessible UI primitives that make it really easy to build custom controls that are super easy to customize and style.
It's the component library I've always dreamed of 😍
Here's a quick demo of the Menu Button component in React:
Learned today that using the box shadow property to create custom focus styles is insufficient because high contrast mode on Windows doesn’t render box shadows at all.
The hoops you have to jump through on the web are unbelievable, it’s no wonder everything is inaccessible :/
Here’s a relevant link, thanks @david_luhr for teaching me about this one 🥴
Take away is if you want a custom focus style that follows an element’s border radius, literally only option is pseudo elements that are absolutely positioned relative to the main element so they aren’t in the document flow. No one does this of course though 😶
Four hours of trying to build an "unprose" feature for the Tailwind typography plugin and I have determined that it is essentially impossible.
The inevitable conclusion is "create a CSS variable for every inheritable property" which is just, no.
Selectors like this get you very close, but the nail in the coffin is anything added to the `prose` class itself that is inheritable:
These styles are inherited to children even if you stick an `unprose` in between and there's literally nothing you can do about it beyond `all: initial` (unset maintains the inheritance), which also overrides reset styles you _do_ want to preserve from elsewhere in your CSS.
(Haven't had a chance to add docs for the new utilities yet but wanted to get the release out for the eager beavers anyways! If anyone wants to scaffold out the basic pages for `font-variant-numeric` and the added alignment utilities I'll send you a t-shirt!)
Should've said "even bigger file sizes", I broke PurgeCSS completely and have now uncovered a flaw in our purge tests 👀
Hold off on upgrading 'til we fix it, hopefully after my toddler goes to bed 🙈