Lea Verou 10/12/2020

The -​-var: ; hack to toggle multiple values with one custom property

Read Original

This article explains a clever CSS hack using custom properties. By setting a property like `--foo: ;` (a single space), you can use `var(--foo, fallback-value)` to conditionally append or remove multiple style values (like gradients, borders, shadows) across different properties and rules, acting as a single-clause conditional.

The -​-var: ; hack to toggle multiple values with one custom property

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser