Menu

📰
0

The Radio State Machine

CSS-Tricks·Amit Sheen·about 2 months ago
#4MSmWSP5
#css-tricks#state#theme#eee#fff3#adjacent
Reading 0:00
15s threshold

Managing state in CSS is not exactly the most obvious thing in the world, and to be honest, it is not always the best choice either. If an interaction carries business logic, needs persistence, depends on data, or has to coordinate multiple moving parts, JavaScript is usually the right tool for the job. That said, not every kind of state deserves a trip through JavaScript. Sometimes we are dealing with purely visual UI state: whether a panel is open, an icon changed its appearance, a card is flipped, or whether a decorative part of the interface should move from one visual mode to another. In cases like these, keeping the logic in CSS can be not just possible, but preferable. It keeps the behavior close to the presentation layer, reduces JavaScript overhead, and often leads to surprisingly elegant solutions. The Boolean solution One of the best-known examples of CSS state management is the checkbox hack .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More