<!-- GENERATED by scripts/lib/skill-files.ts on every build (from src/SKILL_tpl.md +
     each component's component-skill.md frontmatter) - do not edit by hand;
     edit the template or a skill's frontmatter and rebuild. -->

# defuss-shadcn - Agent Skill

**A UI component system that scales with _(local)_ AI.** Themeable components built on semantic HTML, modern CSS, and vanilla JavaScript. No framework, zero dependencies - `dist/` is committed and ready to use as-is. This file is the entry point for an AI agent integrating the library: read it once, then read only the component skills you need.

## Integrate

**Via CDN** (everything at once, or pick only the components you use):

```html
<!-- 1. base: design tokens + sizing/layout/accessibility utilities (a theme preset from theme/ may follow) -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/kyr0/defuss-shadcn@latest/dist/components/core.css">

<!-- 2. icons -->
<script src="https://unpkg.com/lucide@1.8.0"></script>
<script>lucide.createIcons();</script>

<!-- 3a. the bundle: every component's CSS + JS (all.js embeds the core runtime) -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/kyr0/defuss-shadcn@latest/dist/components/all.css">
<script type="module" src="https://cdn.jsdelivr.net/gh/kyr0/defuss-shadcn@latest/dist/components/all.js"></script>

<!-- 3b. …or one CSS link per component, then core.js + one script per interactive component -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/kyr0/defuss-shadcn@latest/dist/components/button/button.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/kyr0/defuss-shadcn@latest/dist/components/dialog/dialog.css">
<script type="module" src="https://cdn.jsdelivr.net/gh/kyr0/defuss-shadcn@latest/dist/components/core.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/gh/kyr0/defuss-shadcn@latest/dist/components/dialog/dialog.js"></script>

<!-- 4. only on a page that uses them: the extra bundles, after 3a / 3b -
     wysiwyg (code-example, editorjs), mermaid (mermaid), math (math-renderer, math-editor, math-compute),
     visual-editor (visual-editor) -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/kyr0/defuss-shadcn@latest/dist/components/wysiwyg.css">
<script type="module" src="https://cdn.jsdelivr.net/gh/kyr0/defuss-shadcn@latest/dist/components/wysiwyg.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/kyr0/defuss-shadcn@latest/dist/components/mermaid.css">
<script type="module" src="https://cdn.jsdelivr.net/gh/kyr0/defuss-shadcn@latest/dist/components/mermaid.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/kyr0/defuss-shadcn@latest/dist/components/math.css">
<script type="module" src="https://cdn.jsdelivr.net/gh/kyr0/defuss-shadcn@latest/dist/components/math.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/kyr0/defuss-shadcn@latest/dist/components/visual-editor.css">
<script type="module" src="https://cdn.jsdelivr.net/gh/kyr0/defuss-shadcn@latest/dist/components/visual-editor.js"></script>
```

**Self-hosting:** copy `dist/` into your project and use the same paths without the CDN prefix. No build step.

**With a package manager:** `npm install defuss-shadcn`, then import `defuss-shadcn/dist/components/core.css`, `…/all.css` and `…/all.js` (in that order) from the app entry. The package's root `SKILL.md` covers both install paths, the rules and an index of every documentation page.

Then: for every component you use, read its skill file (linked per-component below) and emit exactly the documented markup - classes, `data-*` attributes, and ARIA included. The CSS and JS wire themselves up from those attributes.

## Principles (follow these when generating markup)

- **Native web platform first** - every component builds on a native element or browser API: `<dialog>` for modals, `popover` for menus/tooltips, `<details>` for accordions, CSS anchor positioning instead of Popper, `:has()`/`:user-invalid`/`field-sizing` instead of JS. If you find yourself adding JS behavior, check the skill - the platform probably already provides it.
- **Tokens are the source of truth** - all colors, radius, shadows, and fonts are CSS custom properties in `theme/utils/default-semantic-tokens.css` (tweakcn-compatible shape). To re-theme, replace that file; never hardcode colors in markup or custom CSS.
- **Variants via data attributes, never classes** - `data-variant`, `data-size`, `data-side` on one base class per component (`.btn[data-variant="outline"]`, never `.btn-outline`).
- **State API on interactive components** - each interactive element exposes `el.api.setState('open')` / `el.api.getState()`; state names are listed per component below. Drive and observe UI state through this API, not by toggling classes.
- **Every state is a store** - `el.store` (defuss-store) holds the element's `{ name, config }`: `el.store.subscribe(fn)` follows every change (also the user's), `el.store.set({ name, config })` applies one. Keep app state in `df$.store.create(v)` and anything that must survive a reload in `df$.store.persisted(key, initial)` - never raw `localStorage`. Big data: `df$.dataview` (filter / multisort / tree queries) behind Virtual List, Data Tree and Data Grid.
- **Accessibility is built in** - WAI-ARIA patterns, keyboard navigation, focus management, and `prefers-reduced-motion` support ship in the files. Don't duplicate or fight them.

## Where things live (`dist/`)

```
dist/
├── SKILL.md                          ← you are here - start every task with this file
├── stats.json                        ← component counts (per type, JS/CSS-only) + byte sizes raw/minified/gzipped
├── theme/utils/default-semantic-tokens.css ← design tokens (the only theme file)
├── components/all.css                ← bundle: every component stylesheet (+ .min twin & map)
├── components/all.js                 ← bundle: every component's behavior (+ .min twin & maps)
├── components/wysiwyg.css / .js      ← extra bundle: code-example, editorjs - NOT in all.*; load after all.* / core where used
├── components/mermaid.css / .js      ← extra bundle: mermaid - NOT in all.*; load after all.* / core where used
├── components/math.css / .js         ← extra bundle: math-renderer, math-editor, math-compute - NOT in all.*; load after all.* / core where used
├── components/visual-editor.css / .js ← extra bundle: visual-editor - NOT in all.*; load after all.* / core where used
├── components/{name}/
│   ├── component-skill.md            ← HOW to build the HTML - read this before using a component
│   ├── {name}.css                    ← the stylesheet (tokens only; always include)
│   └── {name}.js                     ← behavior as ES module (interactive components only; load as type="module")
└── documentation/                    ← full reference site, openable as static files
    ├── {name}.html                   ← live demos of every variant/size/state per component
    └── css|js                        ← doc-site assets (not part of the system)
```

In the **source repository** additionally: `screenshots/{light,dark}/{name}.png` and `screenshots/{light,dark}/{name}-{state}.png` - one PNG per declared state per color mode (taken by hand with `bun run screenshots` - no build makes them, so they may be missing or older than the source), so a state name listed below maps directly to a visual reference (e.g. `screenshots/dark/dialog-open.png` shows the open modal).

## How to work with this library

1. Pick components from the list below (why/when tells you fit; type says how it composes - ATM atom / MOL molecule / ORG organism / BLK template section / TPL whole page (decks included); supportedStates + screenshots give visual expectations).
2. Read the component's `component-skill.md` and copy its structure section - don't invent markup.
3. Include the component's CSS (always) and JS (`type="module"`, interactive ones only) plus the token file.
4. Need a visual state? `el.api.setState('<state>')`; verify against the matching screenshot.
5. Stuck on composition or a variant? Open `documentation/{name}.html` - every configuration is demonstrated there.

# Components

<!-- COMPONENTS -->
