-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocumentation.html
More file actions
541 lines (520 loc) · 30.7 KB
/
Copy pathdocumentation.html
File metadata and controls
541 lines (520 loc) · 30.7 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Applies a stored theme choice before first paint. The stylesheet already
follows prefers-color-scheme on its own, so this is only needed for the
one case CSS cannot see: a visitor whose stored choice differs from their
OS setting. Must stay inline and in <head> -- an external or deferred
script runs too late to prevent the flash. -->
<script>
try {
var retroTheme = localStorage.getItem('retro-theme');
if (retroTheme) document.documentElement.setAttribute('data-theme', retroTheme);
} catch (e) { /* storage blocked; prefers-color-scheme still applies */ }
</script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RetroCSS Documentation — Tokens, Components & Theming</title>
<meta name="description" content="How to install and theme RetroCSS: the four-tier colour token system, dark mode, utilities, accessibility and the JavaScript API.">
<link rel="canonical" href="https://phantompixeldev.github.io/RetroCSS/documentation.html">
<meta property="og:type" content="website">
<meta property="og:site_name" content="RetroCSS">
<meta property="og:url" content="https://phantompixeldev.github.io/RetroCSS/documentation.html">
<meta property="og:title" content="RetroCSS Documentation — Tokens, Components & Theming">
<meta property="og:image" content="https://phantompixeldev.github.io/RetroCSS/images/og-card.png">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://phantompixeldev.github.io/RetroCSS/images/og-card.png">
<meta property="og:description" content="How to install and theme RetroCSS: the four-tier colour token system, dark mode, utilities, accessibility and the JavaScript API.">
<link rel="stylesheet" href="dist/retro.min.css">
<link rel="stylesheet" href="site.css">
</head>
<body class="retro-body-bg">
<div class="page-shell">
<nav class="retro-nav" aria-label="Site">
<a href="index.html" class="retro-nav-item" data-retro-tooltip="Home page">Home</a>
<a href="documentation.html" class="retro-nav-item active" data-retro-tooltip="Documentation">Documentation</a>
<a href="https://github.com/phantompixeldev/retrocss" class="retro-nav-item" data-retro-tooltip="GitHub">GitHub</a>
<div class="retro-dropdown">
<button class="retro-nav-item retro-dropdown-toggle" data-retro-dropdown data-retro-tooltip="Examples">Examples ▾</button>
<div class="retro-dropdown-menu">
<a href="examples/index.html" class="retro-dropdown-item"><b>All examples</b></a>
<a href="examples/dashboard.html" class="retro-dropdown-item">Dashboard</a>
<a href="examples/blog.html" class="retro-dropdown-item">Blog</a>
<a href="examples/blog-post.html" class="retro-dropdown-item">Blog post</a>
<a href="examples/login.html" class="retro-dropdown-item">Sign in</a>
<a href="examples/register.html" class="retro-dropdown-item">Sign up</a>
<a href="examples/rtl.html" class="retro-dropdown-item">Right-to-left</a>
<a href="examples/theme-matrix.html" class="retro-dropdown-item">Theme matrix</a>
</div>
</div>
<button class="retro-nav-item retro-theme-toggle" type="button" data-retro-tooltip="Toggle dark/light mode">Toggle Theme</button>
</nav>
</div>
<hr class="retro-mt-5 retro-border-muted">
<div class="retro-main-layout retro-gap-4">
<div class="retro-sidebar sidebar-col">
<details class="sidebar-details" open>
<summary class="retro-sidebar-header">Docs Sections</summary>
<nav aria-label="Documentation navigation" class="retro-nav-vertical retro-w-full">
<div class="retro-sidebar-section">
<div class="retro-sidebar-group">Start</div>
<ul>
<li><a class="retro-nav-item" href="#getting-started">Getting started</a></li>
<li><a class="retro-nav-item" href="#installation">Installation</a></li>
<li><a class="retro-nav-item" href="#usage">Usage</a></li>
</ul>
</div>
<div class="retro-sidebar-section">
<div class="retro-sidebar-group">Build with it</div>
<ul>
<li><a class="retro-nav-item" href="#components">Components</a></li>
<li><a class="retro-nav-item" href="#utilities">Utilities</a></li>
<li><a class="retro-nav-item" href="#javascript-api">JavaScript API</a></li>
</ul>
</div>
<div class="retro-sidebar-section">
<div class="retro-sidebar-group">Make it yours</div>
<ul>
<li><a class="retro-nav-item" href="#theming">Theming & dark mode</a></li>
<li><a class="retro-nav-item" href="#customization">Customization</a></li>
<li><a class="retro-nav-item" href="#rtl">Right-to-left</a></li>
</ul>
</div>
<div class="retro-sidebar-section">
<div class="retro-sidebar-group">Reference</div>
<ul>
<li><a class="retro-nav-item" href="#accessibility">Accessibility</a></li>
<li><a class="retro-nav-item" href="#faq">FAQ</a></li>
</ul>
</div>
</nav>
</details>
</div>
<div class="main-content">
<section class="hero retro-card" aria-labelledby="doc-title">
<div class="retro-card-header">RetroCSS — Documentation</div>
<div class="retro-card-content">
<div class="hero-body">
<div>
<h1 class="retro-mt-0" id="doc-title">Everything the framework does</h1>
<p class="hero-lede">
Install it, theme it, and use the components and JavaScript API.
Every claim on this page is enforced by a check that runs in CI,
so the docs and the build cannot drift apart.
</p>
<pre class="retro-code"><code>npm install @phantompixeldev/retrocss</code></pre>
<div class="hero-cta">
<a class="retro-btn retro-btn-primary" href="#installation">Install</a>
<a class="retro-btn" href="index.html#section-navigation">See the components</a>
<a class="retro-btn" href="#javascript-api">JavaScript API</a>
</div>
</div>
<div>
<ul class="quick-links">
<li><a href="#installation">Bundlers & TypeScript</a>
<span class="ql-note">ESM, CJS, the exports map and shipped types</span></li>
<li><a href="#theming">Theming & dark mode</a>
<span class="ql-note">One token set; follows the OS with no flash</span></li>
<li><a href="#rtl">Right-to-left</a>
<span class="ql-note">Layout mirrors; the Win9x bevels do not</span></li>
<li><a href="#accessibility">Accessibility</a>
<span class="ql-note">Keyboard operation and WCAG AA, both themes</span></li>
<li><a href="https://github.com/phantompixeldev/retrocss/blob/main/MIGRATION.md">Migration guide</a>
<span class="ql-note">What changed in 4.0, and why</span></li>
</ul>
</div>
</div>
</div>
</section>
<div class="doc-section retro-prose retro-card" id="getting-started">
<h2>Getting Started</h2>
<p>RetroCSS is a retro-inspired CSS framework for building classic Win9x style UIs with modern CSS and JS. It provides SASS variables, utility classes, components, and a JS API for interactive features.</p>
<pre class="retro-code"><code><link rel="stylesheet" href="dist/retro.min.css">
<script src="dist/retro.min.js"></script></code></pre>
</div>
<div class="doc-section retro-prose retro-card" id="installation">
<h2>Installation</h2>
<h3>NPM</h3>
<pre class="retro-code"><code>npm install @phantompixeldev/retrocss</code></pre>
<h3>CDN</h3>
<pre class="retro-code"><code><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@phantompixeldev/retrocss/dist/retro.min.css">
<script src="https://cdn.jsdelivr.net/npm/@phantompixeldev/retrocss/dist/retro.min.js"></script></code></pre>
<h3>With a bundler</h3>
<p>The package ships ESM, CJS and a browser IIFE behind an
<code>exports</code> map, so a bare import resolves to JavaScript and
the stylesheet has its own entry point.</p>
<pre class="retro-code"><code>// JavaScript
import RetroCSS from '@phantompixeldev/retrocss'; // ESM
const RetroCSS = require('@phantompixeldev/retrocss'); // CJS
// Styles — pick one
import '@phantompixeldev/retrocss/css'; // full
import '@phantompixeldev/retrocss/css/min'; // minified</code></pre>
<p>Importing the bundle is safe during server-side rendering: it touches
no browser global until the DOM exists, so Next, Remix and Astro can
import it at the top level.</p>
<h3>Sass</h3>
<p>Import the source to compile against your own token values.</p>
<pre class="retro-code"><code>@use '@phantompixeldev/retrocss/scss' as retro;</code></pre>
<h3>TypeScript</h3>
<p>Type definitions ship in the package and are picked up automatically
— no <code>@types</code> install.</p>
<pre class="retro-code"><code>import RetroCSS, { RetroTheme, RetroHue } from '@phantompixeldev/retrocss';
const theme: RetroTheme = 'dark'; // 'light' | 'dark'
const hue: RetroHue = 'success'; // every hue with a full token set
RetroCSS.applyTheme(theme);
RetroCSS.toast.show('Saved', { type: hue, duration: 0 });</code></pre>
<h3>Manual</h3>
<pre class="retro-code"><code><link rel="stylesheet" href="dist/retro.min.css">
<script src="dist/retro.min.js"></script></code></pre>
</div>
<div class="doc-section retro-prose retro-card" id="usage">
<h2>Usage</h2>
<p>RetroCSS provides a wide range of components and utilities to build retro-styled interfaces. Here's a simple card example:</p>
<pre class="retro-code"><code><div class="retro-card">
<div class="retro-card-header">System Properties</div>
<div class="retro-card-content">
<p>Welcome to RetroCSS!</p>
<button class="retro-btn retro-btn-primary">OK</button>
</div>
</div></code></pre>
<p>See the <a href="#components">Components</a> section for more examples.</p>
</div>
<div class="doc-section retro-prose retro-card" id="components">
<h2>Components</h2>
<ul>
<li><b>Buttons:</b> <code>.retro-btn</code>, <code>.retro-btn-primary</code>, ...</li>
<li><b>Cards:</b> <code>.retro-card</code>, <code>.retro-card-header</code>, ...</li>
<li><b>Alerts:</b> <code>.retro-alert</code>, <code>.retro-alert-success</code>, ...</li>
<li><b>Tables:</b> <code>.retro-table</code>, <code>.retro-table-bordered</code>, <code>.retro-table-striped</code>, <code>.retro-table-sortable</code>, ...</li>
<li><b>Badges:</b> <code>.retro-badge</code>, <code>.retro-badge-primary</code>, ...</li>
<li><b>Navs:</b> <code>.retro-nav</code>, <code>.retro-nav-item</code>, ...</li>
<li><b>Modals:</b> <code>.retro-modal</code>, <code>.retro-modal-content</code>, ...</li>
<li><b>Accordion:</b> <code>.retro-accordion</code>, <code>.retro-accordion-toggle</code>, ...</li>
<li><b>Sidebar:</b> <code>.retro-sidebar</code>, <code>.retro-sidebar-header</code></li>
<li><b>Lists:</b> <code>.retro-list</code>, <code>.retro-list-bordered</code>, ...</li>
<li>...and many more! See the <a href="index.html">demo</a> for all available classes.</li>
</ul>
</div>
<div class="doc-section retro-prose retro-card" id="javascript-api">
<h2>JavaScript API</h2>
<p>RetroCSS includes a modular JavaScript API for interactive components. Each component is available through the global <code>RetroCSS</code> object.</p>
<h3>Initialization</h3>
<pre class="retro-code"><code>// Auto-initialization happens on DOMContentLoaded
// If you need to manually initialize:
RetroCSS.init();</code></pre>
<h3>Toast</h3>
<pre class="retro-code"><code>RetroCSS.toast.show('Message', { type: 'success', duration: 3000, html: false });</code></pre>
<h3>Modal</h3>
<pre class="retro-code"><code>RetroCSS.modal.show('modalId');
RetroCSS.modal.hide('modalId');</code></pre>
<h3>Form Validation</h3>
<pre class="retro-code"><code>RetroCSS.form.validate(formElement);
RetroCSS.form.validateField(inputElement);</code></pre>
<h3>Table sorting</h3>
<p>Add <code>.retro-table-sortable</code>. Headings become focusable and
sort on click, <kbd>Enter</kbd> or <kbd>Space</kbd>, and carry
<code>aria-sort</code> so the direction is announced.</p>
<pre class="retro-code"><code><table class="retro-table retro-table-sortable">
<thead>
<tr>
<th>Name</th> <!-- sniffed: number or text -->
<th data-sort="number">Size</th>
<th data-sort="none">Actions</th> <!-- opts the column out -->
</tr>
</thead>
<tbody>
<tr>
<td>README</td>
<td data-sort-value="2048">2 KB</td>
<td><button class="retro-btn retro-btn-sm">Edit</button></td>
</tr>
</tbody>
</table>
RetroCSS.table.init(); // only needed for tables added after load</code></pre>
<p><code>data-sort-value</code> sorts a formatted cell by what it means
rather than how it reads. The numeric sniff is strict on purpose: a
loose <code>parseFloat</code> reads <code>2023-09-01</code> as
<code>2023</code> and <code>SKU-001</code> as <code>-1</code>, which
silently sorts a date column by year and an ID column by the digits
after the first dash.</p>
<h3>Code blocks</h3>
<p>Any <code><pre class="retro-code"><code></code> gets a copy
button automatically. Outside a secure context, where
<code>navigator.clipboard</code> is unavailable, it selects the code
and prompts for <kbd>Ctrl</kbd>+<kbd>C</kbd> instead.</p>
<h3>Dropdown</h3>
<pre class="retro-code"><code>RetroCSS.dropdown.init();</code></pre>
<h3>File Upload</h3>
<pre class="retro-code"><code>RetroCSS.fileUpload.init();</code></pre>
<h3>Events System</h3>
<pre class="retro-code"><code>// Subscribe to an event
RetroCSS.events.on('init', data => {
console.log('Framework initialized at:', data.timestamp);
});
// Emit a custom event
RetroCSS.events.emit('custom:event', { foo: 'bar' });
// Remove an event listener
RetroCSS.events.off('init', myHandler);</code></pre>
<h3>Using a script tag</h3>
<pre class="retro-code"><code><script src="dist/retro.min.js"></script>
<script>
RetroCSS.toast.show('Saved', { type: 'success' });
RetroModal.show('myModal');
</script></code></pre>
<p>The bundle exposes <code>RetroCSS</code> plus the component singletons
(<code>RetroModal</code>, <code>RetroToast</code>, <code>RetroForm</code>,
<code>RetroTable</code>, <code>RetroDropdown</code>, <code>RetroFileUpload</code>,
<code>RetroEvents</code>) on <code>window</code>.</p>
</div>
<div class="doc-section retro-prose retro-card" id="theming">
<h2>Theming & Dark Mode</h2>
<p>Colours are organised in four tiers. Picking the right tier is the whole trick —
a value tuned as a background is usually unreadable as text.</p>
<table class="retro-table">
<thead><tr><th>Token</th><th>Role</th></tr></thead>
<tbody>
<tr><td><code>--retro-primary</code></td><td><strong>Fill.</strong> Background of a filled badge, button or alert.</td></tr>
<tr><td><code>--retro-primary-fg</code></td><td><strong>On-fill.</strong> Text placed <em>on</em> that fill.</td></tr>
<tr><td><code>--retro-primary-text</code></td><td><strong>On-surface.</strong> That hue used as text on a page background.</td></tr>
<tr><td><code>--retro-primary-hover</code> / <code>-active</code></td><td><strong>States.</strong> Fill under <code>:hover</code> / <code>:active</code>.</td></tr>
</tbody>
</table>
<p>All four exist for every hue: <code>primary, success, danger, warning, info, teal, tan,
pink, lime, cyan, orange, brown, violet, gray, maroon, gold, navy, olive, silver</code>.
Every pair clears WCAG AA (4.5:1) in both themes — run <code>npm run check:a11y</code> to verify.</p>
<p>Surface and text tokens: <code>--retro-body-bg</code> (page), <code>--retro-bg</code> (raised surface),
<code>--retro-text</code>, <code>--retro-text-muted</code>, <code>--retro-text-inverse</code>.
<code>--retro-black</code> and <code>--retro-white</code> still work and still invert between
themes, but <code>--retro-text</code> / <code>--retro-text-inverse</code> say what they mean.</p>
<p>Override SASS variables before importing <code>retro.scss</code>, or override the custom
properties at runtime:</p>
<pre class="retro-code"><code>:root {
--retro-primary: #0000aa; /* fill */
--retro-primary-fg: #ffffff; /* text on that fill */
--retro-primary-text: #000080; /* that hue as text on a page background */
--retro-font: 'MS Sans Serif', Arial, sans-serif;
}
[data-theme="dark"] {
--retro-body-bg: #181818;
--retro-bg: #232323;
--retro-primary: #4a90e2;
--retro-primary-fg: #000000; /* dark fills are light, so they want black on top */
--retro-primary-text: #4b91e2;
}</code></pre>
<p>Typography is tokenised too: <code>--retro-font</code>, <code>--retro-font-heading</code>,
<code>--retro-font-mono</code>, a <code>--retro-font-size-xs</code> … <code>-3xl</code>
scale in <code>rem</code>, <code>--retro-line-height</code>, and <code>--retro-font-weight-*</code>.
Headings default to the body stack; for a modern heading font set
<code>--retro-font-heading: 'Segoe UI', Tahoma, sans-serif;</code>.</p>
<p>Use the theme toggle button in the navbar to switch between light and dark mode.</p>
</div>
<div class="doc-section retro-prose retro-card" id="utilities">
<h2>Utilities</h2>
<p>Atomic helpers for layout and colour, all driven by the same tokens as the
components. Everything below is prefixed <code>retro-</code>.</p>
<h3>Layout</h3>
<pre class="retro-code"><code><div class="retro-main-layout"> <!-- sidebar + content shell -->
<aside class="retro-sidebar">…</aside>
<div class="main-content">…</div>
</div></code></pre>
<ul>
<li><strong>Flex:</strong> <code>retro-flex</code>, <code>retro-flex-col</code>, <code>retro-flex-wrap</code>, <code>retro-flex-1</code>, <code>retro-items-center</code>, <code>retro-justify-between</code>, <code>retro-self-center</code></li>
<li><strong>Spacing:</strong> <code>retro-m{t,b,l,r,x,y}-0…8</code> and <code>retro-p…</code>, plus <code>retro-gap-0…8</code> and <code>retro-mx-auto</code>. Scale: 0, 4, 8, 12, 16, 24, 32, 40, 48px.</li>
<li><strong>Sizing:</strong> <code>retro-w-full</code>, <code>retro-max-w-full</code>, <code>retro-max-w-prose</code>, <code>retro-max-w-{sm…xxl}</code></li>
<li><strong>Effects:</strong> <code>retro-raised</code>, <code>retro-sunken</code>, <code>retro-shadow-{sm,md,lg}</code>, <code>retro-rounded</code></li>
</ul>
<h3>Colour</h3>
<p><code>retro-bg-<hue></code> sets the fill <em>and</em> its matching on-fill text colour,
so a filled panel is legible in both themes from one class — that pairing is what
<code>npm run check:a11y</code> verifies. <code>retro-bg-<hue>-subtle</code> is a low-alpha
tint of the same hue that keeps normal body text on top.</p>
<pre class="retro-code"><code><div class="retro-bg-primary retro-p-4">Readable in both themes</div>
<div class="retro-bg-success-subtle retro-p-4">Tinted callout</div>
<span class="retro-text-danger">On-surface text</span></code></pre>
<p>Pick the tier by role: <code>retro-bg-*</code> for a fill,
<code>retro-text-*</code> for text on a page surface. Putting an on-surface colour
inside a filled panel is the one mistake to avoid — it paints the hue on itself.</p>
<h3>Prose</h3>
<p><code>retro-prose</code> caps running text at a comfortable measure while leaving
code blocks and tables full width.</p>
</div>
<div class="doc-section retro-prose retro-card" id="accessibility">
<h2>Accessibility</h2>
<p>Every text/surface pair clears WCAG AA (4.5:1) in both themes.
<code>npm run check:a11y</code> compiles the SCSS and asserts it, and also fails on any
<code>var(--retro-*)</code> that resolves to nothing.</p>
<ul>
<li><strong>Focus rings use <code>:focus-visible</code></strong> — keyboard users get a ring, mouse clicks do not. Text inputs still ring on click, because browsers treat their focus as visible.</li>
<li><strong>Modals are keyboard-safe</strong> — <code>role="dialog"</code>, <code>aria-modal</code>, a name taken from the header, focus moved in and trapped, the rest of the page <code>inert</code>, and focus returned to the trigger on close.</li>
<li><strong>Dropdowns are navigable</strong> — <code>aria-haspopup</code>/<code>aria-expanded</code>, <code>role="menu"</code>/<code>menuitem</code>, and Arrow / Home / End / Escape / Tab.</li>
<li><strong><code>prefers-reduced-motion</code> is honoured</strong> — animations and transitions are neutralised; looping text effects are switched off.</li>
</ul>
<p>Label icon-only controls with <code>.retro-sr-only</code>, and use
<code>.retro-sr-only-focusable</code> for a skip link:</p>
<pre class="retro-code"><code><button class="retro-btn">💾<span class="retro-sr-only">Save</span></button></code></pre>
</div>
<div class="doc-section retro-prose retro-card" id="customization">
<h2>Customization</h2>
<p>Override SASS variables or CSS custom properties to customize RetroCSS for your brand or project. See <code>src/scss/_variables.scss</code> for all available variables.</p>
<pre class="retro-code"><code>:root {
--retro-primary: #ff00cc;
--retro-bg: #222233;
--retro-font: 'Comic Sans MS', cursive, sans-serif;
}</code></pre>
<h3>Corner radius</h3>
<p>Every component routes its corners through one token, so a single
declaration rounds the whole framework. It is <code>0</code> by
default, which is what makes the chrome look like Windows.</p>
<pre class="retro-code"><code>:root { --retro-border-radius: 6px; }</code></pre>
<p>Two components keep their shape deliberately:
<code>.retro-nav-pills</code> and <code>.retro-tag</code>. Tables stay
square because <code>border-collapse: collapse</code> — what
merges their cell borders into a single hairline — makes every
engine ignore <code>border-radius</code>. Radio buttons and the
spinner are circles, as they are in Windows.</p>
<p>For one element at a time, use <code>.retro-rounded</code>,
<code>.retro-rounded-lg</code> or <code>.retro-rounded-full</code>.</p>
<h3>Lighting tokens</h3>
<p>Three tokens are fixed in both themes because they model a light
source rather than a surface colour. Use them for anything of that
kind: <code>--retro-black-rgb</code> and
<code>--retro-white-rgb</code> invert, which turns a drop shadow into
a glow and a backdrop into a spotlight.</p>
<pre class="retro-code"><code>--retro-shadow-rgb /* drop shadows */
--retro-scrim-rgb /* modal backdrops */
--retro-sheen-rgb /* gloss highlights */</code></pre>
</div>
<div class="doc-section retro-prose retro-card" id="rtl">
<h2>Right-to-left</h2>
<p>Set <code>dir="rtl"</code> and the layout mirrors. Spacing, text
alignment and start/end positioning are written with logical
properties, so there is nothing to import and no separate stylesheet.</p>
<pre class="retro-code"><code><html lang="ar" dir="rtl"></code></pre>
<p><b>The bevels deliberately do not mirror.</b> In the Win9x visual
language the light source is fixed at the top-left, and Windows itself
keeps it there in RTL. Flipping the raised and sunken edges would make
every button read as sunken on the wrong side, so only the semantic
accents move — an alert's stripe, a blockquote's rule —
because those mark where a line of text begins.</p>
<p>See the <a href="examples/rtl.html">right-to-left example</a>.</p>
</div>
<div class="doc-section retro-prose retro-card" id="faq">
<h2>FAQ</h2>
<h3>Is it responsive?</h3>
<p>Yes. Every page in the repository is checked at 1200, 980, 760, 420
and 360 px in both themes, and horizontal overflow fails the
build.</p>
<h3>Does it support dark mode?</h3>
<p>Yes, and it follows the operating system by default. The dark palette
is emitted under <code>prefers-color-scheme</code> as well as
<code>[data-theme="dark"]</code>, so a dark-OS visitor is painted dark
on the first frame with no flash. Using the theme toggle stores an
explicit choice, which then outranks the OS.</p>
<h3>Can I use it with React, Vue or Svelte?</h3>
<p>Yes. The package ships ESM, CJS and TypeScript definitions, and the
bundle is safe to import during server-side rendering. See
<a href="#installation">Installation</a>.</p>
<h3>Is it accessible?</h3>
<p>Every text and surface pair clears WCAG AA in both themes, and
every control the framework drives from script is reachable by
keyboard and carries an accessible name. Both are enforced in CI
rather than asserted here — see <a href="#accessibility">Accessibility</a>.</p>
<h3>Can I make it less square?</h3>
<p>Set one token: <code>--retro-border-radius</code>. See
<a href="#customization">Customization</a>.</p>
<h3>How big is it?</h3>
<p>About 22 KB of CSS and 8 KB of JavaScript, gzipped, with no
runtime dependencies. The JavaScript is optional — the
components are CSS-only until you need the interactive ones.</p>
</div>
</div>
</div>
<div class="page-shell">
<footer class="site-footer">
<div class="footer-grid">
<div>
<h2>Documentation</h2>
<ul>
<li><a href="#installation">Installation</a></li>
<li><a href="#javascript-api">JavaScript API</a></li>
<li><a href="#theming">Theming & dark mode</a></li>
<li><a href="#accessibility">Accessibility</a></li>
</ul>
</div>
<div>
<h2>Examples</h2>
<ul>
<li><a href="index.html">All components</a></li>
<li><a href="examples/dashboard.html">Dashboard</a></li>
<li><a href="examples/rtl.html">Right-to-left</a></li>
<li><a href="examples/theme-matrix.html">Theme matrix</a></li>
</ul>
</div>
<div>
<h2>Project</h2>
<ul>
<li><a href="https://github.com/phantompixeldev/retrocss">Source on GitHub</a></li>
<li><a href="https://www.npmjs.com/package/@phantompixeldev/retrocss">Package on npm</a></li>
<li><a href="https://github.com/phantompixeldev/retrocss/blob/main/MIGRATION.md">Migration guide</a></li>
</ul>
</div>
</div>
<p class="footer-note">
RetroCSS <span data-version>6.0.4</span> · MIT licensed ·
Built with the framework it documents.
</p>
</footer>
</div>
<button class="retro-btn to-top" type="button" id="to-top" aria-label="Back to top">↑ Top</button>
<script src="dist/retro.js"></script>
<script>
// Scroll-spy for the docs sidebar, plus back-to-top and the phone
// collapse. Page furniture, not framework behaviour.
(function () {
var links = Array.prototype.slice.call(
document.querySelectorAll('.retro-sidebar .retro-nav-item[href^="#"]')
);
var byId = {};
links.forEach(function (a) { byId[a.getAttribute('href').slice(1)] = a; });
var sections = Object.keys(byId)
.map(function (id) { return document.getElementById(id); })
.filter(Boolean);
var current = null;
function mark(id) {
if (id === current) return;
current = id;
links.forEach(function (a) { a.removeAttribute('aria-current'); });
if (byId[id]) byId[id].setAttribute('aria-current', 'true');
}
if (sections.length && 'IntersectionObserver' in window) {
var seen = new Set();
var io = new IntersectionObserver(function (entries) {
entries.forEach(function (e) {
if (e.isIntersecting) seen.add(e.target.id);
else seen.delete(e.target.id);
});
for (var i = 0; i < sections.length; i++) {
if (seen.has(sections[i].id)) { mark(sections[i].id); break; }
}
}, { rootMargin: '0px 0px -70% 0px', threshold: 0 });
sections.forEach(function (el) { io.observe(el); });
}
var details = document.querySelector('.sidebar-details');
var narrow = window.matchMedia('(max-width: 767px)');
function syncSidebar() { if (details) details.open = !narrow.matches; }
syncSidebar();
if (narrow.addEventListener) narrow.addEventListener('change', syncSidebar);
else if (narrow.addListener) narrow.addListener(syncSidebar);
var toTop = document.getElementById('to-top');
if (toTop) {
toTop.addEventListener('click', function () {
window.scrollTo({ top: 0, behavior: 'smooth' });
});
window.addEventListener('scroll', function () {
toTop.classList.toggle('is-visible', window.scrollY > 800);
}, { passive: true });
}
})();
</script>
</body>
</html>