How to create a theme switcher with HTML & CSS

A few custom properties and the :has() selector make color theming super easy to do! Add in a bit of JS and we can save the user’s preferences in localStorage, and we’re good to go! Of course, :has() support isn’t perfect, but we can build in a quick fallback with just a little bit more JS. 🔗 Links ✅ The code from this video: ✅ More on visually-hidden: ✅ Current support for :has() - ⌚ Timestamps 00:00 - Introduction 00:57 - What we’re starting with 01:58 - Setting up the color theme selector 04:04 - Hiding the labels 05:39 - Styling the color theme picker 12:05 - Adding functionality with :has() 13:48 - Using localStorage to remember the us ... #Kevin_Powell #css #front-end #frontend #html #web_development #has() #:has() #css_has_selector 20221101 fyuao3G-2qg
Back to Top