Chrome now lets authors declare CSS custom properties from CSS with a type attached, rather than treating every value as an opaque string. Una Kravetz covers the feature in detail; the core idea is that a custom property declaration can carry the information the browser needs to interpret its value.

From plain strings to declared types

A conventional custom property declaration looks like this:

html {
  --stop: 50%;
}

With the @property syntax, the same property can be declared with more detail:

@property --stop {
  syntax: "<percentage>";
  initial-value: 50%;
  inherits: false;
}

The browser now knows the property holds a percentage rather than a string. Other useful types such as <integer> and <color> are available as well. Once the browser has this information, new capabilities open up — transitioning between two values among them.

Transitioning typed properties

Not everything around transitions comes along for free. A catch-all transition will not do it: the property being transitioned must be called out specifically in the transition declaration.

A recreation of Una's demo animates the position of a color stop, which is a percentage. The color itself is also meant to animate, but it still does not — despite the new feature. Gradients have long resisted animation in CSS, a source of confusion documented by Ana Tudor.

Fallbacks and the falsey-value quirk

Properties can always be re-declared somewhere at a high level to serve browsers that cannot read custom properties at all. The typed version also addresses a long-standing oddity with fallback behavior, described as follows:

As with any other custom property, you can get (using var) or set (write/rewrite) values, but with Houdini custom properties, if you set a falsey value when overriding it, the CSS rendering engine will send the initial value (its fallback value) instead of ignoring the line.

Where the other engines stand

Safari has signaled strong interest in this Houdini-based work but has not shipped it yet. Firefox's position is less clear; the best available signal is that the feature was labeled "Worth Prototyping" before the layoffs.