[css-variables] Adding a default value to var()

In <https://www.w3.org/Bugs/Public/show_bug.cgi?id=16517>, Roland
requests the ability to add a "default value" to the var() function,
which is used when the reference variable is invalid or missing.

The main use-case for this is to make it easier to use variables as
"extension points", such that you can define several variables as part
of a "theming API" and allow the user or other authors to override
them, but provide reasonable defaults so the user doesn't necessarily
have to override the entire set of variables.

This also brings Variables more in line with the proposed abilities of
SVG Parameters, making it easier to merge the two specs into a single
piece of functionality.  The use-case for default values in SVG
Parameters is especially strong, as it can easily be unreasonable to
ask the user to provide values for *all* the things you may want to
make customizable.

So, should we add this to v1?

(Side-note: Roland's suggestion for fallback to multiple vars -
nesting var() functions - isn't quite necessary.  You can instead just
have the first argument to var() accept a space-separated list of
variable names, and it resolves to the first valid one, only taking
the fallback when none of them are valid.)

~TJ

Received on Tuesday, 3 April 2012 01:43:17 UTC