daftcss 1.3.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.
package/README.md ADDED
@@ -0,0 +1,383 @@
1
+ # Daft CSS
2
+
3
+ A semantic-first CSS framework with [shadcn/ui](https://ui.shadcn.com)-quality aesthetics. Style raw HTML — no JavaScript, no required utility classes, no JSX components.
4
+
5
+ ## Who is this for?
6
+
7
+ Daft CSS is for developers who want:
8
+
9
+ - **Beautiful defaults** without writing CSS or utility classes
10
+ - **Semantic HTML** that just works (`<button>` looks good, no classes needed)
11
+ - **Zero JavaScript** for interactive components like modals, accordions, and dropdowns
12
+ - **A tiny footprint** — one ~56 KB minified file
13
+
14
+ The idea is a tiny dependency that makes your app look polished out of the box, with a hierarchical variable system you can tweak from one root knob to per-component overrides.
15
+
16
+ ## Principles
17
+
18
+ - **Semantic HTML first.** Native elements (`<button>`, `<article>`, `<dialog>`, `<details>`) ship styled. You shouldn't need a class to get a polished result.
19
+ - **A few well-chosen classes, not a utility framework.** A small set of variant classes (`.secondary`, `.outline`, `.ghost`) and layout helpers (`.container`, `.grid`) for the cases native HTML can't express. This is not Tailwind — it's the minimum vocabulary on top of HTML.
20
+ - **shadcn/ui aesthetics, simpler internals.** We borrow shadcn's visual language because it's clean and tunable, but we don't borrow its variable graph. Daft's tokens form a tier system (root → scale → component) where most values derive from a handful of knobs at the top.
21
+ - **Connected by default, overridable when you need it.** Tweak `--spacing` and every component breathes differently. Tweak `--card-radius` to round just cards. The chain is the feature; you only break it when the value genuinely needs to differ.
22
+ - **No JavaScript.** Modals, dropdowns, accordions, tooltips — all CSS and native HTML APIs (`<dialog>`, popover, `<details>`).
23
+ - **Modern CSS only.** `light-dark()`, OKLCH, nesting, `color-mix()`, Popover, `@starting-style`. No polyfills, no fallbacks. The result is smaller, cleaner, and easier to read than the cross-browser layers older frameworks carry.
24
+
25
+ ## How is it different?
26
+
27
+ ### vs Pico CSS
28
+
29
+ Both style semantic HTML, but Daft targets app UIs over content sites and ships a more modern aesthetic.
30
+
31
+ | | Daft CSS | [Pico CSS](https://picocss.com) |
32
+ |--|----------|----------|
33
+ | Size (minified) | **~56 KB** | 83 KB |
34
+ | Aesthetics | shadcn/ui | Pico |
35
+ | Focus | App UIs | Landing pages |
36
+ | Source | CSS | SCSS |
37
+ | Dark mode | Native `light-dark()` | Separate stylesheet |
38
+ | Color system | OKLCH | HSL |
39
+ | Extras | Tooltips, dropdowns, button groups, badges | — |
40
+
41
+ Daft is **not** a drop-in replacement for Pico — variable names and class variants differ.
42
+
43
+ ### vs Franken UI / Franken Style
44
+
45
+ [Franken UI](https://franken-ui.dev) ports shadcn/ui to vanilla HTML — great idea, similar goal. Here's how we differ:
46
+
47
+ | | Daft CSS | Franken Style |
48
+ |--|----------|---------------|
49
+ | Total size | **~56 KB** | 823 KB (618 KB CSS + 205 KB JS) |
50
+ | JavaScript | None | Required |
51
+ | Approach | Semantic HTML | Utility classes (Tailwind) |
52
+ | HTML footprint | Small, native | Large, verbose |
53
+
54
+ **Code comparison — a simple card:**
55
+
56
+ ```html
57
+ <!-- Daft CSS -->
58
+ <article>
59
+ <header>Card Title</header>
60
+ <p>Card content goes here.</p>
61
+ <footer>
62
+ <button>Action</button>
63
+ </footer>
64
+ </article>
65
+ ```
66
+
67
+ ```html
68
+ <!-- Franken UI -->
69
+ <div class="uk-card uk-card-default">
70
+ <div class="uk-card-header">
71
+ <h3 class="uk-card-title">Card Title</h3>
72
+ </div>
73
+ <div class="uk-card-body">
74
+ <p>Card content goes here.</p>
75
+ </div>
76
+ <div class="uk-card-footer">
77
+ <button class="uk-button uk-button-primary">Action</button>
78
+ </div>
79
+ </div>
80
+ ```
81
+
82
+ 50% smaller HTML footprint, no JavaScript, and just 1/16th the total dependency size.
83
+
84
+ ## Quick Start
85
+
86
+ Add one line to your HTML:
87
+
88
+ ```html
89
+ <link rel="stylesheet" href="https://unpkg.com/daftcss@1/dist/daft.min.css">
90
+ ```
91
+
92
+ Or install via npm:
93
+
94
+ ```bash
95
+ npm install daftcss
96
+ ```
97
+
98
+ ```js
99
+ import 'daftcss/dist/daft.min.css';
100
+ ```
101
+
102
+ Then write semantic HTML:
103
+
104
+ ```html
105
+ <!doctype html>
106
+ <html lang="en">
107
+ <head>
108
+ <meta charset="utf-8">
109
+ <meta name="viewport" content="width=device-width, initial-scale=1">
110
+ <meta name="color-scheme" content="light dark">
111
+ <link rel="stylesheet" href="https://unpkg.com/daftcss@1/dist/daft.min.css">
112
+ <title>My App</title>
113
+ </head>
114
+ <body>
115
+ <main class="container">
116
+ <h1>Hello DAFT CSS</h1>
117
+ <p>Start building with semantic HTML.</p>
118
+ <button>Get Started</button>
119
+ </main>
120
+ </body>
121
+ </html>
122
+ ```
123
+
124
+ ## Components
125
+
126
+ ### Buttons
127
+
128
+ ```html
129
+ <button>Primary</button>
130
+ <button class="secondary">Secondary</button>
131
+ <button class="outline">Outline</button>
132
+ <button class="ghost">Ghost</button>
133
+ <button class="destructive">Destructive</button>
134
+ <button aria-busy="true">Loading</button>
135
+ ```
136
+
137
+ ### Forms
138
+
139
+ ```html
140
+ <form>
141
+ <label>Email <input type="email"></label>
142
+ <label>Password <input type="password"></label>
143
+ <label><input type="checkbox" role="switch"> Remember me</label>
144
+ <button type="submit">Sign In</button>
145
+ </form>
146
+ ```
147
+
148
+ ### Cards
149
+
150
+ ```html
151
+ <article>
152
+ <header>Card Title</header>
153
+ <p>Card content...</p>
154
+ <footer>
155
+ <button>Action</button>
156
+ </footer>
157
+ </article>
158
+ ```
159
+
160
+ ### Accordion
161
+
162
+ ```html
163
+ <details>
164
+ <summary>Click to expand</summary>
165
+ <p>Hidden content revealed.</p>
166
+ </details>
167
+ ```
168
+
169
+ ### Dropdown
170
+
171
+ ```html
172
+ <details class="dropdown">
173
+ <summary>Menu</summary>
174
+ <ul>
175
+ <li><a href="#">Option 1</a></li>
176
+ <li><a href="#">Option 2</a></li>
177
+ </ul>
178
+ </details>
179
+ ```
180
+
181
+ ### Modal
182
+
183
+ ```html
184
+ <button popovertarget="my-modal">Open Modal</button>
185
+ <dialog id="my-modal" popover>
186
+ <article>
187
+ <header>
188
+ <button aria-label="Close" popovertarget="my-modal"></button>
189
+ <strong>Modal Title</strong>
190
+ </header>
191
+ <p>Modal content here.</p>
192
+ <footer>
193
+ <button class="secondary" popovertarget="my-modal">Cancel</button>
194
+ <button>Confirm</button>
195
+ </footer>
196
+ </article>
197
+ </dialog>
198
+ ```
199
+
200
+ ### Navigation
201
+
202
+ ```html
203
+ <nav>
204
+ <ul>
205
+ <li><strong>Brand</strong></li>
206
+ </ul>
207
+ <ul>
208
+ <li><a href="#">About</a></li>
209
+ <li><a href="#" aria-current="page">Docs</a></li>
210
+ <li><button>Sign Up</button></li>
211
+ </ul>
212
+ </nav>
213
+ ```
214
+
215
+ ### Sidebar
216
+
217
+ An `<aside class="sidebar">` inside `<main>` becomes a fixed full-height column on desktop. Add the `popover` attribute and a `.sidebar-toggle` button for a mobile slide-out drawer — no JavaScript.
218
+
219
+ ```html
220
+ <body>
221
+ <header class="container-fluid">
222
+ <nav>
223
+ <ul>
224
+ <li>
225
+ <button class="ghost icon sidebar-toggle"
226
+ popovertarget="sidebar"
227
+ aria-label="Open menu">☰</button>
228
+ </li>
229
+ <li><strong>Admin</strong></li>
230
+ </ul>
231
+ </nav>
232
+ </header>
233
+
234
+ <main class="container-fluid">
235
+ <aside id="sidebar" class="sidebar" popover>
236
+ <nav>
237
+ <ul>
238
+ <li><strong>Overview</strong></li>
239
+ <li><a href="#" aria-current="page">Dashboard</a></li>
240
+ <li><a href="#">Reports</a></li>
241
+ </ul>
242
+ </nav>
243
+ </aside>
244
+
245
+ <section>
246
+ <!-- page content -->
247
+ </section>
248
+ </main>
249
+ </body>
250
+ ```
251
+
252
+ The `.sidebar-toggle` button auto-hides on desktop (≥768px). On mobile it opens the sidebar as a drawer via the native Popover API. Override `--aside-width` to change the column width.
253
+
254
+ ### Tooltips
255
+
256
+ ```html
257
+ <span data-tooltip="Tooltip text">Hover me</span>
258
+ <button data-tooltip="Help" data-placement="right">?</button>
259
+ ```
260
+
261
+ ### Tables
262
+
263
+ ```html
264
+ <table>
265
+ <thead>
266
+ <tr><th>Name</th><th>Status</th></tr>
267
+ </thead>
268
+ <tbody>
269
+ <tr><td>Alice</td><td>Active</td></tr>
270
+ <tr><td>Bob</td><td>Pending</td></tr>
271
+ </tbody>
272
+ </table>
273
+ ```
274
+
275
+ ### Grid
276
+
277
+ ```html
278
+ <div class="grid">
279
+ <div>Column 1</div>
280
+ <div>Column 2</div>
281
+ <div>Column 3</div>
282
+ </div>
283
+ ```
284
+
285
+ ## Utility Classes
286
+
287
+ For when semantic HTML alone isn't enough. Daft ships a small, opinionated set — not a full utility framework.
288
+
289
+ | Group | Classes |
290
+ |---|---|
291
+ | Text color | `.muted` `.primary` `.success` `.warning` `.destructive` |
292
+ | Text size | `.text-xs` `.text-sm` `.text-base` `.text-lg` `.text-xl` `.text-2xl` `.text-3xl` `.text-4xl` |
293
+ | Font weight | `.font-normal` `.font-medium` `.font-semibold` `.font-bold` |
294
+ | Text align | `.text-left` `.text-center` `.text-right` |
295
+ | Truncate | `.truncate` |
296
+ | Visibility | `.hidden` `.invisible` `.sr-only` `.no-print` |
297
+ | Display | `.flex` `.flex-col` |
298
+ | Flex align | `.items-center` `.justify-center` `.justify-between` `.justify-end` |
299
+ | Gap | `.gap-2` `.gap-4` |
300
+ | Width | `.w-full` |
301
+ | Margin | `.m-0` `.mx-auto` `.mt-4` `.mb-4` `.my-4` |
302
+ | Padding | `.p-0` `.p-4` `.p-6` |
303
+ | Overflow | `.overflow-auto` `.overflow-hidden` |
304
+ | Radius | `.rounded-none` `.rounded-sm` `.rounded` `.rounded-lg` `.rounded-xl` `.rounded-full` |
305
+ | Border | `.border` `.border-none` |
306
+ | Background | `.bg-card` `.bg-muted` `.bg-transparent` |
307
+ | Shadow | `.shadow-none` `.shadow-sm` `.shadow` `.shadow-md` `.shadow-lg` |
308
+ | Position | `.sticky` |
309
+ | Cursor | `.cursor-pointer` `.cursor-not-allowed` |
310
+ | Interaction | `.pointer-events-none` `.select-none` |
311
+ | Transition | `.transition` `.transition-none` |
312
+ | Animation | `.animate-spin` `.animate-pulse` |
313
+
314
+ If you find yourself reaching for utilities that aren't here, that's a signal to either lean on a semantic element you might be overlooking — or, if it's a real gap, open an issue.
315
+
316
+ ## Theming
317
+
318
+ ### Dark Mode
319
+
320
+ Follows system preference automatically. Override with `data-theme`:
321
+
322
+ ```html
323
+ <html data-theme="dark">
324
+
325
+ <!-- Or theme islands -->
326
+ <article data-theme="dark">Always dark</article>
327
+ ```
328
+
329
+ ### CSS Variables
330
+
331
+ Daft CSS uses a hierarchical variable system designed to give you both simplicity and granularity.
332
+
333
+ **1. Root variables** — A small set of core values that control the entire design system. Change one, and everything adapts:
334
+
335
+ ```css
336
+ :root {
337
+ --spacing: 1rem; /* Controls all spacing throughout the app */
338
+ --radius: 0.5rem; /* Controls all border radii */
339
+ --primary: oklch(0.5 0.22 295); /* Primary brand color (default is neutral) */
340
+ }
341
+ ```
342
+
343
+ The system automatically handles derived concerns — for example, button text color adjusts based on whether the primary color is light or dark.
344
+
345
+ **2. Scale variables** — Root values cascade into scales. Decrease `--spacing` and all spacing shrinks proportionally:
346
+
347
+ ```css
348
+ --spacing-sm /* 0.5rem — derived from --spacing */
349
+ --spacing /* 1rem — the base */
350
+ --spacing-lg /* 1.5rem — derived from --spacing */
351
+ ```
352
+
353
+ **3. Component variables** — For fine-grained control, override individual components without affecting others:
354
+
355
+ ```css
356
+ :root {
357
+ --button-radius: var(--radius-full); /* Pill-shaped buttons */
358
+ --card-radius: var(--radius-lg); /* Slightly rounded cards */
359
+ --card-shadow: none; /* Flat cards (no elevation) */
360
+ }
361
+ ```
362
+
363
+ This tree structure gives you the best of both worlds: change a few root variables for a quick redesign, or drill down into component-specific tokens when you need precise control.
364
+
365
+ ## Browser Support
366
+
367
+ Requires modern browsers for native support of `light-dark()`, OKLCH colors, CSS nesting, `color-mix()`, the Popover API, and `@starting-style`:
368
+
369
+ - Chrome 123+
370
+ - Firefox 129+
371
+ - Safari 18+
372
+
373
+ ## Development
374
+
375
+ ```bash
376
+ npm run build # Build daft.css and daft.min.css
377
+ npm run watch # Watch and rebuild on changes
378
+ npm run dev # Serve examples locally
379
+ ```
380
+
381
+ ## License
382
+
383
+ MIT