CSS toggles
- Category
- CSS
- Type
- New or changed feature
- Status
- No longer pursuing (Chrome No longer pursuing)
- Intent stage
- None
WPT details: https://wpt.fyi/results/css/css-toggle?label=experimental&label=master
Summary
CSS toggles are a mechanism for associating toggleable state with a DOM element. This state can be defined and connected to activations through CSS properties, and can be queried in CSS selectors. This provides a declarative mechanism for specifying state that describes behaviors like the existing HTML behaviors for checkboxes or radio buttons.
Motivation
There are many cases where a user interaction (such as a click) toggles state that styles depend on. These cases include popups, tabs, carousels, accordions, and toggles controlling light/dark mode. Building these today requires Javascript. We would like to build a declarative way of doing this that, if we do it right, will be easier for developers to use, faster, and more accessible than the solutions that are used today.
Standards & signals
- Specification: https://tabatkins.github.io/css-toggle
- Firefox: No signal
- Safari: No signal
- Web developers: No signals — Somewhat indirect, but what kicked off the original designs here was OpenUI work around tabs (see, e.g., https://open-ui.org/components/tabs.research ).
- Tracking bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1250716
Ecosystem
- Web Platform Tests: https://wpt.fyi/results/?q=css%2Fcss-toggle
- Chrome Platform Showcase: https://chrome-platform-showcase.paulkinlan-ea.deno.net/features
- GenDN reference: https://gendn.paulkinlan-ea.deno.net/features
- chrome.dev demos search: https://www.google.com/search?q=site%3Achrome.dev+CSS%20toggles
- MDN Web Docs: https://developer.mozilla.org/en-US/search?q=CSS%20toggles
- Baseline status: https://webstatus.dev/?q=CSS%20toggles
Explainers: https://css.oddbird.net/toggles/explainer/