@@ -42,7 +42,51 @@ Introduction {#intro}
42
42
43
43
<em> This section is not normative.</em>
44
44
45
- Issue: TODO
45
+ Note: At this time, this specification only defines [=custom functions=] ,
46
+ which operate at the level of CSS values.
47
+ It is expected that it will define "mixins" later,
48
+ which are functions that operate at the style rule level.
49
+
50
+ [=Custom properties=] give authors a lot of power
51
+ to define useful, sometimes complex values
52
+ in one place,
53
+ and then re-use them across their stylesheet.
54
+ They can vary across the document,
55
+ or based on Media Queries or other conditionals,
56
+ making them very flexible and responsive.
57
+
58
+ However, their values are <em> fixed</em> at the point they're defined,
59
+ unable to be changed except by fully overriding their previous definition:
60
+ a ''--shadow: 2px 2px var(--shadow-color)'' declaration
61
+ takes its ''--shadow-color'' value from the element it's declared on,
62
+ and later changes to ''--shadow-color'' on descendant elements
63
+ don't alter the value of ''--shadow'' for them;
64
+ they continue to use the shadow color defined where ''--shadow'' was defined.
65
+ This is a common source of confusion for authors
66
+ making heavy use of composite variables like this.
67
+
68
+ [=Custom functions=] allow authors the same power as [=custom properties=] ,
69
+ but <em> parameterized</em> :
70
+ they have the same flexibility and conditionality as a [=custom property=] definition,
71
+ but take values from other custom properties
72
+ (or explicitly as arguments)
73
+ <em> at the point of use</em> .
74
+ For example, instead of a ''--shadow'' [=custom property=] ,
75
+ a ''--shadow()'' [=custom function=] could be defined instead,
76
+ like:
77
+
78
+ <pre highlight=css>
79
+ @function --shadow(--color <color> : var(--shadow-color)) {
80
+ result: 2px 2px var(--color, black);
81
+ }
82
+
83
+ .foo {
84
+ --shadow-color: blue;
85
+ box-shadow: --shadow(); // produces a blue shadow
86
+ /* or just */
87
+ box-shadow: --shadow(blue);
88
+ }
89
+ </pre>
46
90
47
91
<!-- Big Text: @function
48
92
0 commit comments