If/Else in CSS 0 ▲ Jake Worth 43 minutes ago · Tech · hide · 0 comments Today I got to try the experimental if/else syntax in CSS: /* Component.module.css */ img { transform: if(style(--isZoomed: true): scale(2) ; else: scale(1)); } I used it to pass a variable from React state to the stylesheet: // Component.tsx <img style={{'--isZoomed': isZoomed ? 'true' : 'false'}} /> I think conditional classes would be my preference for managing this for real, but this is an alternative. if() CSS Function — MDN No comments yet. Log in to reply on the Fediverse. Comments will appear here.