W3C home > Mailing lists > Public > www-style@w3.org > April 2012

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

From: Chris Eppstein <chris@eppsteins.net>
Date: Mon, 2 Apr 2012 20:24:55 -0700
Message-ID: <CANyEp6UbnAp6eLQX+gutBSaiF+yjuk12dQ3PxpN2Y+fZfEvD3w@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: www-style list <www-style@w3.org>
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 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:52 GMT