css-tags 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +875 -0
  3. package/carousel.js +86 -0
  4. package/components/accessibility.css +51 -0
  5. package/components/actions.css +76 -0
  6. package/components/alert.css +122 -0
  7. package/components/application-patterns.css +122 -0
  8. package/components/badge.css +125 -0
  9. package/components/box-extra.css +220 -0
  10. package/components/box.css +75 -0
  11. package/components/card.css +130 -0
  12. package/components/carousel.css +76 -0
  13. package/components/chip.css +71 -0
  14. package/components/container.css +55 -0
  15. package/components/content-patterns.css +234 -0
  16. package/components/disclosure.css +581 -0
  17. package/components/divider.css +68 -0
  18. package/components/flex.css +59 -0
  19. package/components/form-patterns.css +273 -0
  20. package/components/form.css +130 -0
  21. package/components/grid.css +82 -0
  22. package/components/identity.css +59 -0
  23. package/components/img-container.css +141 -0
  24. package/components/img-container.js +75 -0
  25. package/components/list.css +69 -0
  26. package/components/loading.css +112 -0
  27. package/components/masonry.css +48 -0
  28. package/components/modal.css +73 -0
  29. package/components/navigation-patterns.css +245 -0
  30. package/components/navigation.css +200 -0
  31. package/components/popover.css +49 -0
  32. package/components/site-shell.css +180 -0
  33. package/components/status.css +110 -0
  34. package/components/table.css +98 -0
  35. package/components/tabs.css +103 -0
  36. package/components/tooltip.css +87 -0
  37. package/components/tooltips.css +73 -0
  38. package/components/view-transition.css +73 -0
  39. package/core/base.css +62 -0
  40. package/core/defaults.css +490 -0
  41. package/core/engine.css +32 -0
  42. package/core/mixins.css +376 -0
  43. package/core/palette-accent.css +8 -0
  44. package/core/palette-base.css +107 -0
  45. package/core/palette-extended.css +142 -0
  46. package/core/palette-feedback.css +62 -0
  47. package/core/palette.css +7 -0
  48. package/core/reset.css +270 -0
  49. package/core/text.css +171 -0
  50. package/core/theme.css +608 -0
  51. package/core/tokens.css +488 -0
  52. package/core/typography.css +327 -0
  53. package/index.css +66 -0
  54. package/layouts/layout-extra.css +204 -0
  55. package/layouts/layout-extras-helpers.css +19 -0
  56. package/layouts/layout.css +348 -0
  57. package/package.json +66 -0
  58. package/theme-generator.css +979 -0
  59. package/themes/example-brand.css +59 -0
  60. package/themes/theme-packs.css +31 -0
  61. package/types/css-tags.d.ts +482 -0
  62. package/utilities/utilities.css +564 -0
  63. package/view-transition.js +111 -0
package/README.md ADDED
@@ -0,0 +1,875 @@
1
+ # CSS Tags
2
+
3
+ **Style HTML directly with modern CSS. No classes, no frameworksβ€”just semantic markup that looks great.**
4
+
5
+ CSS Tags brings styling back to HTML. Instead of cluttering your markup with utility classes, you write clean, semantic tags, and the stylesheet makes them beautiful and responsive automatically.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install css-tags
11
+ ```
12
+
13
+ Import the complete layered stylesheet from your application entry point:
14
+
15
+ ```css
16
+ @import "css-tags";
17
+ ```
18
+
19
+ Or import it from JavaScript when your bundler supports CSS imports:
20
+
21
+ ```js
22
+ import "css-tags";
23
+ ```
24
+
25
+ The package includes full DOM and JSX declarations for the library's custom
26
+ tags. Add the global declarations once when your framework does not discover
27
+ the package types automatically:
28
+
29
+ ```ts
30
+ /// <reference types="css-tags" />
31
+ ```
32
+
33
+ For a no-build setup, use the npm CDN entry:
34
+
35
+ ```html
36
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/css-tags@0.1.0/index.css">
37
+ ```
38
+
39
+ Load your own theme stylesheet after CSS Tags so its layer is appended after
40
+ the library layers:
41
+
42
+ ```css
43
+ @import "css-tags";
44
+ @import "./my-theme.css";
45
+ ```
46
+
47
+ ### Before: Traditional CSS Frameworks
48
+
49
+ ```html
50
+ <!-- You are forced to describe the styling, not the content. -->
51
+ <div class="card max-w-sm rounded-lg overflow-hidden shadow-lg bg-white p-6">
52
+ <img class="w-full h-48 object-cover" src="..." alt="...">
53
+ <div class="py-4">
54
+ <div class="font-bold text-xl mb-2 text-gray-900">Amazing Product</div>
55
+ <p class="text-gray-700 text-base">Description of the product...</p>
56
+ </div>
57
+ <div class="pt-4 pb-2">
58
+ <button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
59
+ Buy Now
60
+ </button>
61
+ </div>
62
+ </div>
63
+ ```
64
+
65
+ ### After: CSS Tags
66
+
67
+ ```html
68
+ <!-- You describe the content. The styling is automatic. -->
69
+ <card>
70
+ <card-media><img src="..." alt="..."></card-media>
71
+ <card-body>
72
+ <h3>Amazing Product</h3>
73
+ <p>Description of the product...</p>
74
+ <button bg="var(--accent)">Buy Now</button>
75
+ </card-body>
76
+ </card>
77
+ ```
78
+
79
+ **The difference:** Clean, readable HTML that automatically adapts to themes, screen sizes, and user preferences, leading to a more maintainable and intuitive developer experience.
80
+
81
+ ## ✨ Try It Right Now
82
+
83
+ See it for yourself in 60 seconds. Copy the code below into an `index.html` file and open it in your browser.
84
+
85
+ ```html
86
+ <!DOCTYPE html>
87
+ <html lang="en">
88
+ <head>
89
+ <meta charset="UTF-8">
90
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
91
+ <title>CSS Tags Demo</title>
92
+
93
+ <!-- 1. Add the stylesheet. That's the only setup. -->
94
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/doeixd/CSS-Tags@latest/index.css">
95
+
96
+ </head>
97
+ <body p="var(--space-lg)">
98
+
99
+ <!-- 2. Write semantic HTML. No classes needed. -->
100
+ <layout-center max-width="70ch">
101
+ <card>
102
+ <card-body>
103
+ <h1>It Just Works.</h1>
104
+ <p>This component is already responsive and adapts to your system's light or dark mode. No build step, no configuration needed.</p>
105
+ <layout-cluster gap="var(--space-sm)">
106
+ <!-- 3. Use design tokens for declarative styling. -->
107
+ <button bg="var(--accent)">Get Started</button>
108
+ <button>Learn More</button>
109
+ </layout-cluster>
110
+ </card-body>
111
+ </card>
112
+ </layout-center>
113
+
114
+ </body>
115
+ </html>
116
+ ```
117
+
118
+ ## πŸ“– Docs
119
+
120
+ * **[API Reference](./API.md)** - Complete API documentation for layouts and components
121
+ * **[Color System Guide](./docs/guides/color-system.md)** - Understanding OKLCH and theming
122
+ * **[Component Documentation](./docs/components/)** - Individual component guides
123
+ * **[Core System Documentation](./docs/core/)** - Base styles, tokens, and mixins
124
+ * **[Layout Documentation](./docs/layouts/)** - Layout patterns and utilities
125
+ * **[Utilities Guide](./docs/utilities/)** - Utility classes reference
126
+ * **[Examples](./examples/)** - Interactive demos and real-world patterns
127
+ * **[Theming Guide](./docs/theming.md)** - Advanced theming and customization
128
+ * **[TypeScript Guide](./website/src/content/docs/guides/typescript.md)** - DOM and JSX globals for custom tags
129
+ * **[Type Declarations](./types/css-tags.d.ts)** - Shipped custom-element attribute types
130
+
131
+
132
+ ## πŸ›οΈ The Foundational Pillars of CSS Tags
133
+
134
+ This library isn't magicβ€”it's a showcase of powerful, modern CSS features that are now widely supported. Understanding them is key to mastering CSS Tags.
135
+
136
+ #### 1. Unknown HTML Tags (`<card>`, `<layout-grid>`)
137
+ * **What It Is:** Any HTML tag a browser doesn't recognize (like `<card>`) is rendered as a generic `<span>`-like element. It's valid HTML.
138
+ * **Why It Matters:** We can target these custom, semantic tags directly in CSS (`card { ... }`) to build an entire component system without needing classes like `.card`.
139
+
140
+ #### 2. The `oklch()` Color Space & Perceptual Uniformity
141
+ * **What It Is:** A new way to define colors using Lightness, Chroma (intensity), and Hue.
142
+ * **Why It Matters:** Unlike HSL (where 50% lightness looks different for yellow vs. blue), OKLCH is **perceptually uniform**. A 10% increase in lightness *looks* 10% lighter to the human eye, regardless of the color. This allows for mathematically precise and consistent theming.
143
+
144
+ #### 3. Relative Color Syntax
145
+ * **What It Is:** The ability to create a new color by modifying an existing one directly in CSS.
146
+ * **Why It Matters:** We no longer need to pre-define dozens of color variants (`--blue-500`, `--blue-600`, etc.). We can derive them on the fly, creating hover, active, and subtle states programmatically.
147
+ ```css
148
+ /* Make the button 10% darker on hover, whatever its original color is. */
149
+ button:hover {
150
+ background: oklch(from var(--bg) calc(l - 0.1) c h);
151
+ }
152
+ ```
153
+
154
+ #### 4. The `:has()` Selector (Parent Selector)
155
+ * **What It Is:** The ability to style a parent element based on the children it contains.
156
+ * **Why It Matters:** This enables powerful, automatic component variations without extra classes. A card can style itself differently just by detecting if an image is present.
157
+ ```css
158
+ /* If a card has <card-media>, make it a horizontal flex container. */
159
+ card:has(card-media) {
160
+ display: flex;
161
+ flex-direction: row;
162
+ }
163
+ ```
164
+
165
+ #### 5. The `attr()` Function
166
+ * **What It Is:** A CSS function that reads the value of an HTML attribute.
167
+ * **Why It Matters:** This allows us to pass "props" directly from HTML to CSS, creating declarative, configurable components without a single line of JavaScript.
168
+ ```html
169
+ <layout-grid min-item-size="300px">...</layout-grid>
170
+ ```
171
+ ```css
172
+ layout-grid {
173
+ grid-template-columns: repeat(auto-fit, minmax(attr(min-item-size, 16rem), 1fr));
174
+ }
175
+ ```
176
+
177
+ ## 🎯 Core Concepts
178
+
179
+ ### Declarative Styling
180
+ Control appearance through HTML attributes using modern CSS `attr()` function:
181
+
182
+ ```html
183
+ <!-- Size, color, and spacing controlled by attributes -->
184
+ <text size="lg" weight="bold" color="accent">Large bold text</text>
185
+
186
+ <!-- Layout adapts to container size -->
187
+ <layout-grid min-item-size="300px">
188
+ <card>Item 1</card>
189
+ <card>Item 2</card>
190
+ <card>Item 3</card>
191
+ </layout-grid>
192
+ ```
193
+
194
+ ### Design Token System
195
+ Everything uses CSS custom properties for consistent theming:
196
+
197
+ ```css
198
+ /* Change one value, update entire theme */
199
+ :root {
200
+ --primary-h: 280; /* Purple theme */
201
+ --space-md: 1.25rem; /* Larger spacing */
202
+ }
203
+ ```
204
+
205
+ ### Container Queries
206
+ Components respond to their container, not viewport:
207
+
208
+ ```html
209
+ <!-- Card adapts when container is 400px+ wide -->
210
+ <card>
211
+ <card-media>...</card-media>
212
+ <card-body>...</card-body>
213
+ </card>
214
+ ```
215
+
216
+ ### Auto-Contrast
217
+ Text colors automatically adjust for readability:
218
+
219
+ ```html
220
+ <!-- Text stays readable on any background -->
221
+ <text contrast>Always readable text</text>
222
+ ```
223
+
224
+ ## πŸ—οΈ Architecture Overview
225
+
226
+ The framework uses a sophisticated layered architecture with CSS cascade layers for predictable, maintainable styling. Each layer has a specific purpose and builds upon the previous layers.
227
+
228
+ ### Cascade Layer Structure
229
+
230
+ 1. **Reset Layer** (`@layer reset`): Zero-specificity browser normalization
231
+ 2. **Base Layer** (`@layer base`): Fundamental design tokens and global variables
232
+ 3. **Tokens Layer** (`@layer tokens`): Raw design values as CSS custom properties
233
+ 4. **Engine Layer** (`@layer engine`): Mathematical calculations and color transformations
234
+ 5. **Palette Layer** (`@layer palette`): Complete color palettes with systematic scales
235
+ 6. **Theme Layer** (`@layer theme`): Generative theme system creating semantic color roles
236
+ 7. **Defaults Layer** (`@layer defaults`): Base styling for HTML elements
237
+ 8. **Components Layer** (`@layer components`): Reusable UI components with scoped styling
238
+ 9. **Utilities Layer** (`@layer utilities`): Single-purpose utility classes
239
+ 10. **Layouts Layer** (`@layer layouts`): Declarative layout components
240
+
241
+ ### Key Architectural Principles
242
+
243
+ - **Hierarchical Token System**: Design tokens flow from abstract to concrete
244
+ - **Container Query-First Design**: Components adapt to their container rather than viewport
245
+ - **Scoped Component Styling**: Components use `@scope` to isolate styles
246
+ - **Attribute-Driven Components**: Components controlled by HTML attributes using `attr()`
247
+ - **Progressive Enhancement**: Modern features with graceful fallbacks
248
+
249
+ #### Example: Cascade Layers in Action
250
+ ```css
251
+ @layer reset, base, tokens, theme, components, utilities;
252
+
253
+ @layer reset {
254
+ /* Zero-specificity normalization */
255
+ *, *::before, *::after { box-sizing: border-box; }
256
+ }
257
+
258
+ @layer theme {
259
+ /* Semantic color roles */
260
+ :root {
261
+ --accent: oklch(55% 0.15 240);
262
+ --text-default: oklch(15% 0.02 240);
263
+ }
264
+ }
265
+
266
+ @layer components {
267
+ /* Component styles with proper specificity */
268
+ card { background: var(--surface-default); }
269
+ }
270
+ ```
271
+
272
+ ## 🎨 Advanced Features
273
+
274
+ ### OKLCH Color System
275
+ Perceptually uniform colors that look consistent across devices:
276
+
277
+ ```css
278
+ /* One hue value creates entire palette */
279
+ --primary-h: 220; /* Blue */
280
+ /* Automatically generates: --primary, --primary-muted, --primary-subtle, etc. */
281
+ ```
282
+
283
+ ### Relative Color Syntax
284
+ Create color variants dynamically without pre-defining them:
285
+
286
+ ```css
287
+ /* Hover state: 10% darker */
288
+ button:hover {
289
+ background: oklch(from var(--accent) calc(l - 0.1) c h);
290
+ }
291
+
292
+ /* Muted variant: reduced saturation */
293
+ .muted {
294
+ color: oklch(from var(--text-default) l calc(c * 0.3) h);
295
+ }
296
+ ```
297
+
298
+ ### Automatic Dark Mode
299
+ Colors adapt automatically to user preference:
300
+
301
+ ```css
302
+ @media (prefers-color-scheme: dark) {
303
+ /* Framework handles this automatically */
304
+ }
305
+ ```
306
+
307
+ ### Modern CSS Showcase
308
+ Learn cutting-edge CSS features:
309
+ - CSS Layers (`@layer`) for organized cascade
310
+ - Container Queries for component-level responsive design
311
+ - CSS Anchor Positioning for tooltips and popovers
312
+ - `@property` for typed CSS variables
313
+ - `@scope` for component isolation
314
+
315
+ ## 🎨 Deep Dive: OKLCH Color System
316
+
317
+ ### OKLCH Color Space
318
+ The framework uses OKLCH (Oklab Lightness-Chroma-Hue) for perceptually uniform color manipulation:
319
+
320
+ - **L (Lightness)**: 0-1 value representing perceptual lightness
321
+ - **C (Chroma)**: 0+ value representing color intensity (similar to saturation)
322
+ - **H (Hue)**: 0-360 degree value representing the color
323
+
324
+ **Advantages over RGB/HSL:**
325
+ - **Perceptual Uniformity**: Equal steps correspond to equal perceived changes
326
+ - **Intuitive Control**: Separate manipulation of lightness, chroma, and hue
327
+ - **Wide Gamut**: Access to colors outside traditional sRGB space
328
+ - **Better Interpolation**: More natural color transitions
329
+
330
+ ### Hierarchical Token System
331
+
332
+ #### 1. Base Hue Tokens
333
+ Foundation hues that define the color palette:
334
+ ```css
335
+ --primary-h: 220; /* Primary color hue (blue) */
336
+ --success-h: 160; /* Success color hue (green) */
337
+ --warning-h: 35; /* Warning color hue (amber) */
338
+ --error-h: 355; /* Error color hue (red) */
339
+ --gray-h: 220; /* Gray color hue (cool gray) */
340
+ ```
341
+
342
+ #### 2. Systematic Scales
343
+ 13-step scales for consistent perceptual progression:
344
+ ```css
345
+ /* Lightness Scale (0-12, lightest to darkest) */
346
+ --scale-l-0: 0.98; /* Nearly white */
347
+ --scale-l-6: 0.60; /* Mid-range */
348
+ --scale-l-12: 0.10; /* Nearly black */
349
+
350
+ /* Chroma Scale (1-9, least to most saturated) */
351
+ --scale-c-1: 0.02; /* Very subtle */
352
+ --scale-c-7: 0.14; /* Balanced saturation */
353
+ ```
354
+
355
+ #### 3. Color Palettes
356
+ Complete 13-step palettes for each hue:
357
+ ```css
358
+ --accent-palette-0: oklch(var(--scale-l-0) min(var(--scale-c-1), var(--clamp-max-c-0)) var(--primary-h));
359
+ --accent-palette-6: oklch(var(--scale-l-6) var(--scale-c-7) var(--primary-h));
360
+ --accent-palette-12: oklch(var(--scale-l-12) min(var(--scale-c-2), var(--clamp-max-c-12)) var(--primary-h));
361
+ ```
362
+
363
+ #### 4. Semantic Color Roles
364
+ Meaningful color assignments for UI consistency:
365
+ ```css
366
+ /* Surface Hierarchy */
367
+ --surface-muted: oklch(var(--scale-l-2) var(--scale-c-1) var(--gray-h));
368
+ --surface-default: oklch(var(--scale-l-3) var(--scale-c-2) var(--gray-h));
369
+ --surface-overt: oklch(var(--scale-l-5) var(--scale-c-3) var(--gray-h));
370
+
371
+ /* Text Hierarchy */
372
+ --text-muted: oklch(var(--scale-l-7) var(--scale-c-1) var(--gray-h));
373
+ --text-default: oklch(var(--scale-l-10) var(--scale-c-2) var(--gray-h));
374
+ --text-overt: oklch(var(--scale-l-12) var(--scale-c-3) var(--gray-h));
375
+
376
+ /* Brand Colors */
377
+ --accent: oklch(var(--scale-l-6) var(--scale-c-7) var(--primary-h));
378
+ --success: oklch(var(--scale-l-5) var(--scale-c-7) var(--success-h));
379
+ ```
380
+
381
+ ### Automatic Contrast Calculation
382
+ Sophisticated algorithm that calculates readable text colors dynamically:
383
+
384
+ ```css
385
+ --auto-contrast-text: oklch(
386
+ from var(--bg, var(--base))
387
+ clamp(0.1, (var(--l-threshold, 0.65) / l - 1) * 999, 0.98)
388
+ min(c, var(--c-threshold, 0.08))
389
+ h
390
+ );
391
+ ```
392
+
393
+ **How it works:**
394
+ 1. Takes the background color as input
395
+ 2. Calculates appropriate lightness for sufficient contrast
396
+ 3. Constrains chroma for better readability
397
+ 4. Maintains hue harmony with the background
398
+
399
+ ### Color Transformations
400
+ Systematic color variants using OKLCH calculations:
401
+
402
+ ```css
403
+ /* Muted variant - reduced chroma, slightly darker */
404
+ --color-to-muted: oklch(from var(--color-base) calc(l * 0.97) calc(c * 0.3) h);
405
+
406
+ /* Subtle variant - higher lightness, much lower chroma */
407
+ --color-to-subtle: oklch(from var(--color-base) calc(l * 1.15) calc(c * 0.12) h);
408
+
409
+ /* Overt variant - slightly darker, higher chroma */
410
+ --color-to-overt: oklch(from var(--color-base) calc(l * 0.85) calc(c * 1.2) h);
411
+ ```
412
+
413
+ ### Dark Mode Adaptation
414
+ Colors automatically adapt to `prefers-color-scheme`:
415
+
416
+ ```css
417
+ @media (prefers-color-scheme: dark) {
418
+ :root:not(.light) {
419
+ --base: oklch(var(--scale-l-12) var(--scale-c-1) var(--gray-h));
420
+ --surface-default: oklch(var(--scale-l-11) var(--scale-c-2) var(--gray-h));
421
+ --text-default: oklch(var(--scale-l-2) var(--scale-c-2) var(--gray-h));
422
+ }
423
+ }
424
+ ```
425
+
426
+ Each semantic role is individually optimized for dark mode rather than simple inversion.
427
+
428
+ ### High Contrast Mode Support
429
+ Enhanced visibility for users with visual impairments:
430
+
431
+ ```css
432
+ @media (prefers-contrast: more) {
433
+ :root {
434
+ --contrast-multiplier: 1.2;
435
+ --text-default: oklch(calc(var(--scale-l-12) * var(--contrast-multiplier)) var(--scale-c-2) var(--gray-h));
436
+ }
437
+ }
438
+ ```
439
+
440
+ ### Color Scale Usage Guidelines
441
+
442
+ **Steps 0-2**: Very light shades
443
+ - Subtle backgrounds and highlights
444
+ - Placeholder text
445
+ - Disabled states
446
+
447
+ **Steps 3-5**: Light shades
448
+ - Card backgrounds
449
+ - Subtle UI elements
450
+ - Secondary surfaces
451
+
452
+ **Steps 6-8**: Mid-range shades
453
+ - Primary UI elements
454
+ - Borders and dividers
455
+ - Interactive states
456
+
457
+ **Steps 9-11**: Dark shades
458
+ - Body text
459
+ - Secondary text
460
+ - Prominent elements
461
+
462
+ **Step 12**: Darkest shade
463
+ - Headings and emphasis
464
+ - High-contrast text
465
+ - Strong accents
466
+
467
+ ## πŸ“ Component Deep Dive: `<text>` and `<box>`
468
+
469
+ ### `<text>`: Declarative Typography Component
470
+
471
+ The `<text>` component provides powerful, attribute-driven typography control without requiring CSS classes. It integrates deeply with the design token system for consistent theming.
472
+
473
+ #### Key Features
474
+ - **Attribute-Based Styling**: Control size, weight, color, alignment via HTML attributes
475
+ - **Design Token Integration**: Maps to CSS variables from theme and token layers
476
+ - **Auto-Contrast**: `contrast` attribute calculates readable text color against any background
477
+ - **Text Truncation**: Single-line (`truncate`) and multi-line (`lines="3"`) truncation
478
+ - **Modern CSS**: Uses `attr()` function for dynamic, type-safe styling
479
+
480
+ #### Usage Examples
481
+ ```html
482
+ <!-- Basic styling -->
483
+ <text size="lg" weight="bold" color="accent">Large bold accent text</text>
484
+
485
+ <!-- Auto-contrast for readability on any background -->
486
+ <text contrast>Always readable text</text>
487
+
488
+ <!-- Truncation -->
489
+ <text truncate>Single-line truncated text that will be cut off...</text>
490
+ <text lines="3">Multi-line truncated text that wraps to 3 lines maximum...</text>
491
+
492
+ <!-- Advanced styling -->
493
+ <text size="xl" weight="semibold" color="overt" align="center" leading="relaxed">
494
+ Centered, large, semibold text with relaxed line height
495
+ </text>
496
+ ```
497
+
498
+ #### Supported Attributes
499
+ - **Size**: `xs`, `sm`, `base`, `lg`, `xl`, `2xl`, `3xl`, `4xl`
500
+ - **Weight**: `thin`, `light`, `normal`, `medium`, `semibold`, `bold`, `black`
501
+ - **Color**: `muted`, `subtle`, `default`, `overt`, `link`, `accent`, `secondary`, `success`, `warning`, `error`, `info`
502
+ - **Leading**: `none`, `tight`, `snug`, `normal`, `relaxed`, `loose`
503
+ - **Align**: `start`, `center`, `end`, `justify`
504
+ - **Transform**: `none`, `capitalize`, `uppercase`, `lowercase`
505
+ - **Style**: `normal`, `italic`
506
+ - **Wrap**: `balance`, `wrap`, `nowrap`, `pretty`
507
+
508
+ ### `<box>`: Versatile Utility Container
509
+
510
+ The `<box>` component is a "Swiss Army Knife" for layouts and styling, allowing declarative control of dozens of CSS properties through HTML attributes.
511
+
512
+ #### Key Features
513
+ - **Attribute-Driven Styling**: Control display, spacing, sizing, colors via attributes
514
+ - **Logical Properties**: Uses modern CSS logical properties for spacing
515
+ - **Type-Safe Attributes**: `attr()` function with type checking and fallbacks
516
+ - **Zero-Specificity**: No class-based conflicts
517
+ - **Flexible Layout**: Supports flex, grid, and traditional layouts
518
+
519
+ #### Usage Examples
520
+ ```html
521
+ <!-- Basic container -->
522
+ <box p="1rem" bg="var(--surface-subtle)" radius="0.5rem">
523
+ Content with padding and background
524
+ </box>
525
+
526
+ <!-- Flex layout -->
527
+ <box display="flex" px="2rem" py="1rem" gap="1rem" align="center">
528
+ <div>Item 1</div>
529
+ <div>Item 2</div>
530
+ </box>
531
+
532
+ <!-- Spacer element -->
533
+ <box height="2rem"></box>
534
+
535
+ <!-- Card-like component -->
536
+ <box p="1.5rem" bg="white" border="1px solid var(--outline)" radius="0.75rem" max-width="300px" shadow="var(--shadow-md)">
537
+ <h3>Card Title</h3>
538
+ <p>Card content with shadow and border...</p>
539
+ </box>
540
+
541
+ <!-- Grid layout -->
542
+ <box display="grid" grid-template-columns="1fr 1fr" gap="1rem">
543
+ <div>Column 1</div>
544
+ <div>Column 2</div>
545
+ </box>
546
+ ```
547
+
548
+ #### Supported Attributes
549
+ - **Display & Layout**: `display` (block, flex, grid, inline, etc.)
550
+ - **Spacing**: `p`, `px`, `py`, `m`, `mx`, `my` (padding/margin with logical properties)
551
+ - **Sizing**: `width`, `height`, `max-width`
552
+ - **Appearance**: `bg`, `color`, `border`, `radius`
553
+ - **Typography**: `align`
554
+ - **Flexbox**: `flex-direction`, `justify-content`, `align-items`, `gap`
555
+ - **Grid**: `grid-template-columns`, `grid-template-rows`, `gap`
556
+
557
+ #### Technical Implementation
558
+ The component uses the `attr()` function with type checking for safety:
559
+ ```css
560
+ --padding: attr(p type(<length-percentage>), 0);
561
+ ```
562
+
563
+ This provides type safety, fallbacks, and dynamic updates when attributes change. It employs logical properties (`padding-inline`, `padding-block`) for better internationalization support.
564
+
565
+ ## πŸš€ Quick Start Guide
566
+
567
+ Get your project running with CSS Tags in three simple steps.
568
+
569
+ ### 1. Include the CSS
570
+ Add the stylesheet to the `<head>` of your HTML file.
571
+
572
+ ```html
573
+ <!-- CDN (Recommended for prototyping) -->
574
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/doeixd/CSS-Tags@latest/index.css">
575
+ ```
576
+ *(See [Installation](#-installation) for other methods).*
577
+
578
+ ### 2. Write Semantic HTML
579
+ Use the provided custom elements to structure your content logically. The styles are applied automatically.
580
+
581
+ ```html
582
+ <layout-page>
583
+ <header slot="header">...</header>
584
+ <main slot="main">
585
+ <layout-center max-width="65ch">
586
+ <h1>My Awesome Article</h1>
587
+ <p>This content is perfectly centered and readable.</p>
588
+ </layout-center>
589
+ </main>
590
+ </layout-page>
591
+ ```
592
+
593
+ ### 3. Customize Your Theme (Optional)
594
+ Create a `<style>` tag or a local CSS file to override the default design tokens. The entire design system will adapt instantly.
595
+
596
+ ```css
597
+ :root {
598
+ --primary-h: 280; /* Changes the theme to purple */
599
+ --font-family-sans: 'Inter', sans-serif;
600
+ --radius-md: 0.75rem; /* Makes corners more rounded */
601
+ --space-md: 1.25rem; /* Increases base spacing */
602
+ }
603
+ ```
604
+
605
+ ## πŸ“š What You Get: Component & Layout Library
606
+
607
+ CSS Tags provides a comprehensive set of pre-built, accessible, and responsive components, organized into logical categories.
608
+
609
+ ### Layout Components
610
+ Declarative layout primitives that adapt to content and container size using container queries.
611
+
612
+ * `<layout-center>`: Centers content with a max-width for optimal readability. [[docs/layouts/layout.md](docs/layouts/layout.md)]
613
+ ```html
614
+ <layout-center max-width="70ch">
615
+ <p>Centered content with max width for readability.</p>
616
+ </layout-center>
617
+ ```
618
+
619
+ * `<layout-grid>`: A powerful, responsive grid that automatically wraps columns based on available space. [[docs/layouts/layout.md](docs/layouts/layout.md)]
620
+ ```html
621
+ <layout-grid min-item-size="250px" gap="1rem">
622
+ <card>Item 1</card>
623
+ <card>Item 2</card>
624
+ <card>Item 3</card>
625
+ </layout-grid>
626
+ ```
627
+
628
+ * `<layout-stack>`: Stacks items vertically with consistent spacing. [[docs/layouts/layout.md](docs/layouts/layout.md)]
629
+ ```html
630
+ <layout-stack gap="1rem">
631
+ <h1>Title</h1>
632
+ <p>Description</p>
633
+ <button>Action</button>
634
+ </layout-stack>
635
+ ```
636
+
637
+ * `<layout-sidebar>`: Creates a classic sidebar layout that intelligently stacks on mobile devices. [[docs/layouts/layout.md](docs/layouts/layout.md)]
638
+ ```html
639
+ <layout-sidebar side-width="300px">
640
+ <aside slot="aside">Sidebar content</aside>
641
+ <main>Main content</main>
642
+ </layout-sidebar>
643
+ ```
644
+
645
+ * `<layout-cluster>`: Groups items horizontally that wrap onto new lines, perfect for tags or buttons. [[docs/layouts/layout.md](docs/layouts/layout.md)]
646
+ ```html
647
+ <layout-cluster gap="0.5rem">
648
+ <button>Button 1</button>
649
+ <button>Button 2</button>
650
+ <button>Button 3</button>
651
+ </layout-cluster>
652
+ ```
653
+
654
+ * `<layout-page>`: A full page structure with header, main, and footer slots. [[docs/layouts/layout.md](docs/layouts/layout.md)]
655
+ * `<layout-frame>`: Responsive media containers with aspect ratios. [[docs/layouts/layout.md](docs/layouts/layout.md)]
656
+ * `<layout-pad>`: Adds consistent padding. [[docs/layouts/layout.md](docs/layouts/layout.md)]
657
+ * `<layout-switcher>`: Switches from stack to row when items fit. [[docs/layouts/layout.md](docs/layouts/layout.md)]
658
+ * `<layout-reel>`: Horizontally scrolling container. [[docs/layouts/layout.md](docs/layouts/layout.md)]
659
+
660
+ ### UI Components
661
+ Pre-built UI components with scoped styling and modern CSS features.
662
+
663
+ * `<card>`: A flexible container with `<card-media>`, `<card-header>`, `<card-body>`, and `<card-footer>`. [[docs/components/card.md](docs/components/card.md)]
664
+ ```html
665
+ <card>
666
+ <card-media><img src="image.jpg" alt="Card image"></card-media>
667
+ <card-body>
668
+ <h3>Card Title</h3>
669
+ <p>Card content...</p>
670
+ <button>Action</button>
671
+ </card-body>
672
+ </card>
673
+ ```
674
+
675
+ * `<button>`: Accessible buttons with built-in `:hover`, `:active`, and `:focus-visible` states. [[docs/components/form.md](docs/components/form.md)]
676
+ ```html
677
+ <button bg="var(--accent)">Primary Action</button>
678
+ <button>Secondary Action</button>
679
+ ```
680
+
681
+ * `<alert>`: Semantic notification banners for `success`, `warning`, `error`, and `info`. [[docs/components/alert.md](docs/components/alert.md)]
682
+ ```html
683
+ <alert bg="var(--surface-success)">Success message</alert>
684
+ <alert bg="var(--surface-warning)">Warning message</alert>
685
+ ```
686
+
687
+ * `<badge>`: Small status indicators and labels. [[docs/components/badge.md](docs/components/badge.md)]
688
+ ```html
689
+ <badge bg="var(--success)">New</badge>
690
+ <badge bg="var(--warning)">Beta</badge>
691
+ ```
692
+
693
+ * `<modal>`: An overlay dialog powered by the native Popover API for robust accessibility and performance. [[docs/components/modal.md](docs/components/modal.md)]
694
+ * `<tooltip>`: Contextual help text with CSS Anchor Positioning. [[docs/components/tooltip.md](docs/components/tooltip.md)]
695
+ * `<popover>`: Overlay content with automatic positioning. [[docs/components/popover.md](docs/components/popover.md)]
696
+ * `<box>`: Versatile container controlled by HTML attributes. [[docs/components/box.md](docs/components/box.md)]
697
+ * `<chip>`: Compact elements for tags, filters, or selections. [[docs/components/chip.md](docs/components/chip.md)]
698
+ * `<container>`: Responsive container with max-widths. [[docs/components/container.md](docs/components/container.md)]
699
+ * `<flex>`: Flexible layout container. [[docs/components/flex.md](docs/components/flex.md)]
700
+ * `<grid>`: CSS Grid-based layout component. [[docs/components/grid.md](docs/components/grid.md)]
701
+ * Image containers: Token-driven frames available as `<img-container>`, `[data-img-container]`, or `.img-container`. [[docs/components/img-container.md](docs/components/img-container.md)]
702
+ * `<list>`: Styled lists with variants. [[docs/components/list.md](docs/components/list.md)]
703
+ * `<masonry>`: Pinterest-style masonry layout. [[docs/components/masonry.md](docs/components/masonry.md)]
704
+ * `<navigation>`: Navigation components. [[docs/components/navigation.md](docs/components/navigation.md)]
705
+ * `<table>`: Responsive data tables with proper semantics. [[docs/components/table.md](docs/components/table.md)]
706
+ * `<carousel>`: Touch-enabled carousel with indicators. [[docs/components/carousel.md](docs/components/carousel.md)]
707
+ * `<view-transition>`: Smooth page transitions. [[docs/components/view-transition.md](docs/components/view-transition.md)]
708
+ * Element patterns: Native-first icon/FAB actions, switches, compound inputs, ratings, avatars, toolbars, list navigation, chat/log surfaces, and vertical snap feeds. [[docs/components/element-patterns.md](docs/components/element-patterns.md)]
709
+
710
+ ### Form Components
711
+ Themed styles for form elements with accessibility and consistency.
712
+
713
+ * `<form>`: Styled form containers. [[docs/components/form.md](docs/components/form.md)]
714
+ * `<input>`, `<select>`, `<textarea>`: Enhanced form controls. [[docs/components/form.md](docs/components/form.md)]
715
+
716
+ ### Core System
717
+ Foundational CSS layers that power the entire framework.
718
+
719
+ * **Reset Layer**: Zero-specificity browser normalization. [[docs/core/reset.md](docs/core/reset.md)]
720
+ * **Base Layer**: Fundamental design tokens and global variables. [[docs/core/base.md](docs/core/base.md)]
721
+ * **Tokens Layer**: Raw design values as CSS custom properties. [[docs/core/tokens.md](docs/core/tokens.md)]
722
+ * **Engine Layer**: Mathematical calculations and color transformations. [[docs/core/engine.md](docs/core/engine.md)]
723
+ * **Palette Layer**: Complete color palettes with systematic scales. [[docs/core/palette.md](docs/core/palette.md)]
724
+ * **Theme Layer**: Generative theme system creating semantic color roles. [[docs/core/theme.md](docs/core/theme.md)]
725
+ * **Defaults Layer**: Base styling for HTML elements. [[docs/core/defaults.md](docs/core/defaults.md)]
726
+ * **Text Layer**: Typography foundations and responsive text. [[docs/core/text.md](docs/core/text.md)]
727
+ * **Mixins Layer**: Reusable CSS patterns and utilities. [[docs/core/mixins.md](docs/core/mixins.md)]
728
+
729
+ ### Utilities
730
+ Single-purpose utility classes for rapid styling.
731
+
732
+ * **Color Utilities**: Background, text, and border color classes. [[docs/utilities/utilities.md](docs/utilities/utilities.md)]
733
+ * **Spacing Utilities**: Padding, margin, and gap utilities. [[docs/utilities/utilities.md](docs/utilities/utilities.md)]
734
+ * **Typography Utilities**: Font size, weight, and alignment. [[docs/utilities/utilities.md](docs/utilities/utilities.md)]
735
+ * **Layout Utilities**: Display, flexbox, grid, and positioning. [[docs/utilities/utilities.md](docs/utilities/utilities.md)]
736
+ * **Responsive Utilities**: Breakpoint-specific classes. [[docs/utilities/utilities.md](docs/utilities/utilities.md)]
737
+
738
+ ### Themes
739
+ Pre-built and customizable theme systems.
740
+
741
+ * **Example Brand Theme**: Sample branded theme implementation. [[docs/themes/example-brand.md](docs/themes/example-brand.md)]
742
+ * **Theme Packs**: Collection of ready-to-use themes. [[docs/themes/theme-packs.md](docs/themes/theme-packs.md)]
743
+
744
+ ### JavaScript Enhancements
745
+ Interactive components with JavaScript enhancement.
746
+
747
+ * **Carousel Component**: Touch/swipe navigation and looping. [[carousel.js](carousel.js)]
748
+ * **Image Container**: Loading, fallback, and responsive-image enhancement. [[components/img-container.js](components/img-container.js)]
749
+ * **View Transitions**: Page transition management. [[view-transition.js](view-transition.js)]
750
+
751
+ ## 🎨 Advanced Concepts
752
+
753
+ * **Design Token System:** The entire system is controlled by CSS Custom Properties. Change a token once (`--primary-h`, `--space-md`), and your whole UI updates.
754
+ * **Container Queries:** Components respond to the size of their parent container, not just the browser viewport. A card in a narrow sidebar will look different from one in a wide content area, automatically.
755
+ * **Automatic Dark Mode:** The system automatically respects the user's `prefers-color-scheme` media query with no extra work required from you.
756
+ * **Accessibility First:** Components are built with accessibility as a priority, including proper focus states, ARIA roles where necessary, and high-contrast text colors.
757
+
758
+ ## πŸ”§ Installation
759
+
760
+ Choose the method that best fits your project.
761
+
762
+ ### CDN (Recommended for quick prototyping)
763
+ ```html
764
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/doeixd/CSS-Tags@latest/index.css">
765
+ ```
766
+
767
+ ### Download
768
+ For production use, it's best to host the file yourself.
769
+ 1. **[Download the latest `index.css` file](https://github.com/doeixd/CSS-Tags/blob/main/index.css)**.
770
+ 2. Place it in your project's CSS directory.
771
+ 3. Link to it in your HTML: `<link rel="stylesheet" href="your-css-folder/index.css">`.
772
+
773
+ ### Package status
774
+
775
+ CSS Tags is not currently published to npm. For production, vendor the stylesheet
776
+ or pin a specific Git commit/tag in your jsDelivr URL instead of using `@latest`.
777
+
778
+ ## πŸ› οΈ Customization Deep Dive
779
+
780
+ Override CSS variables to create a unique design system that matches your brand.
781
+
782
+ ### Brand Colors
783
+ Simply change the hue (`-h`) values. The entire color palette regenerates automatically.
784
+ ```css
785
+ :root {
786
+ --primary-h: 240; /* Blue primary */
787
+ --accent-h: 320; /* Magenta accent */
788
+ --success-h: 160; /* Green success */
789
+ }
790
+
791
+ /* Result: Complete theme with consistent colors */
792
+ --primary: oklch(55% 0.15 240);
793
+ --accent: oklch(60% 0.18 320);
794
+ --success: oklch(58% 0.15 160);
795
+ ```
796
+
797
+ ### Typography
798
+ Set your brand's font family, base size, and line height.
799
+ ```css
800
+ :root {
801
+ --font-family-sans: 'Inter', system-ui, sans-serif;
802
+ --font-size-base: 1rem;
803
+ --line-height-base: 1.6;
804
+ }
805
+ ```
806
+
807
+ ### Spacing & Borders
808
+ Adjust the global scale for spacing, border radius, and shadows.
809
+ ```css
810
+ :root {
811
+ --space-md: 1.25rem; /* Base spacing unit */
812
+ --radius-md: 0.75rem; /* Base border radius */
813
+ --shadow-md: 0 4px 6px oklch(0% 0% 0% / 0.1);
814
+ }
815
+ ```
816
+
817
+ ## ⚠️ When NOT to Use CSS Tags
818
+
819
+ This approach is powerful but opinionated. It may **not** be the best fit if you:
820
+
821
+ * **Need to support legacy browsers:** This framework relies heavily on modern CSS features not available in browsers like IE11.
822
+ * **Require extreme bundle size optimization:** While the file is small (~50KB), utility-first frameworks like Tailwind CSS can achieve smaller final builds with their JIT compilers.
823
+ * **Are deeply invested in a utility-first workflow:** This is a component-first, semantic-by-design alternative.
824
+ * **Need framework-specific components:** This is a pure CSS library and does not include React/Vue components out of the box.
825
+
826
+ ## 🌐 Browser Support
827
+
828
+ CSS Tags works best in the latest versions of all major browsers.
829
+
830
+ | Feature | Chrome | Firefox | Safari | Edge |
831
+ |:---|:---:|:---:|:---:|:---:|
832
+ | **Core Framework** | βœ… 111+ | βœ… 113+ | βœ… 16.4+ | βœ… 111+ |
833
+ | `:has()` Selector | βœ… 105+ | βœ… 121+ | βœ… 16+ | βœ… 105+ |
834
+ | Container Queries | βœ… 105+ | βœ… 110+ | βœ… 16+ | βœ… 105+ |
835
+ | OKLCH Colors | βœ… 111+ | βœ… 113+ | βœ… 15.4+ | βœ… 111+ |
836
+
837
+ *The framework includes graceful degradation, so pages will still be usable in older browsers, but layout and colors may be simplified.*
838
+
839
+ ## 🎯 Philosophy & Core Principles
840
+
841
+ This framework is built on principles that prioritize developer experience, accessibility, and future-proofing. As a showcase of modern CSS, it demonstrates advanced techniques while remaining practical for production use:
842
+
843
+ - **Semantic Styling**: Brings styling back to HTML tags using modern CSS techniques
844
+ - **Educational Showcase**: Demonstrates cutting-edge CSS features and best practices
845
+ - **Progressive Enhancement**: Starts with a solid baseline and enhances for capable browsers
846
+ - **Cascade Layering**: Explicit cascade order prevents specificity conflicts
847
+ - **Design Token System**: Single source of truth for all design values
848
+ - **Modern Color Science**: OKLCH for perceptually uniform color manipulation
849
+ - **Accessibility First**: Built-in support for dark mode, high contrast, and reduced motion
850
+ - **Utility-First Approach**: Rapid development with composable utility classes
851
+ - **Component Autonomy**: Self-contained components using container queries
852
+
853
+ #### Example: Semantic vs Utility Approach
854
+ ```html
855
+ <!-- Traditional utility classes -->
856
+ <div class="bg-white p-4 rounded shadow-md max-w-sm mx-auto">
857
+ <h2 class="text-xl font-bold mb-2">Title</h2>
858
+ <p class="text-gray-600">Content</p>
859
+ </div>
860
+
861
+ <!-- CSS Tags semantic approach -->
862
+ <card>
863
+ <card-body>
864
+ <h2>Title</h2>
865
+ <p>Content</p>
866
+ </card-body>
867
+ </card>
868
+ ```
869
+
870
+
871
+ <br />
872
+
873
+ ## πŸ“„ License
874
+
875
+ This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.