@keyframes cast-bit-to-space-toggle { to { --space-toggle: ; } } :where(.cbtst) { --cbtst-animation: cast-bit-to-space-toggle 1ms linear both var(--bit, 0); animation: var(--cbtst-animation); } /* usage */ .my-el.cbtst { --bit: 1; /* provide input value of 0 or 1 */ /* var(--space-toggle) is the output */ --bg: var(--space-toggle) lime; background: var(--bg, red); /* 1 = lime, 0 = red */ }