-
Notifications
You must be signed in to change notification settings - Fork 0
/
css-system-colors.html
903 lines (823 loc) · 45.2 KB
/
css-system-colors.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<!--Refresh page every 5 seconds: meta http-equiv="refresh" content="5"-->
<title>CSS System Colors</title>
<link rel="icon" type="image/x-icon" href="./images/favicon.ico" />
<link rel="stylesheet" href="./css-system-colors.css" />
<link rel="stylesheet" href="./css/css-system-main.css" />
<link rel="stylesheet" href="./css/css-system-demo.css" />
<link rel="stylesheet" href="./css/css-system-grid.css" />
<link rel="stylesheet" href="./css/css-system-table.css" />
<link rel="stylesheet" href="./css/css-system-classes.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Delius&display=swap" rel="stylesheet">
<script src="./css-system-colors.js"></script>
<script defer src="./css-system-json.js"></script>
<script defer src="./js/css-system-utilities.js"></script>
<script defer src="./js/css-system-cards.js"></script>
<script defer src="./js/jscolor.js"></script> <!-- color picker from https://jscolor.com/ -->
</head>
<body>
<div id="syscolors-outer-container">
<header>
<a href="https://eoc.online">
<img src="./images/favicon.png" alt="eoc.online logo"
title="brought to you by eoc.online - Open Source Tooling for Emergency Operation Centers" height="60" />
</a>
<a href="https://github.com/eoconline/css-system-colors" class="no-decoration">
<h1>CSS System Colors</h1>
<h3>Visually demonstrate CSS System Colors</h3>
</a>
<span id="syscolors-github">
<a href="https://github.com/eoconline/css-system-colors" title="Download the source!"><img
src="./images/github-mark.svg" height="40"></a>
</span>
</header>
<div id="syscolors-options-container" class="syscolors-inner-container">
Options:
<label for="syscolors-page-mode" title="This sets the general page color mode. All panels
have hardwired color modes, so this basically just changes the page background.">Page
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme">color-scheme</a>:</label>
<select id="syscolors-page-mode" onchange="setPageColorScheme(this)">
<option class="floater" value="normal" data-title="Page can be rendered using the page's color
scheme settings. If the page does not have a color scheme
set, the element is rendered using the page's default color settings." title="Page can be rendered using the page's color
scheme settings. If the page does not have a color scheme
set, the element is rendered using the page's default color settings." selected="selected">Normal
(Browser Default)</option>
<option class="floater" value="light dark" title="Page can be rendered using the operating
system's light (preferred) or dark color scheme." data-title="Page can be rendered using the operating
system's light (preferred) or dark color scheme.">Light Dark</option>
<option class="floater" value="dark light" title="Page can be rendered using the operating
system's dark (preferred) or light color scheme." data-title="Page can be rendered using the operating
system's dark (preferred) or light color scheme.">Dark Light</option>
<option class="floater" value="light" title="Page can be rendered using the operating system light
color scheme." data-title="Page can be rendered using the operating system light
color scheme.">Light</option>
<option class="floater" value="dark" title="Page can be rendered using the operating system dark
color scheme." data-title="Page can be rendered using the operating system dark
color scheme.">Dark</option>
<option class="floater" value="only light" title="Forbids the user agent from overriding the color scheme
for the element." data-title="Forbids the user agent from overriding the color scheme
for the element.">Only Light</option>
<option class="floater" value="only dark" title="Forbids the user agent from overriding the color scheme
for the element." data-title="Forbids the user agent from overriding the color scheme
for the element.">Only Dark</option>
<option class="floater" value="Nonsense String"
title="An unexpected/non-standard string here is interpreted as 'Light'."
data-title="An unexpected/non-standard string here is interpreted as 'Light'.">Nonsense String</option>
</select>
<label for="syscolors-sorted" title="Sort grid & table colors by category (vs. name)">Sort by Category:</label>
<input type="checkbox" onclick="setSortOrder(this)" id="syscolors-sorted" />
<label id="syscolors-contrast-label" for="syscolors-contrast">
Contrast <span id="syscolors-contrast-value">(auto) 100</span>%:
<input type="range" step="2.5" min="0" value="100" max="100" id="syscolors-contrast"
oninput="updateContrast(this)" />
</label>
<button class="btn" id="syscolors-download-current" style="cursor: pointer"
title="Download JSON file with RGBA values" onclick="downloadColors()">
Download JSON
</button>
<div title="As reported by navigator.userAgent" id="syscolors-user-agent-div">
<b>System parameters:</b> <span id="syscolors-user-agent"></span>
</div>
</div>
<div id="syscolors-intro-container" class="syscolors-inner-container">
<!-- #region(collapsed) intro-->
<details>
<summary>CSS System Color Introduction</summary>
<div id="syscolors-intro-main">
<p>CSS provides a system-wide color scheme, that automatically handles light & dark modes,
requires little effort to implement by web designers and is accessible & user-friendly.
System Colors are derived by the browser from the user's operating system's color scheme.</p>
Advantages of using system colors include:
<ul>
<li>With just a few statements a website can handle light & dark modes.</li>
<li>Application colors will match others providing a consistent user experience.</li>
<li>They are designed to adapt to different light/dark modes and contrast settings.</li>
<li>They are ideal for creating accessible and user-friendly interfaces.</li>
<li>They can be used in combination with other color values to create a harmonious color palette.</li>
</ul>
<blockquote>
Avoid specifying different colors for
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/light-dark">(light or dark
mode)</a>:
let the browser & OS handle it for you!
</blockquote>
<p>There are also a few other new "system" things out now:
<a href="https://css-trricks.com/system-things">System Fonts, font weights, icons</a> which
provides a neat new way to re-envision who does what. A complete
<a href="https://projects.dutchcelt.com/system.css/">system.css</a> can provide a quick
start!
</p>
<h3>What the system specification doesn't/can't do:</h3>
<ul>
<li>Provide classes to readily access the suggested styles</li>
<li>Provide a JSON representation of the colors</li>
<li>Show the colors visually: not by color mode, by category, or as interpreted by a browser</li>
<li>Provide explicit terms or names for the implicit categories or groups it creates</li>
<li>Show the color scheme in use as intended</li>
</ul>
<p><strong>This web page addresses these points:</strong></p>
<ul>
<li>We provide an independent file 'css-system-colors.css' that sets up handy classes
corresponding with the suggested styles</li>
<li>The file <code>'css-system-json.js'</code> provides two different JSON representations
of the colors that can be adapted for your own use.</li>
<li>A JSON file can be downloaded which contains the actual colors (in RGBA
& hex format) for each color mode, as provided by the user's browser & operating system (OS).</li>
<li>We provide 3 different views of the colors: by category, with different
color modes implemented, and as actually displayed by the browser.</li>
<li>The 'System Colors Categories' section provides categories that make conceptualizing
the system colors easier and more natural. These match the classes in
the <code>'css-system-colors.css'</code> file.</li>
<li>Provides a micro-website and minimal input form to explore how best to use
the system colors.</li>
</ul>
<h3 id="history">History</h3>
<ul>
<li>CSS System Colors are not new but were originally part of
<a href="https://www.w3.org/TR/CSS2/ui.html#system-colors">CSS2</a>.
</li>
<li>With <img src="W3C.png" alt="W3C's"> CSS
<a href="https://www.w3.org/TR/css-color-3/#css-system">Color Module Level 3</a> they
were all listed as depreciated. (Apparently they enabled mimicking system
colors too well, and could be used for fake, evil
<a href="https://www.w3.org/TR/css-color-4/#security">phishing sites</a>. Just don't go
there!)
</li>
<li>The <a href="https://www.w3.org/TR/css-color-adjust-1/#color-scheme">color-scheme</a>
keyword was adopted around 2022.</li>
<li><a href="https://www.w3.org/TR/css-color-4/#css-system-colors">Color Module Level 4</a>,
revived the following colors: ButtonFace, ButtonText, GrayText, Highlight &
HighlightText. It also added a number of other as seen in the link above.
<a href="https://drafts.csswg.org/css-color/#typedef-deprecated-color">Deprecated</a>
colors were put into an appendix.
</li>
<li><a href="https://www.w3.org/TR/css-color-5/#light-dark">Color Module 5</a> adds
@color-profiles, color-mix(), light-dark() &
<a href="https://css-tricks.com/exploring-color-contrast-for-the-first-time/">contrast-color()</a>
functions & teases of future enhancements. System-colors remain as defined by
Color Module 4.
</li>
</ul>
<p>Current system colors are defined in the CSS Color Module Level 4 specification
and can be used in any property that accepts a color value. (Somewhere I've read
they were supposed to be prefixed with the system- keyword, such as
system-highlight or system-buttonface, but this only leads to errors for me.)</p>
<p>The colors are designed to adapt to different light/dark modes and contrast
settings, making them ideal for creating (accessible)[<a
href="https://whimsica11y.net/">https://whimsica11y.net/</a>]
and user-friendly (interfaces)[<a
href="https://projects.dutchcelt.com/system.css/">https://projects.dutchcelt.com/system.css/</a>]. They
can be used in combination with other color values to create a harmonious color
palette theoretically, though this has not been explored much. Do see our Hue Panel below though.</p>
<h3 id="caveats">Caveats</h3>
<ul>
<li>"System Colors can theoretically can expose details of the user’s OS settings,
which is a fingerprinting risk."
<a href="https://www.w3.org/TR/css-color-4/#privacy">1</a>
</li>
<li>"The system colors, if they actually correspond to the user’s system colors,
pose a security risk, as they make it easier for a malware site to create user
interfaces that appear to be from the system. However, as several system
colors are now defined to be "generic", this risk is believed to be
mitigated." <a href="https://www.w3.org/TR/css-color-4/#security">2</a></li>
<li>"Authors may also use these keywords at any time, but should be careful to use
the colors in matching background-foreground pairs to ensure appropriate contrast,
as any particular contrast relationship across non-matching pairs (e.g. Canvas
and ButtonText) is not guaranteed.<a href="https://drafts.csswg.org/css-color/#css-system-colors">3</a>
</li>
</ul>
<details>
<summary>More Articles & References for the Eager</summary>
<ul><b>Standards</b>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/system-color">MDN Web Docs
shttps://developer.mozilla.org/en-US/docs/Web/CSS/system-color</a>]
</li>
<li><a
href="https://drafts.csswg.org/css-color/#css-system-colorss/example.html">https://drafts.csswg.org/css-color/#css-system-colorss/example.html</a>
</li>
</ul>
<ul><b>CSS System Color Articles</b>
<li><a
href="https://www.bram.us/2023/10/09/the-future-of-css-easy-light-dark-mode-color-switching-with-light-dark/">https://www.bram.us/2023/10/09/the-future-of-css-easy-light-dark-mode-color-switching-with-light-dark/</a>
</li>
<li><a href="https://web.dev/articles/color-scheme">Thomas Steiner
https://web.dev/articles/color-scheme</a>
</li>
<li><a href="https://blog.jim-nielsen.com/2021/css-system-colors/">Jim Nielsen's blog post
https://blog.jim-nielsen.com/2021/css-system-colors/</a>]
</li>
<li><a href="https://css-tricks.com/come-to-the-light-dark-side/">CSS Tricks article
https://css-tricks.com/come-to-the-light-dark-side/</a>
</li>
<li><a href="https://sarajoy.dev/blog/color-scheme/">Sara Joy https://sarajoy.dev/blog/color-scheme/</a>
</li>
</ul>
<ul><b>Example Code</b>
<li><a href="https://codepen.io/sarajw/pen/xxzyOMZ">https://codepen.io/sarajw/pen/xxzyOMZ</a></li>
<li><a href="https://4mrnhq.csb.app/">https://4mrnhq.csb.app/</a></li>
<li><a href="https://x4qtf8.csb.app/">https://x4qtf8.csb.app/</a></li>
<li><a
href="https://color-scheme-light-dark.netlify.app/">https://color-scheme-light-dark.netlify.app/</a>
</li>
</ul>
<ul><b>Baseline systems to use for your site that use CSS System Colors</b>
<li><a
href="https://projects.dutchcelt.com/system.css/example.html">https://projects.dutchcelt.com/system.css/example.html</a>
</li>
<li><a href="https://simplecss.org/demo/">https://simplecss.org/demo/</a></li>
<li><a href="https://picocss.com/docs/colors">https://picocss.com/docs/colors</a></li>
<li> <a
href="https://github.com/kevquirk/simple.css/blob/main/index.html">https://github.com/kevquirk/simple.css/blob/main/index.html</a>
</li>
<li><a href="https://projects.dutchcelt.com/system.css/">System.css:
https://projects.dutchcelt.com/system.css/</a></li>
</ul>
</p>
</details>
</div>
</details>
<!-- #endregion -->
</div>
<div id="syscolors-table-container" class="syscolors-inner-container">
<!-- #region(collapsed) table -->
<details open>
<summary id="syscolors-table-title">System Color Table</summary>
<p>CSS provides a system-wide color scheme, that automatically handles light & dark modes,
requires little effort to implement by web designers and is accessible & user-friendly.</p>
<p>These cards list each system color from the standard & its description. The neighboring cells'
<strong>background</strong>
show the actual (browser dependent) color provided by the browser for 'light' and 'dark' color modes. The
actual color is also provided in RGB and Hex notation. (Note that the few non-opaque colors are reported in
the RGBA format.) Hovering over each card displays the same text as in the card, and allows copying it to
your clipboard if desired.
</p>
<p>Use these colors anywhere you'd use another color, e.g., as a text, border or background style.</p>
<div id="syscolors-table">
<div class="syscolors-row-card syscolors-initial-card">
<div class="syscolors-row-text">
<span class="syscolors-category-span" category="category">Category</span>
<span class="syscolors-color-span"><strong>System Color</strong></span>
<span class="syscolors-desc-span"> — Description </span>
</div>
<div class="syscolors-row-light ">
<strong>This column displays colors in light mode</strong>
</div>
<div class="syscolors-row-dark Canvas">
<strong>This column displays colors in dark mode</strong>
</div>
</div>
</div>
</details>
<!-- #endregion -->
</div>
<div id="syscolors-grid-container" class="syscolors-inner-container">
<!-- #region(collapsed) grid -->
<details>
<summary id="syscolors-grid-title">System Colors Grouped by Color Mode</summary>
<div id="syscolors-grid">
<p>This 'grid' view is nearly identical to the above 'table' view, but
these cards are organized into separate panels for
light & dark modes and the text may be rearranged a bit.</p>
<div id="syscolors-grid-light" class="syscolors-inner-container syscolors-light">
<h2>Current System Colors: <span class="syscolors-grid-mode syscolors-preserve"></span> Light Color Mode
</h2>
<div class="syscolors-break"></div>
</div>
<div id="syscolors-grid-dark" class="syscolors-inner-container syscolors-dark">
<h2>Current System Colors: <span class="syscolors-grid-mode syscolors-preserve"></span> Dark Color Mode
</h2>
<div class="syscolors-break syscolors-preserve"></div>
</div>
</div>
</details>
<!-- #endregion -->
</div>
<div id="syscolors-class-container" class="syscolors-inner-container">
<!-- #region classes -->
<details open>
<summary>Utility Classes for System Colors</summary>
<div id="syscolors-class-main">
<p>The CSS System Color standard tacitly defines color 'categories' - and for each a brief description:
<ul>
<li>Accent - accented user interface controls</li>
<li>Canvas - application content or documents</li>
<li>Field - input fields</li>
<li>Mark - specially marked with the <code><mark></code> tag</li>
<li>GrayText - disabled text</li>
<li>Button - push buttons</li>
<li>Link - hyperlinks</li>
<li>Highlight - text of selected text</li>
<li>Selected - selected items</li>
</ul>
We've created a simple file (<code>css-system-colors.css</code>) that provides explicit classes
for each of these tacit categories. Now authors can easily assign a class to an HTML element
and have it display in an appropriate system defined (and accessible & user-friendly) color.</p>
<blockquote>Our system color classes offer one less thing to do!</blockquote>
<p>Each 'category' generally defines a text color and a background color that will display together well. (A
few categories define additional colors.) Normally a designer has to create a style
statement for each of the standard's individual colors in each category.</p>
<p>As an alternative, the 'css-system-colors.css' file provides handy
classes. Simply assign a class to an HTML element. Easy Peasy!</p>
<p>Each class (one per category) is listed and demonstrated below. The previous panels just showed
colors in the cell background. Here, we show text and background color using both selectors.</p>
<div id="syscolors-class-category">
<h2>Classes for System Colors</h2>
<div class="syscolors-class-card syscolors-initial-card">
<div class="syscolors-cell-text">
<span class="syscolors-category-span" className="Class">Class Name</span>
<!--span class="syscolors-name-span"><strong>Color Class</strong> —</span-->
<span class="syscolors-desc-span">Class Description</span>
</div>
<div class="syscolors-cell-light">These cells display the classes actual styles in light mode</div>
<div class="syscolors-cell-dark Canvas">These cells display the classes' actual styles in dark mode</div>
</div>
</div>
<details>
<summary>
Individual System Color Classes
</summary>
<div>In practice, authors may desire finer-grained control and
to specify text and background colors independently. If so,
these 'Individual Classes' allow you to still assign classes, without explicit style statements.
(Independent classes in <code>`css-system-colors.css`</code> all are preceded by `system-` to avoid
conflicting with those of the same name from the grouped classes.)
</div>
<div id="syscolors-class-individual">
<div class="syscolors-class-card syscolors-initial-card">
<div class="syscolors-cell-text">
<span class="syscolors-category-span" className="Class">Class Name</span>
<!--span class="syscolors-name-span"><strong>Color Class</strong> —</span-->
<span class="syscolors-desc-span">Class Description</span>
</div>
<div class="syscolors-cell-light">These cells display the classes actual styles in light mode</div>
<div class="syscolors-cell-dark Canvas">These cells display the classes' actual styles in dark mode
</div>
</div>
</div>
</details>
</div>
</details>
<!-- #endregion -->
</div>
<div id="syscolors-demo-container" class="syscolors-inner-container">
<!-- #region(collapsed) demo -->
<details open>
<summary>System Color Website & Form Example</summary>
<div id="syscolors-demo" open>
<div id="syscolors-demo-light" class="syscolors-inner-container">
<h3>Demo Page: <span class="syscolors-demo-mode"></span> Color Mode</h3>
<div class="myWebSite" id="idLightWebSite">
<header>
<a id="idLightHome"></a>
<h1>A Swell Website <code>h1</code></h1>
<nav>
<ul>
<li><a href="#idLightHome" class="active">Home</a></li>
<li><a href="#idLightColorPaletee">Color Palette</a></li>
<li><a href="#idLightBlog">Blog</a></li>
<li><a href="#idLightAboutUs">About Us</a></li>
</ul>
</nav>
</header>
<main>
<h3>Our Color Palette <code>h3</code></h3>
<section>
<a id="idLightColorPalette"></a>
<div>The CSS System Colors provide a very limited palette. Use it for your own site by
copying the sample code below, and possibly by adopting our `css-system-colors.css`
file which sets up two sets of useful classes for you.
<br />
<br />
It is <a href="https://web.dev/articles/prefers-color-scheme">easy to
extend them</a> with your
<a href="https://sarajoy.dev/blog/color-scheme/">own scheme</a> that
adds additional accent colors. This micro-site uses only two:
<ol>
<li>Primary: used for headings (except h1)</li>
<li>Contrast: used for h1, nav bar, footer, code (blocks), left margin of block quotes </li>
</ol>
(We could use color-mix in the future.) Click to change either color:
<div class="colorPalette">
<div class="primary">
<button id="idLightPrimary" class="picker" data-jscolor="{}">Primary</button>
</div>
<div class="contrast">
<button id="idLightContrast" class="picker" data-jscolor="{}">Contrast</button>
</div>
</div>
<br />
<details>
<summary><b>tl;dr</b> — click to see sample code for setting up another site's color
scheme...</summary>
<br />
This just sets up one 'primary' highlight. You can add more colors as needed.
<pre><code>
root: {
color-scheme: light dark;
--light-primary: rgb(10,0,230);
--dark-primary: rgb(108, 102, 237);
--primary: light-dark(var(--light-primary), var(--dark-primary));
}
</code></pre>
You may also add a class to set the color:
<pre><code>
root: {
.primary {
color: var(--primary);
background-color: light-dark(var(--dark-primary), var(--light-primary));
}
}
</code></pre>
If you use transparency/opacity, you can also add:
<pre><code>
root: {
--light-primary-rgb: 10,0,230;
--dark-primary-rgb: 108,102,237;
--primary-rgb: light-dark(var(--light-primary-rgb), var(--dark-primary-rgb));
.primary-transparent {
color: rgba(var(--primary-rgb), 0.5);
background-color: rgba(var(--primary-rgb), 0.5);
}
}
</code></pre>
<br />
Optionally you can also use:
<pre><code>
@media (prefers-color-scheme: dark) {
/* custom dark mode styles here */
}
</code></pre>
</details>
</div>
</section>
<h3>Our Blog <code>h3</code></h3>
<a id="idLightBlog"></a>
<section>
<div>
<article>
<h4>CSS System Color News <code>h4</code></h4>
<p>This demo paragraph illustrates a micro-website using light & dark color
modes & CSS System Colors. Micro-site content generally uses <code>CanvasText</code> for
the text color and <code>Canvas</code> for the background.</p>
<div>This is a <code>div</code> element with the same color settings.</div>
<p>This paragraph shows various HTML tags in action:
Normal, <abbr title="Abbreviations">abbr</abbr>, <cite>cite-ation</cite>, <del>del-ete</del>,
<dfn>dfn-definition</dfn>, <em>em-phasis</em>, <ins>ins-ert</ins>, <mark>mark</mark>,
<s>s-trike through</s>, <small>small</small>, <strong>strong</strong>, <sub>sub-script</sub>,
<sup>sup-erscript</sup>, <u>u-nderline</u>. <span class="GrayText">This uses the
<code>GrayText</code>
system color.</span>
</p>
<div>This div describes text selection. If you select some text, the <code>::selected</code>
pseudo
class sets a text color of <code>HighlightText</code> & background color of
<code>Highlight</code>. <span class="SelectedItem">This span has <code>Selection</code>
hardcoded as the background color and <code>SelectedItemText</code>
as the text color.</span>
</div>
<br />
<div>
<strong>Links</strong>
<ul>
<li><code>:hover</code> is not in <a
href="https://www.w3.org/TR/css-color-4/#css-system-colors">the standards</a>, so
browser-specific.</li>
<li>Here's a <a href="Mofified each document.load" class="uniqueUrl" onclick="return false;">
never visited link</a> using the <code>Link</code> system color.</li>
<li>Here's a <a href="https://google.com" class=":visited" onclick="return false;">visited
link using the <code>Visited</code> system color</a>
</li>
</ul>
</div>
</article>
</div>
<div>
<h4>Comments</h4>
<article>"Check this out!"</article><br />
<article>"Very helpful"</article>
</div>
<!--aside>
<h4>Aside</h4>
<p>Interesting extra info</p>
</aside-->
</section>
<h3>About Us</h3>
<div class="syscolors-break"></div>
<section class="aboutUs">
<a id="idLightAboutUs"></a>
<div class="card">
<img src="./images/avatar2.png" alt="Avatar" style="width:30%">
<div class="container">
<h4>Wanda Doe</h4>
<p>Architect</p>
</div>
</div>
<div class="card">
<img src="./images/avatar0.png" alt="Avatar" style="width:30%">
<div class="container">
<h4>Abbad Doe</h4>
<p>Engineer</p>
</div>
</div>
<blockquote>
This blockquote has the text color set to <code>Canvas</code> and a
background color of <code>CanvasText</code>. The borders use <code>AccentColor</code>.
</blockquote>
</section>
</main>
<footer>
©2024 Me, Myself & I
</footer>
</div>
<form class="myForm">
<h3>A Fine Form</h3>
<p>Text input, Number & Date illustrate <code>:focus</code>
which we've manually set to "SelectedItem". Notice
the <code>Field</code> reflects the color mode automatically.</p>
<label>Text input: <input type="text" placeholder="Hellooo"> text input field. The text color is set to
InputText and the background color is set to
Input."</label>
<label>Check box: <input type="checkbox"> Click to see selected color</label>
<div>Radio button:
<input type="radio" name="rName" value="1" id="idOn">
<label for="idOn">on</label>
<input type="radio" id="idOff" name="rName" value="2">
<label for="idOff">off</label>
</div>
<label>Select: <select name="cars" id="bikes">
<option>Cervelo</option>
<optgroup label="Domestic">
<option>Schwinn</option>
<option>Specialized</option>
<option>Trek</option>
<option>Cannondale</option>
</optgroup>
<option>Giant</option>
</select>
</label>
<div>File: <input type="file" /></div>
<div>Range: <input type="range" /> </div>
<div>Number: <input type="number" value="1" /> </div>
<div>Date: <input type="date" /> </div>
<div>Progress: <progress max="100" value="30"></progress> </div>
<div>Text area: <textarea id="textarea"></textarea></div>
<p>Unstyled Buttons:<br />
<button disabled="disabled">Disabled</button>
<button type="button">Cancel</button>
<button type="submit">Submit</button>
</p>
<p>Buttons using the Button class:<br />
<button class="Button" disabled="disabled">Disabled</button>
<button class="Button" style="border:5px solid ButtonBorder;" type="button">Cancel (with fat
ButtonBorder)</button>
<button class="Button" type="submit">Submit</button>
</p>
<button class="btn" class="syscolors-demo-button" style="cursor: pointer" title="non-functional button">
Fake Button</button>
<p>- This uses the ButtonText, ButtonFace & ButtonBorder colors. No hover color, but Click for the
ActiveText color!</p>
<!--
<input type="button">
<input type="checkbox">
<input type="color">
<input type="date">
<input type="datetime-local">
<input type="email">
<input type="file">
<input type="hidden">
<input type="image">
<input type="month">
<input type="number">
<input type="password">
<input type="radio">
<input type="range">
<input type="reset">
<input type="search">
<input type="submit">
<input type="tel">
<input type="text"> (default value)
<input type="time">
<input type="url">
<input type="week">
-->
</form>
</div>
</div>
</details>
<!-- #endregion -->
</div>
<div id="syscolors-hue-container" class="syscolors-inner-container">
<!-- #region(collapsed) hue -->
<details>
<summary>Hue & Color-Mix</summary>
<div id="syscolors-hue-demo">
<p>Whether in a light or dark mode, theme colors can be nicely mixed in OKLCH & HSL
color spaces. This demo is adapted from Sara Joy's
<a href="https://codepen.io/sarajw/pen/eYwLaYp"> CodePen</a>.
Her article at
<a href="https://sarajoy.dev/blog/color-scheme/">
https://sarajoy.dev/blog/color-scheme/</a>
explains more about color schemes.
</p>
<div>
<label for="hueSlider">Set the <b>Hue: <span class="hueValue">222</span></b></label>
<input id="hueSlider" type="range" min="0" max="360" value="222">
</div>
<br />
<div id="syscolors-hue-panels">
<div id="syscolors-hue-light" class="syscolors-inner-container">
<h3>Color-mix Panel: <span class="syscolors-hue-mode"></span> Color Mode</h3>
<div>
Theme color:
<br>
<div class="oklch"></div> in <a href="https://oklch.com">OKLCH color space</a>
<br>
<div class="hsl"></div> in <a href="https://hslpicker.com">HSL color space</a>
</div>
<br />
<p class="oklch">Themed text inside a themed paragraph<br />
oklch(50% 0.25 <span class="hueValue">222</span>)
</p>
<p class="hsl">Themed text inside a themed paragraph<br />
hsl(<span class="hueValue">222</span> 75% 50%)
</p>
</div>
</div>
</div>
</details>
<!-- #endregion -->
</div>
<div id="syscolors-deprecated-table-container" class="syscolors-inner-container">
<!-- #region(collapsed) dep-table -->
<details>
<summary id="syscolors-deprecated-table-title">Deprecated System Color Table</summary>
<div id="syscolors-deprecated-table">
<div class="syscolors-row-card syscolors-initial-card syscolors-tall-row">
<div class="syscolors-row-text">
<span class="syscolors-category-span" category="category">Category</span>
<span class="syscolors-color-span"><strong>Deprecated System Color</strong></span>
<span class="syscolors-desc-span"> — Description </span>
</div>
<div class="syscolors-row-light Canvas">
<strong>This column displays deprecated-colors in light mode</strong>
</div>
<div class="syscolors-row-dark Canvas">
<strong>This column displays deprecated-colors in dark mode</strong>
</div>
</div>
</div>
</details>
<!-- #endregion -->
</div>
<div id="syscolors-deprecated-grid-container" class="syscolors-inner-container">
<!-- #region(collapsed) demo -->
<details>
<summary id="syscolors-deprecated-title">
Deprecated System Color Grid
</summary>
<p>
You may - or may not - see a color as these are deprecated and
should not be used. The browser decides what to do with these
values. They are included here for reference purposes only.
</p>
<div id="syscolors-deprecated-grid">
<div id="syscolors-deprecated-light" class="syscolors-inner-container syscolors-light">
<h2>Deprecated System Colors: <span class="syscolors-grid-mode syscolors-preserve"></span> Light Color Mode
</h2>
<div class="syscolors-break"></div>
</div>
<div id="syscolors-deprecated-dark" class="syscolors-inner-container syscolors-dark">
<h2>Deprecated System Colors: <span class="syscolors-grid-mode syscolors-preserve"></span> Dark Color Mode
</h2>
<div class="syscolors-break"></div>
</div>
</div>
</details>
<!-- #endregion -->
</div>
<div id="syscolors-help-container" class="syscolors-inner-container">
<!-- #region(collapsed) help-->
<details>
<summary>Page Help</summary>
<div id="syscolors-help-main">
<p>This web page explores system-colors through several different views, each in
its own section. Note that the actual
colors displayed are <strong>specific to this browser/operating System</strong>!</p>
<p><img src="images/Screenshot-Options&SystemColorTable.png" alt="System Color Table"
style="max-width:800px;">
</p>
<blockquote>
Avoid specifying different colors for
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/light-dark">(light or dark
mode)</a>:
let the browser & OS handle it for you!
</blockquote>
<p>This page demonstrates the CSS System Colors in action.</p>
<h2 id="options">Options</h2>
<p><img src="images/Screenshot-Options.png" alt="alt text"></p>
<ul>
<li><strong>Color Scheme:</strong> The first option is a dropdown that sets the page's color
scheme from OS System default (auto), to explicitly light, or explicitly to
dark color mode. Note that form demonstration purposes many of the panels
explicitly set color mode to make the effect obvious.</li>
<li><strong>Sort by Category:</strong> By default the system colors are displayed
alphabetically. When clicked they are sorted by a category that I arbitrarily
assigned based on their description.</li>
<li><strong>Contrast:</strong> You can change the
<a href="https://css-tricks.com/come-to-the-light-dark-side/#aa-contrast-levels">contrast</a>
for the page using the slider.
</li>
<li>The "Options Panel" has a
<strong>"Download JSON"</strong> button at the bottom. This will download a JSON file with
the system colors and their description. Uniquely, we add the UserAgent as
reported by the browser/Operating system. We also then note the colors (as
RGB/RGBA & Hex) that were actually displayed -- both in light and dark color
modes!
</li>
<li><strong>User Agent:</strong> The browser's reported configuration (from
navigator.userAgent) is displayed here, for the record.</li>
</ul>
<h2 id="functionality">Functionality</h2>
<p>The web page delivers a handful of panels:</p>
<ul>
<li><strong>Introduction:</strong> This ideally is synchronized to contain the same information
you are reading now.</li>
<li>
<p><strong>System Color Table:</strong> This displays one 'card' for each of the 16 System
Colors, plus an initial one that serves as a legend. Each card displays the
category I assigned each color, followed by the color name and description.</p>
<p>Then there are two sections that show that color as displayed by the browser
in the background. The first blob of color is with the color-scheme explicitly
set to 'light'. The second is the same, but with the color-scheme set to
'dark'.</p>
<p>The actual color used for the backgrounds is then displayed in RGA and hex
notation. (On a few colors the colors have some level of opacity so are
reported in the RGBA format.)</p>
<img src="images/Screenshot-SystemColorTable.png" alt="System Color Table" />
</li>
<li>
<p><strong>System Color Grid:</strong> This is fairly similar to the table but groups the
colors into light and dark mode panels. The colors and values in these 'grids'
should match those in the 'tables', it just is a different presentation. Note
that there is a "Download JSON" button as described above under Options.
<img src="images/Screenshot-SystemColorsGrid.png" alt="System Colors Grid" height="200px">
</p>
</li>
<li>
<p><strong>Deprecated System Color Table:</strong> as above, but displays the deprecated
colors for anyone's interest.</p>
</li>
<li><strong>Deprecated System Color Grid:</strong> as above, but displays the deprecated colors
for anyone's interest.</li>
<li><strong>Demo Page:</strong> - The goal is to have a simple HTML page that
shows all the System Colors in use as intended - shown in light & dark mode of
course.</li>
</ul>
<p>You can view the colors and change the light/dark mode and contrast settings to
see how the colors adapt to different environments.</p>
<p>We uniquely display the actual color's
<a href="https://drafts.csswg.org/css-color/#rgb-functions">RGBA</a> values for the current
environment. Note that the values are likely to change when switching from light
to dark mode.
</p>
<p>Hovering over each card displays the same text as in the card,and allows copying
it to your clipboard if desired.</p>
<blockquote>
Note: System colors' actual RGBA values may vary depending on the user's
operating system and browser settings!
</blockquote>
<h2 id="license">License</h2>
<p>©2024 eoc.online under the permissive MIT License. Please note our contributions
though!</p>
<p><a href="https://eoc.online">https://eoc.online</a>: Open source tooling for Emergency Operation Centers
</p>
<p>Source & details at <a
href="https://github.com/eoconline/css-system-colors">https://github.com/eoconline/css-system-colors</a>
</p>
</div>
</details>
<!-- #endregion -->
</div>
<div id="syscolors-footer" class="syscolors-inner-container">
<!-- #region(collapsed) footer -->
<a href="https://eoc.online" title="Open source tooling for Emergency Operation Centers">©2024
eoc.online</a>
<span style="float: right"><a href="https://github.com/eoconline/css-system-colors">Details &
source code</a>
<!--img
src="https://img.shields.io/github/stars/eoconline/system-colors?style=social"
alt="GitHub stars"/-->
</span>
<!-- #endregion -->
</div>
</div>
</body>
</html>