Wulan’s toast and the colour menu on the workshop’s order page: write the CSS, close and open, then read display, opacity and overlay every frame from the…
Why it matters
Toasts, dropdowns, dialogs and popovers all come and go. Without understanding discrete properties you are stuck between a broken fade and a transparent element that still blocks clicks. With allow-discrete, @starting-style and overlay, smooth entry and exit take only CSS.
The key idea
display is discrete: on or off, no value in between
Common mistakes
It fades, yet the box still blocks clicks once "gone"opacity: 0 alone makes it transparent, not gone: it is still in layout and still catches clicks. It must reach display: none, with transition: opacity .4s, display .4s allow-discrete so it still gets to fade.
The fade-in still snaps though allow-discrete is setallow-discrete decides when display switches. For the way in (from none) the element has no before-style to transition from: add @starting-style { opacity: 0 }.
Putting allow-discrete on its own line, not on displaytransition-behavior: allow-discrete written above the transition shorthand is reset to normal, and if display is not in the transition list nothing is held. Safest: display .4s allow-discrete inside the shorthand.
Try it in this playground
Close the toast and read its timeline The opacity line falls, the display band holds or breaks, and the upright line marks when display became none.
Use the "opacity only" preset, close, then watch Rara’s tap The toast is transparent but still there: the hit-test shows the tap hits the toast, not the button.
Remove @starting-style, then Auto test Closing stays smooth, but the first frame on the way in is opacity 1 already: it snaps.
Use the "longhand above the shorthand" preset, then close The transition-behavior the browser computes is normal: the shorthand below resets that longhand.