Re: [csswg-drafts] [animation-triggers-1] Proposal: toggle Custom States using Animation Triggers (`state-trigger`) (#13579)

@flackr :

> I think you can set up generic state-like changes with animation triggers with something like this:
>
> ```css
> @keyframes state-foo { to {--state: foo;} }
> .target {
>   animation: state-foo forwards;
>   animation-trigger: --in-view;
>   timeline-trigger: --in-view view();
>   @container style(--state: foo) {
>     /* Style descendants after state change */
>   }
> }
> ```

Yeah, for sure. That's what I mentioned that it's possible today, but it's hacky, and you need to target a container of the actual target. Also, the state management would also look cumbersome,  unlike having `add/remove/toggle-state()` that is proposed.

@kizu:

Good point! That's an action item for improving the explainer.

@LeaVerou: of course 👍 , mentioned in the OP (:

-- 
GitHub Notification of comment by ydaniv
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/13579#issuecomment-4164594468 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 31 March 2026 18:30:40 UTC