You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/documentation/overview/customize.html
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -50,14 +50,16 @@ <h2 class="subtitle">Create your <strong>own theme</strong> with a simple set of
50
50
// 2. Set your own initial variables
51
51
// Update blue
52
52
$blue: #72d0eb
53
-
// Add pink
53
+
// Add pink and its invert
54
54
$pink: #ffb3b3
55
+
$pink-invert: #fff
55
56
// Add a serif family
56
57
$family-serif: "Merriweather", "Georgia", serif
57
58
58
59
// 3. Set the derived variables
59
60
// Use the new pink as the primary color
60
61
$primary: $pink
62
+
$primary-invert: $pink-invert
61
63
// Use the existing orange as the danger color
62
64
$danger: $orange
63
65
// Use the new serif family
@@ -79,7 +81,7 @@ <h2 class="subtitle">Create your <strong>own theme</strong> with a simple set of
79
81
See the <strong>result</strong>: before and after
80
82
</p>
81
83
<pclass="subtitle is-6">
82
-
Notice how the <code>$blue-invert</code> is now black instead of white, based on <code>findColorInvert(#72d0eb)</code></p>
84
+
As <code>$blue</code> has been updated, and since <code>$blue-invert</code> is automatically calculated with the <strong>function</strong><code>$blue-invert: findColorInvert($blue)</code>, the <code>$blue-invert</code> is now black instead of white</p>
83
85
</p>
84
86
<figure>
85
87
<imgwidth="640" height="640" src="{{site.url}}/images/customize-before.png" alt="Customizing Bulma with Sass">
<p>The <code>findColorInvert($color)</code> function takes a <strong>color</strong> as an input, and outputs either transparent <strong>black</strong><code>rgba(#000, 0.7)</code> or <strong>white</strong><code>#fff</code>:</p>
31
+
<ul>
32
+
<li>if <code>colorLuminance($color) > 0.55</code>, it outputs <code>rgba(#000, 0.7)</code></li>
33
+
<li>otherwise, it outputs <code>#fff</code></li>
34
+
</ul>
35
+
<p>Its purpose is to guarantee a <strong>readable</strong> shade for the <em>text</em> when the input color is used as the <em>background</em>.</p>
36
+
<tableclass="table is-bordered">
37
+
<thead>
38
+
<tr>
39
+
<th>color</th>
40
+
<th>color luminance</th>
41
+
<th>findColorInvert()</th>
42
+
<th>result</th>
43
+
</tr>
44
+
</thead>
45
+
<tbody>
46
+
<tr>
47
+
<td>
48
+
<spanclass="color" style="background: #00d1b2;"></span>
49
+
<code>#00d1b2</code>
50
+
</td>
51
+
<td>
52
+
<code>0.52831</code>
53
+
</td>
54
+
<td>
55
+
<spanclass="color" style="background: #fff;"></span>
56
+
<code>#fff</code>
57
+
</td>
58
+
<td>
59
+
<aclass="button" style="background: #00d1b2; border-color: #00d1b2; color: #fff;">
60
+
Button
61
+
</a>
62
+
</td>
63
+
</tr>
64
+
<tr>
65
+
<td>
66
+
<spanclass="color" style="background: #3273dc;"></span>
67
+
<code>#3273dc</code>
68
+
</td>
69
+
<td>
70
+
<code>0.23119</code>
71
+
</td>
72
+
<td>
73
+
<spanclass="color" style="background: #fff;"></span>
74
+
<code>#fff</code>
75
+
</td>
76
+
<td>
77
+
<aclass="button" style="background: #3273dc; border-color: #3273dc; color: #fff;">
78
+
Button
79
+
</a>
80
+
</td>
81
+
</tr>
82
+
<tr>
83
+
<td>
84
+
<spanclass="color" style="background: #23d160;"></span>
85
+
<code>#23d160</code>
86
+
</td>
87
+
<td>
88
+
<code>0.51067</code>
89
+
</td>
90
+
<td>
91
+
<spanclass="color" style="background: #fff;"></span>
92
+
<code>#fff</code>
93
+
</td>
94
+
<td>
95
+
<aclass="button" style="background: #23d160; border-color: #23d160; color: #fff;">
96
+
Button
97
+
</a>
98
+
</td>
99
+
</tr>
100
+
<tr>
101
+
<td>
102
+
<spanclass="color" style="background: #ffdd57;"></span>
103
+
<code>#ffdd57</code>
104
+
</td>
105
+
<td>
106
+
<code>0.76863</code>
107
+
</td>
108
+
<td>
109
+
<spanclass="color" style="background: rgba(0, 0, 0, 0.7);"></span>
110
+
<code>rgba(0, 0, 0, 0.7)</code>
111
+
</td>
112
+
<td>
113
+
<aclass="button" style="background: #ffdd57; border-color: #ffdd57; color: rgba(0, 0, 0, 0.7);">
114
+
Button
115
+
</a>
116
+
</td>
117
+
</tr>
118
+
<tr>
119
+
<td>
120
+
<spanclass="color" style="background: #ff3860;"></span>
121
+
<code>#ff3860</code>
122
+
</td>
123
+
<td>
124
+
<code>0.27313</code>
125
+
</td>
126
+
<td>
127
+
<spanclass="color" style="background: #fff;"></span>
128
+
<code>#fff</code>
129
+
</td>
130
+
<td>
131
+
<aclass="button" style="background: #ff3860; border-color: #ff3860; color: #fff;">
132
+
Button
133
+
</a>
134
+
</td>
135
+
</tr>
136
+
<tr>
137
+
<td>
138
+
<spanclass="color" style="background: #ffb3b3;"></span>
139
+
<code>#ffb3b3</code>
140
+
</td>
141
+
<td>
142
+
<code>0.61796</code>
143
+
</td>
144
+
<td>
145
+
<spanclass="color" style="background: rgba(0,0,0,0.7);"></span>
146
+
<code>rgba(0,0,0,0.7)</code>
147
+
</td>
148
+
<td>
149
+
<aclass="button" style="background: #ffb3b3; border-color: #ffb3b3; color: rgba(0,0,0,0.7);">
150
+
Button
151
+
</a>
152
+
</td>
153
+
</tr>
154
+
<tr>
155
+
<td>
156
+
<spanclass="color" style="background: #ffbc6b;"></span>
157
+
<code>#ffbc6b</code>
158
+
</td>
159
+
<td>
160
+
<code>0.63053</code>
161
+
</td>
162
+
<td>
163
+
<spanclass="color" style="background: rgba(0,0,0,0.7);"></span>
164
+
<code>rgba(0,0,0,0.7)</code>
165
+
</td>
166
+
<td>
167
+
<aclass="button" style="background: #ffbc6b; border-color: #ffbc6b; color: rgba(0,0,0,0.7);">
168
+
Button
169
+
</a>
170
+
</td>
171
+
</tr>
172
+
<tr>
173
+
<td>
174
+
<spanclass="color" style="background: hsl(294, 71%, 79%);"></span>
175
+
<code>hsl(294, 71%, 79%)</code>
176
+
</td>
177
+
<td>
178
+
<code>0.5529</code>
179
+
</td>
180
+
<td>
181
+
<spanclass="color" style="background: rgba(0,0,0,0.7);"></span>
For colors that have a luminance close to the <code>0.55</code> threshold, it can be useful to <strong>override</strong> the <code>findColorInvert()</code> function, and rather set the invert color <strong>manually.</strong>
194
+
<br>
195
+
For example, this shade of <spanclass="color" style="background: hsl(294, 71%, 79%); float: none; height: 16px; width: 16px; margin-right: 0; vertical-align: middle;"></span> purple has a color luminance of <code>0.5529</code>. It can be preferable to set a color invert of white instead of transparent black:
0 commit comments