{"id":335207,"date":"2021-03-04T07:51:39","date_gmt":"2021-03-04T15:51:39","guid":{"rendered":"https:\/\/css-tricks.com\/?p=335207"},"modified":"2021-03-04T07:51:41","modified_gmt":"2021-03-04T15:51:41","slug":"exploring-property-and-its-animating-powers","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/exploring-property-and-its-animating-powers\/","title":{"rendered":"Exploring @property and its Animating Powers"},"content":{"rendered":"\n

Uh, what\u2019s @property<\/code>? It\u2019s a new CSS feature! It gives you superpowers. No joke, there is stuff that @property<\/code> can do that unlocks things in CSS we\u2019ve never been able to do before.<\/p>\n\n\n\n

While everything about @property<\/code> is exciting, perhaps the most interesting thing is that it provides a way to specify a type<\/strong> for custom CSS properties. A type provides more contextual information to the browser, and that results in something cool: We can give the browser the information is needs to transition and animate those properties!<\/strong><\/p>\n\n\n\n\n\n\n\n

But before we get too giddy about this, it\u2019s worth noting that support isn\u2019t quite there. As it current stands at the time of this writing, @property<\/code> is supported in Chrome and, by extension, Edge. We need to keep an eye on browser support<\/a> for when we get to use this in other places, like Firefox and Safari.<\/p>\n\n\n

First off, we get type checking<\/h3>\n\n\n
@property --spinAngle {\n  \/* An initial value for our custom property *\/\n  initial-value: 0deg;\n  \/* Whether it inherits from parent set values or not *\/\n  inherits: false;\n  \/* The type. Yes, the type. You thought TypeScript was cool *\/\n  syntax: '<angle>';\n}\n\n@keyframes spin {\n  to {\n    --spinAngle: 360deg;\n  }\n}<\/code><\/pre>\n\n\n\n

That\u2019s right! Type checking in CSS. It\u2019s sorta like creating our very own mini CSS specification. And that\u2019s a simple example. Check out all of the various types we have at our disposal:<\/p>\n\n\n\n