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

We have default values for variables in Sass, but I do not think they are
necessary in CSS variables because the value is resolved after the cascade
is applied. As such, you can set the value to the default value and the
consumer of the "themeable" stylesheet can always override that value if
they choose to in their own stylesheets.

Chris

On Mon, Apr 2, 2012 at 6:42 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:

> 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 03:25:25 UTC