It's not possible to use variables in media queries with plain CSS.
@media (max-width: var(--some-pixel-size)) { ... } /* Does not work */
Postcss Plugin
If you're using PostCSS to postprocess your CSS, you can configure postcss-custom-media and add this feature:
@custom-media --small-variable-name(max-width: 968px);
@media (--small-variable-name) { ... } /* works */
Posted by Niklas Hä. to makandra dev (2025-11-26 17:10)