@joralvmel/cosmos-mcp 0.1.0 → 0.1.2

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.
@@ -1 +1 @@
1
- [{"slug":"ai/mcp","title":"MCP server","markdown":"# MCP server\n\n> Connect AI assistants to the Cosmos UI MCP server to query components, themes, tokens and setup.\n\n`@joralvmel/cosmos-mcp` is a [Model Context Protocol](https://modelcontextprotocol.io/) server\n(stdio). It ships the contracts, snippets, status, themes and docs of its version, so the answers match\nwhat you install.\n\n## Connect\n\n**VS Code**\n`npx @joralvmel/cosmos-cli init-ai` does it for you, or add to `.vscode/mcp.json`:\n\n```json\n{\n \"servers\": {\n \"cosmos-ui\": { \"type\": \"stdio\", \"command\": \"npx\", \"args\": [\"-y\", \"@joralvmel/cosmos-mcp\"] }\n }\n}\n```\n**Claude Code**\n```bash\nclaude mcp add cosmos-ui -- npx -y @joralvmel/cosmos-mcp\n```\n**Other clients**\nRun the command `npx -y @joralvmel/cosmos-mcp` as a stdio server in your client configuration.\n\n## Tools\n\n| Tool | Arguments | Returns |\n| --- | --- | --- |\n| `list_components` | `status?` (`planned`, `in-progress`, `stable`) | Every catalog component with category, platforms, dependencies and status. |\n| `get_component` | `name` | Contract (props, events per platform, slots, parts, keyboard), API table, snippets for HTML, React, Angular and React Native, imports and status. |\n| `list_themes` | — | Built-in themes and their modes. |\n| `get_tokens` | `theme?`, `mode?` | Semantic color tokens and radii of a theme and mode. |\n| `get_setup` | `framework` (`react`, `next`, `angular`, `html`, `react-native`, `tailwind`) | Install commands, setup code and rules. |\n| `search_docs` | `query`, `limit?` | Matching docs pages and package references with an excerpt. |\n\nResources: `cosmos://llms/<package>` returns the `llms.md` of each package.\n\n## Example questions\n\n- \"Which Cosmos components are stable, and which ones can I use for a form?\"\n- \"Show me the Angular code for a danger outline button that is loading.\"\n- \"What are the dark-mode tokens of the nebula theme?\"\n"},{"slug":"ai/overview","title":"Use Cosmos UI with AI","markdown":"# Use Cosmos UI with AI\n\n> Give AI assistants the real Cosmos API with init-ai, llms.txt, Markdown pages and the MCP server.\n\nAI assistants write better UI code when they know the real components, props, events and tokens. Cosmos\ngives them that knowledge in three ways, all generated from the component contracts.\n\n## 1. Prepare your project with `init-ai`\n\n1. Run it in your project folder with your stack (`react`, `next`, `angular`, `html` or `react-native`):\n\n ```bash\n npx @joralvmel/cosmos-cli init-ai --stack react\n ```\n\n2. It writes a marked block with the Cosmos rules into `.github/copilot-instructions.md` and\n `AGENTS.md` (add `--claude` for `CLAUDE.md`), registers the MCP server in `.vscode/mcp.json` and\n prints the installation steps. Run it again at any time: only the marked block is replaced.\n\n3. Ask your assistant to install Cosmos UI (see the [ready-made prompts](../prompts/)).\n\n## 2. Reference files\n\n| Resource | Use |\n| --- | --- |\n| [`/llms.txt`](../../llms.txt) | Index of every package reference and page, for assistants that read `llms.txt`. |\n| [`/llms-full.txt`](../../llms-full.txt) | The whole documentation and every package reference in one file. |\n| `/<page>.md` | Every page as Markdown (button **Copy page for AI** below each title). |\n| `node_modules/@joralvmel/cosmos-*/llms.md` | Reference of each installed package: setup, components with props, events and examples, themes and rules. |\n\n## 3. MCP server\n\nThe [MCP server](../mcp/) answers questions about components, themes, tokens and setup with data that\nmatches the installed version.\n\n## Install with AI (copy and paste)\n\n```text\nInstall Cosmos UI in this project. First run `npx @joralvmel/cosmos-cli init-ai --stack <my stack>`,\nthen follow the steps it prints. Use the cosmos-ui MCP server (get_setup, list_components,\nget_component) or https://joralvmel.github.io/cosmos-ui/llms.txt to check every component and prop\nbefore using it. Style only with Cosmos tokens or the Cosmos Tailwind theme.\n```\n"},{"slug":"ai/prompts","title":"Ready-made prompts","markdown":"# Ready-made prompts\n\n> Copyable prompts to build UI with Cosmos in React, Next.js, Angular, HTML and React Native.\n\nCopy a prompt, replace the part in angle brackets and paste it in your assistant. They assume you ran\n[`init-ai`](../overview/) or that the assistant can read `llms.txt` or the MCP server.\n\n**React**\n```text\nUsing Cosmos UI (@joralvmel/cosmos-react) in this React + Vite app, build <a settings page with a\nform and a save button>. Check each component with the cosmos-ui MCP server (get_component) before\nusing it, handle events through event.detail, style the layout with Cosmos tokens or the Cosmos\nTailwind theme, support light and dark mode and keep keyboard access.\n```\n**Next.js**\n```text\nUsing Cosmos UI (@joralvmel/cosmos-react) in this Next.js App Router project, build <a dashboard\nheader with actions>. Put Cosmos components in Client Components ('use client'), keep pages as\nServer Components, load @joralvmel/cosmos-tokens/tokens.css in app/layout.tsx and use\nthemeInitScript() to avoid a theme flash. Check props with the cosmos-ui MCP server.\n```\n**Angular**\n```text\nUsing Cosmos UI (@joralvmel/cosmos-angular) in this standalone Angular app, build <a profile form>.\nImport the Cosmos standalone components you need, bind inputs with signals, listen to outputs with\n$event.detail and keep forms accessible. Check each component with the cosmos-ui MCP server.\n```\n**HTML**\n```text\nBuild <a landing page section> in plain HTML with Cosmos UI Web Components from a CDN\n(@joralvmel/cosmos-elements and @joralvmel/cosmos-tokens). Use <cosm-*> elements, listen to cosm-*\nevents, set data-theme and data-mode on <html> and use only var(--cosm-*) tokens in custom CSS.\n```\n**React Native**\n```text\nUsing Cosmos UI (@joralvmel/cosmos-native) in this Expo app, build <a login screen>. Wrap the app in\nCosmosThemeProvider with mode=\"system\", use useTheme() for custom styles, keep touch targets of at\nleast 44 points and accessibility labels. Check each component with the cosmos-ui MCP server.\n```\n\n## Prompts for the component library itself\n\nTo add or change components in the Cosmos repository, use the agents and prompts of the repository\n(`/create-component`, `/component-status`…): see [Working with agents](../../contribute/working-with-agents/).\n"},{"slug":"components/button","title":"Button","markdown":"# Button\n\n> Triggers an action or submits a form. Web Component, React, Angular and React Native.\n\nStatus: **stable** (web, react, angular, native).\n\n`<cosm-button>` triggers an action. It follows the\n[WAI-ARIA button pattern](https://www.w3.org/WAI/ARIA/apg/patterns/button/), renders a native\n`<button>` and takes part in forms (`type=\"submit\"` / `type=\"reset\"`). Use it for actions; use a link\nfor navigation.\n\n## Playground\n\n**HTML / Web Component**\n\n```html\n<cosm-button>Save changes</cosm-button>\n\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/button';\n\n const element = document.querySelector('cosm-button');\n element.addEventListener('cosm-press', event => console.log(event.detail));\n</script>\n```\n\n**React**\n\n```tsx\nimport { Button } from '@joralvmel/cosmos-react';\n\nexport function Example() {\n return (\n <Button onPress={event => console.log(event.detail)}>Save changes</Button>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmButtonComponent } from '@joralvmel/cosmos-angular';\nimport type { ButtonPressDetail } from '@joralvmel/cosmos-core';\n\n@Component({\n selector: 'app-example',\n imports: [CosmButtonComponent],\n template: `<cosm-button (press)=\"onPress($event.detail)\">Save changes</cosm-button>`,\n})\nexport class ExampleComponent {\n onPress(detail: ButtonPressDetail) {\n console.log(detail);\n }\n}\n```\n\n**React Native**\n\n```tsx\nimport { Button } from '@joralvmel/cosmos-native';\n\nexport function Example() {\n return (\n <Button onPress={detail => console.log(detail)}>Save changes</Button>\n );\n}\n```\n\n## Variants\n\n`variant` sets the emphasis and `tone` the color role. Use one `solid` button per view for the main\naction.\n\n```html\n<cosm-button>Solid</cosm-button>\n<cosm-button variant=\"soft\">Soft</cosm-button>\n<cosm-button variant=\"outline\">Outline</cosm-button>\n<cosm-button variant=\"ghost\">Ghost</cosm-button>\n<cosm-button tone=\"neutral\">Neutral</cosm-button>\n<cosm-button tone=\"danger\">Delete</cosm-button>\n```\n\n```html\n<cosm-button size=\"sm\">Small</cosm-button>\n<cosm-button>Medium</cosm-button>\n<cosm-button size=\"lg\">Large</cosm-button>\n```\n\n## States\n\n```html\n<cosm-button loading>Saving</cosm-button>\n<cosm-button disabled>Disabled</cosm-button>\n```\n\n- `loading` keeps the button focusable, sets `aria-busy` and ignores presses.\n- `disabled` removes it from the tab order and ignores presses.\n- Hover, active and `:focus-visible` states use the theme tokens of the selected tone.\n\n## Accessibility\n\n- Native `<button>` semantics: <kbd>Enter</kbd> and <kbd>Space</kbd> activate it.\n- Give icon-only buttons a `label`; it becomes the accessible name.\n- Use `tone=\"danger\"` together with explicit text for destructive actions; color is never the only cue.\n- On React Native, small buttons extend their touch area to 44 points.\n\n## API\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `variant` | 'solid' \\| 'soft' \\| 'outline' \\| 'ghost' | `solid` | Visual emphasis, from highest (solid) to lowest (ghost). |\n| `tone` | 'primary' \\| 'neutral' \\| 'danger' | `primary` | Color role. Use danger for destructive actions. |\n| `size` | 'sm' \\| 'md' \\| 'lg' | `md` | Control height and padding. |\n| `disabled` | boolean | `false` | Prevents interaction and removes the button from the tab order. |\n| `loading` | boolean | `false` | Shows a spinner, sets aria-busy and ignores presses while keeping focus. |\n| `fullWidth` | boolean | `false` | Stretches the button to the width of its container. |\n| `type` | 'button' \\| 'submit' \\| 'reset' | `button` | Form behavior of the button. |\n| `label` | string | — | Accessible name when the visible content is not descriptive (icon-only buttons). |\n\n**Slots**\n\n| Name | Description |\n| --- | --- |\n| `(default)` | Button label. |\n| `start` | Content before the label, usually an icon. |\n| `end` | Content after the label, usually an icon. |\n\n**CSS parts**\n\n| Name | Description |\n| --- | --- |\n| `base` | The native button element. |\n| `label` | Wrapper of the label slot. |\n| `spinner` | Loading indicator. |\n\n**CSS custom properties**\n\n| Name | Description |\n| --- | --- |\n| `--cosm-button-radius` | Corner radius. |\n| `--cosm-button-gap` | Space between icon and label. |\n| `--cosm-button-font-weight` | Label font weight. |\n\n**Keyboard**\n\n| Keys | Action |\n| --- | --- |\n| `Enter`, `Space` | Activates the button. |\n\n## Events by platform\n\n| DOM | React | Angular | React Native | Detail | Description |\n| --- | --- | --- | --- | --- | --- |\n| `cosm-press` | `onPress` | `(press)` | `onPress` | `ButtonPressDetail` | The button was activated by pointer, keyboard or programmatically. |\n"},{"slug":"components/status","title":"Component status","markdown":"# Component status\n\n> Inventory of every planned Cosmos component, with what exists on each platform.\n\nThis page is generated from the repository on every build: the canonical list lives in\n`packages/core/src/catalog.ts` and `npm run status` detects which pieces exist for each component\n(contract, scenarios, each platform, tests, docs, AI reference and changeset).\n\n- **Stable**: every piece exists for every platform of the component.\n- **In progress**: some pieces exist.\n- **Planned**: nothing exists yet. A planned component can start when its dependencies are stable.\n\n1 stable · 0 in progress · 37 planned (38 total)\n\nNext: `icon`, `badge`, `avatar`, `divider`, `listbox`\n\n| Component | Status | Priority | Contract | Scenarios | Web Component | React | Angular | React Native | Native demo | Tests | Docs (EN) | Docs (ES) | llms.md | Changeset | Depends on |\n| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |\n| button | stable | 1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | — |\n| icon | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| icon-button | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | button, icon |\n| badge | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| spinner | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| avatar | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| divider | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| listbox | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| calendar | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | button |\n| text-field | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon |\n| textarea | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| checkbox | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon |\n| radio-group | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| switch | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| number-field | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | text-field, icon-button |\n| select | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | popover, listbox, icon |\n| combobox | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | popover, listbox, text-field |\n| multi-select | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | popover, listbox, badge, checkbox |\n| slider | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| popover | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| tooltip | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | popover |\n| dialog | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | button, icon-button |\n| drawer | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | dialog |\n| toast | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon, icon-button |\n| menu | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | popover |\n| split-button | planned | 3 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | button, menu |\n| tabs | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| accordion | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon |\n| pagination | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | button, icon-button |\n| steps | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon |\n| breadcrumb | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon |\n| card | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| table | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | checkbox, pagination, icon-button |\n| date-picker | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | popover, calendar, text-field |\n| date-range-picker | planned | 3 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | date-picker |\n| bottom-sheet | planned | 3 | ✗ | ✗ | — | — | — | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| skeleton | planned | 3 | ✗ | ✗ | — | — | — | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| list-item | planned | 3 | ✗ | ✗ | — | — | — | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon |\n\nRun it locally:\n\n```bash\nnpm run status # table\nnpm run status -- --markdown\nnpm run status -- --json\n```\n"},{"slug":"contribute/example-switch","title":"Example: from issue to release","markdown":"# Example: from issue to release\n\n> A complete walkthrough that creates the cosm-switch component with the agents and skills, from the issue to the npm release.\n\nThis walkthrough adds `cosm-switch` (WAI-ARIA switch) on every platform. Each step names the skill to\nrun (as a `/prompt` in VS Code or by asking the agent) and shows the commands it runs and the expected\noutput.\n\n## 1. Check the inventory — `component-status`\n\n```bash\nnpm run status\n```\n\n```text\nComponents: 38 · stable 1 · in progress 0 · planned 37\n…\nplanned 1 switch\n…\nNext suggested: icon, badge, avatar, divider, listbox\n```\n\n`switch` is planned, priority 1 and has no dependencies, so it can start now.\n\n## 2. Issue and branch — `start-work`\n\n```bash\ngh issue create --template component_request.yml --title \"Component: switch\"\n# → https://github.com/joralvmel/cosmos-ui/issues/12\ngh issue develop 12 --base develop --name feat/elements-switch --checkout\n```\n\n```text\ngithub.com/joralvmel/cosmos-ui/tree/feat/elements-switch\nSwitched to a new branch 'feat/elements-switch'\n```\n\n## 3. Research — `research-reference`\n\nThe `researcher` agent summarizes the\n[APG switch pattern](https://www.w3.org/WAI/ARIA/apg/patterns/switch/): role `switch`,\n`aria-checked`, <kbd>Space</kbd> toggles, visible label, and recommends a native\n`<input type=\"checkbox\" role=\"switch\">` inside the Web Component (form participation for free).\n\n## 4. Contract — `define-contract`\n\nThe `architect` agent writes `packages/core/src/specs/switch.ts` (props `checked`, `disabled`,\n`required`, `name`, `value`, `label`; event `change` → DOM `cosm-change`, React `onChange`, Angular\n`(checkedChange)`, React Native `onCheckedChange`; state `checked` with `defaultChecked`) and the shared\nscenarios (toggle by pointer and keyboard, disabled, controlled proposal without commit).\n\n## 5. Visual spec — `design-component`\n\nThe `design-system` agent writes `docs/design/switch.md`: track and thumb sizes per `size`, states\n(hover, focus-visible, checked, disabled, invalid), tokens (`--cosm-primary`, `--cosm-border-strong`,\n`--cosm-surface`), motion with `prefers-reduced-motion`, and checks contrast in every theme.\n\n## 6. Generate — `create-component`\n\n```bash\nnpm run generate -- component switch\n```\n\n```text\nWrote 21 files:\n packages/core/src/specs/switch.ts\n packages/core/src/specs/switch.scenarios.ts\n packages/core/src/index.ts\n packages/elements/src/components/switch/cosm-switch.ts\n …\n apps/docs/src/content/docs/es/components/switch.mdx\n .changeset/add-switch.md\n\nNext: resolve every TODO(generator) marker, then run\n npx biome ci . && npx turbo run typecheck test build\n```\n\n`component-builder` replaces the generated placeholders with the real contract, the Lit\nimplementation (anatomy order: imports, types, styles, class, registration), the React events map and\nthe Angular inputs and `(checkedChange)` output with a `ControlValueAccessor`.\n\n## 7. React Native — `create-native-component`\n\n`native-expert` implements `Switch` with `Pressable`, `accessibilityRole=\"switch\"`,\n`accessibilityState={{ checked, disabled }}`, a 44-point touch area and `useTheme()` colors, and\nfinishes the demo screen `apps/native-demo/app/switch.tsx`.\n\n## 8. Tests — `add-contract-tests`\n\n```bash\nnpx turbo run test --filter=...@joralvmel/cosmos-core\ncd tools && npx vitest run test/structure.test.mjs test/status.test.mjs\n```\n\n```text\n Tasks: N successful, N total\n ✓ test/structure.test.mjs\n ✓ test/status.test.mjs\n```\n\n## 9. Docs and AI references — `add-docs-page`, `add-playground`, `update-ai-references`\n\nThe pages follow the anatomy order (status, Playground, variants, states, accessibility, API, events by\nplatform) in English and Spanish. The Playground already shows HTML, React, Angular and React Native\ncode from the contract.\n\n```bash\nnpm run llms\nnpm run status\n```\n\n```text\nstable 1 switch\n```\n\nWhen every piece exists, `component-builder` sets `status: 'stable'` in the catalog entry.\n\n## 10. Changeset — `add-changeset`\n\n```md\n---\n'@joralvmel/cosmos-core': minor\n'@joralvmel/cosmos-elements': minor\n'@joralvmel/cosmos-react': minor\n'@joralvmel/cosmos-angular': minor\n'@joralvmel/cosmos-native': minor\n---\n\nAdd the Switch component (`cosm-switch`) on every platform.\n```\n\n## 11. Pull request — `finish-work`\n\n```bash\nnpx biome ci . && npx turbo run typecheck test build && npm run check-terms\ngit push -u origin HEAD\ngh pr create --base develop --title \"feat(elements): add cosm-switch\" --body-file pr.md --label type:component\n```\n\n```text\nhttps://github.com/joralvmel/cosmos-ui/pull/13\n```\n\nCI runs lint, terms, typecheck, tests and build, the docs build (preview artifact), the changeset check\nand commit hygiene; the labeler adds `pkg:core`, `pkg:elements`, `pkg:react`, `pkg:angular`,\n`pkg:native`, `app:docs` and `app:native-demo`.\n\n## 12. Review and merge\n\nAsk the `reviewer` agent for a review, address the comments and wait for the code owner approval. Merge\nwith **Squash and merge** (the PR title becomes the commit message); the branch is deleted\nautomatically.\n\n## 13. Back to develop — `sync-after-merge`\n\n```bash\ngit switch develop && git pull --prune --ff-only && git branch -D feat/elements-switch\n```\n\n## 14. Release pull request — `release-pr`\n\n```bash\nnpx changeset status --since=origin/main\ngh pr create --base main --head develop --title \"chore(release): switch\" --label release\n```\n\nMerge it with **Create a merge commit**.\n\n## 15. Publish — `release`\n\nThe `Release` workflow opens **Version Packages** on main (versions `0.2.0`, changelogs). Merging it\npublishes to npm with provenance and creates the GitHub Releases:\n\n```bash\nnpm view @joralvmel/cosmos-elements version\n```\n\n```text\n0.2.0\n```\n"},{"slug":"contribute/getting-started","title":"Getting started","markdown":"# Getting started\n\n> Set up the Cosmos UI repository, run the docs and the native demo, and solve common problems.\n\n## Requirements\n\n- **Node.js 24** (see `.nvmrc`; `nvm use` or `fnm use`) and **npm 11**.\n- Git, and the [GitHub CLI](https://cli.github.com/) (`gh`) for the branch and pull request skills.\n- VS Code with GitHub Copilot to use the [agents](../working-with-agents/) (optional).\n- For the native demo: the Expo Go app on a phone, Android Studio (emulator) or Xcode (iOS simulator,\n macOS only).\n\n## First run\n\n1. Clone and install. `npm ci` also points Git to the hooks in `.githooks`:\n\n ```bash\n git clone https://github.com/joralvmel/cosmos-ui.git\n cd cosmos-ui\n npm ci\n ```\n\n2. Build, test and check everything (the same commands as CI):\n\n ```bash\n npx biome ci . && npx turbo run typecheck test build\n ```\n\n Turborepo caches results: a second run takes seconds.\n\n3. Open the docs site at http://localhost:4321:\n\n ```bash\n npm run docs\n ```\n\n4. See what exists and what is next:\n\n ```bash\n npm run status\n ```\n\n## Native demo\n\nThe Expo Router app in `apps/native-demo` has one screen per React Native component and a theme and\nmode switcher.\n\n```bash\nnpm run build # the demo uses the built packages\nnpm run dev --workspace=@joralvmel/cosmos-native-demo\n```\n\n- **Expo Go** (any OS): scan the QR code with the Expo Go app (Android) or the camera (iOS). The phone\n and the computer must be on the same network.\n- **Android emulator**: install Android Studio, create a virtual device, start it, then press `a` in\n the Expo terminal.\n- **iOS simulator** (macOS): install Xcode and its command line tools, then press `i`.\n\n## Repository structure\n\n| Folder | Contents |\n| --- | --- |\n| `packages/*` | Publishable packages (`tokens`, `tailwind`, `core`, `elements`, `react`, `angular`, `native`, charts, `icons`, `i18n`, `mcp`, `cli`) |\n| `apps/docs` | This site (Astro + Starlight, English and Spanish) |\n| `apps/native-demo` | Expo demo app |\n| `tools/` | Generator, component status, AI references, Git and GitHub checks, release helpers |\n| `docs/adr`, `docs/conventions` | Architecture decisions and the component anatomy |\n| `.github/` | Workflows, agents, skills, prompts and path-specific instructions |\n\n## Browser tests\n\nUnit and behavior tests run in Vitest with happy-dom, so no browser is needed. Browser checks\n(Playwright with axe) are planned for keyboard behavior and accessibility; when they land they will\nneed `npx playwright install` once.\n\n## Troubleshooting\n\n| Problem | Fix |\n| --- | --- |\n| `EBADENGINE` / unsupported engine | Use Node.js 24 (`nvm use`). |\n| `EBUSY: resource busy or locked` on Windows during `npm ci` | An editor or language server holds a file in `node_modules`; close the project in other IDEs and run it again. |\n| `File content differs from formatting output` | `npm run lint:fix` (Biome formats with LF line endings). |\n| Hooks do not run | `npm ci` with `ignore-scripts` skips `prepare`: run `node tools/git/install-hooks.mjs`. |\n| `Commit blocked: the Git identity does not match` | Your `.local/git-identity.json` expects another identity; fix `git config --local user.*` or the file. |\n| `llms.md files are outdated` | `npm run llms` (the AI references are generated from the contracts). |\n| Strange cached results | `npx turbo run build --force`. |\n"},{"slug":"contribute/git-workflow","title":"Git workflow","markdown":"# Git workflow\n\n> Branches, commits, pull requests, reviews and releases in Cosmos UI.\n\n## Branches\n\n| Branch | Purpose | How changes arrive |\n| --- | --- | --- |\n| `main` | Released code; every push runs the release and docs deployment | Merge commit from `develop` (release pull request) |\n| `develop` | Integration, default branch | Squash merge of work branches |\n| `<type>/<scope>-<description>` | One task | Created from `develop`, deleted after merge |\n\nTypes: `feat`, `fix`, `docs`, `chore`, `refactor`, `test`. Scope: package or area (`elements`, `tokens`,\n`docs`…). Example: `feat/elements-switch`. Contributors without write access fork the repository and\nopen the pull request from their fork.\n\n## Commits\n\n- [Conventional Commits](https://www.conventionalcommits.org/): `type(scope): summary`, several scopes\n separated by commas (`feat(mcp,cli): …`). The `commit-msg` hook checks it.\n- Use your own Git identity; prefer your GitHub noreply email. Sign off with `git commit -s`\n ([DCO](https://developercertificate.org/)) if you can.\n- Never use `--no-verify`.\n\n## Pull requests\n\n1. `start-work` → work → `finish-work` (validates, pushes and opens the pull request to `develop`).\n2. Required: green checks (lint, terms, typecheck, tests, build, packs, docs build, changeset, commit\n hygiene) and resolution of review conversations. Approvals are optional.\n3. Squash merge: the pull request title must be a Conventional Commit (checked by CI).\n4. `sync-after-merge` cleans up the local branch.\n\nApprovals are optional on `main` and `develop` so a sole maintainer can merge their own pull requests.\nThis policy applies to all contributors: classic branch protection on a personal repository does not\nsupport individual review exemptions. Pull requests, required checks and conversation resolution\nremain mandatory. Copilot reviews are advisory, not approving reviews.\n\n## Releases\n\n`release-pr` opens `develop → main` with the pending changesets; merge it with a merge commit. The\n[Release and publishing](../publishing/) page explains the rest.\n\n## Repository settings\n\nBranch protection, merge options and labels are code: `npm run setup-repo` shows the changes and\n`npm run setup-repo -- --apply` applies them with the GitHub CLI. Settings that only exist in the\nGitHub UI are printed at the end of the command.\n\n## Personal safeguards (optional)\n\nOn a computer with several GitHub accounts, create `.local/git-identity.json` (ignored by Git) with\nyour name, email and GitHub login: the `pre-commit` hook and the `verify-identity` skill then block\ncommits and pushes with another identity. On a computer with a single personal account nothing is\nneeded.\n"},{"slug":"contribute/publishing","title":"Release and publishing","markdown":"# Release and publishing\n\n> How Cosmos UI is versioned and published to npm, and the one-time setup for maintainers.\n\nCosmos UI uses [Changesets](https://github.com/changesets/changesets) for versions and changelogs and\npublishes to the public npm registry with\n[trusted publishing](https://docs.npmjs.com/trusted-publishers) (OIDC, no npm token) and\n[provenance](https://docs.npmjs.com/generating-provenance-statements).\n\n## How releases work\n\n1. Every pull request that changes `packages/*` adds a changeset (`npm run changeset`).\n2. When `develop` is ready, a maintainer opens the release pull request `develop → main`\n (skill `release-pr`) and merges it with a **merge commit**.\n3. On `main`, the `Release` workflow opens or updates the **Version Packages** pull request: it bumps\n versions and writes the changelogs.\n4. Merging **Version Packages** runs `changeset publish`: new versions go to npm with provenance, Git\n tags are pushed and a GitHub Release is created per package.\n5. The `Docs` workflow deploys the documentation site from `main`.\n\nPrereleases: run the `Release` workflow manually on `develop` (Actions → Release → Run workflow). It\npublishes a snapshot such as `0.2.0-next-20261110120000` with the dist-tag `next`:\n\n```bash\nnpm install @joralvmel/cosmos-react@next\n```\n\n## One-time setup (maintainers)\n\nThe skill `publish-setup` walks an agent through the same checklist.\n\n1. **npm account.** Create an account on [npmjs.com](https://www.npmjs.com/signup), verify the email\n and enable two-factor authentication (Account → Two-Factor Authentication, \"Authorization and\n writes\"). The scope `@joralvmel` is the account's user scope.\n\n2. **Check the packages.**\n\n ```bash\n npm ci\n npm run check-packs # builds, validates manifests and runs npm pack --dry-run\n npm run publish-order # dependencies first\n ```\n\n3. **First publication by hand.** Trusted publishing can only be configured for packages that exist.\n Publish the current version of every package once, in the order printed above:\n\n ```bash\n npm login\n cd packages/core && npm publish --access public --otp <code> && cd ../..\n # …repeat for each package in publish order\n ```\n\n The first version is a placeholder (`0.0.0`); you can mark it with\n `npm deprecate @joralvmel/cosmos-core@0.0.0 \"placeholder\"`.\n\n4. **Trusted publisher per package.** On npmjs.com open each package → Settings → Trusted Publisher →\n GitHub Actions and enter: owner `joralvmel`, repository `cosmos-ui`, workflow `release.yml`,\n environment `npm`. Then, under \"Publishing access\", choose\n \"Require two-factor authentication and disallow tokens\".\n\n5. **GitHub.** In the repository settings:\n - Environments → create `npm` (optionally with required reviewers).\n - Secrets and variables → Actions → Variables: `COSMOS_PUBLISH_ENABLED` = `true`.\n - For the docs site: Pages → Source \"GitHub Actions\" and the variable `COSMOS_DOCS_ENABLED` = `true`.\n\n6. **Verify** after the first automated release:\n\n ```bash\n npm view @joralvmel/cosmos-core versions dist-tags\n npm audit signatures # inside a project that installed the packages\n ```\n\n The package page on npmjs.com shows the provenance badge linking to the workflow run.\n\n## Troubleshooting\n\n| Symptom | Fix |\n| --- | --- |\n| `E404` / `ENEEDAUTH` on publish | The trusted publisher does not match: check owner, repository, workflow file name and environment. |\n| No \"Version Packages\" pull request | Allow GitHub Actions to create pull requests (`npm run setup-repo -- --apply` does it). |\n| Workflow skipped | `COSMOS_PUBLISH_ENABLED` is not `true`. |\n| `check-packs` fails | A manifest misses `publishConfig.access`, `files`, `exports`, `repository`, `license` or `llms.md`. |\n"},{"slug":"contribute/recipes","title":"Recipes","markdown":"# Recipes\n\n> Short guides to create a theme, add a token, build a component from Figma, change a component and create a chart.\n\nEach recipe names the skill that automates it (run it as a `/prompt` or ask its agent).\n\n## Create a theme — `add-theme`\n\n```bash\nnpm run generate -- theme aurora --seed \"oklch(0.58 0.14 165)\"\nnpx turbo run test build --filter=@joralvmel/cosmos-tokens...\n```\n\n1. Tune the definition in `packages/tokens/src/themes.ts`: seeds (OKLCH), `harmony`, neutral tint and\n `radius`. Add mode overrides only when unavoidable.\n2. The tokens tests check WCAG 2.2 AA and color vision deficiencies in light and dark. Never lower the\n thresholds; change the seeds instead.\n3. The theme appears in the theme gallery, the header picker, Tailwind (`theme-aurora:`) and\n `CosmosThemeProvider`.\n\n## Add a token — `add-token`\n\n1. Semantic color: add it to `semanticColors` (`packages/tokens/src/types.ts`), derive it in\n `generate.ts` and add contrast pairs in `validate.ts` when it carries text or UI.\n2. Base token (spacing, radius, motion…): add it to `base.ts`; map it in `toTailwindTheme` / `toNative`.\n3. Update the tokens and Tailwind tests, then `npm run llms`.\n\n## Component from Figma — `component-from-design`\n\n1. Share the Figma link of the frame (`?node-id=`) or a screenshot with the `design-system` agent.\n2. It extracts anatomy, variants and states and maps every value to existing tokens; a new token goes\n through `add-token`.\n3. `architect` writes the contract and `component-builder` runs `create-component`.\n\n## Change a component — `modify-component`\n\n1. `component-status` for the component and for any component it will use.\n2. Change the contract and scenarios first; decide the semver bump with `architect`.\n3. Update every platform, tests and docs; keep the anatomy (the structure test checks it).\n4. `npm run llms` and a changeset (`major` with a migration note when breaking).\n\n## Create a chart — `create-chart`\n\n```bash\nnpm run generate -- chart sparkline\n```\n\n1. Implement the pure layout in `packages/charts-core/src/sparkline-layout.ts` and test it without DOM.\n2. Render SVG in `packages/charts` and React Native in `packages/charts-native` with the same layout.\n3. Use theme chart colors (`--cosm-chart-1..8`), add a text description and a data table alternative.\n"},{"slug":"contribute/working-with-agents","title":"Working with agents","markdown":"# Working with agents\n\n> What each AI agent and skill of the repository does, how to use them in VS Code and what to ask.\n\nThe repository ships a team of specialized agents (`.github/agents/`) and step-by-step skills\n(`.github/skills/`, each with a prompt in `.github/prompts/`). They follow `AGENTS.md`, the rules in\n`.github/instructions/` and the [component anatomy](https://github.com/joralvmel/cosmos-ui/blob/develop/docs/conventions/component-anatomy.md).\n\n## How to use them in VS Code\n\n1. Open the repository in VS Code with GitHub Copilot and open the **Chat** view.\n2. **Agents**: pick one in the agent selector of the chat (for example `component-builder`), then\n describe the task. The agent loads its rules and uses its skills.\n3. **Prompts**: type `/` and the skill name, e.g. `/create-component`, `/component-status`,\n `/start-work`. The prompt asks for its inputs and runs the skill with the right agent.\n4. Attach context with `#` (a file, a folder or a Figma link) when it helps.\n\nOther assistants (Codex, Claude Code, Cursor…) read `AGENTS.md`; point them to a skill file, e.g.\n\"follow `.github/skills/create-component/SKILL.md` for `switch`\".\n\n## Agents\n\n| Agent | What it does | Skills |\n| --- | --- | --- |\n| `ai-tooling` | Maintains the AI tooling for consumers: MCP server, `cosmos init-ai`, consumer instructions and drift tests of llms.md against contracts. | `update-ai-references` |\n| `angular-expert` | Angular specialist: standalone proxy components, ControlValueAccessors for form controls, signals and zoneless apps, Angular examples. | `modify-component` |\n| `architect` | Owns architecture and patterns: package boundaries, component contracts in core, ADRs, new dependencies, performance, public API and breaking changes. Use before adding a component, a package, a dependency or changing a public API. | `write-adr`, `define-contract`, `component-status`, `research-reference` |\n| `chart-builder` | Builds charts: pure layout in charts-core, SVG rendering as Web Components, interaction and accessibility, and coordinates native rendering with native-expert. | `create-chart` |\n| `component-builder` | Builds or extends Cosmos web components end-to-end with the generator: contract, Lit Web Component, form association, React and Angular wrappers, React Native stub, tests and docs pages. Use for any \"create/add/extend a component\" task. | `component-status`, `create-component`, `modify-component` |\n| `design-system` | Design and layout specialist with deep color theory and visual accessibility knowledge: themes, palettes, light/dark modes, typography, spacing, motion, component anatomy and states, responsive layout, Tailwind theme and translation of Figma designs into tokens. | `design-component`, `component-from-design`, `add-theme`, `add-token` |\n| `devops` | GitHub Actions, Turborepo caching, docs and demo deployments (GitHub Pages), Expo EAS, workflow security, SBOM and license reports. | `setup-ci`, `deploy-docs`, `publish-setup` |\n| `docs-writer` | Writes the English and Spanish documentation site, playgrounds, theme gallery, icon catalog, READMEs and the llms.md / llms.txt AI references. | `add-docs-page`, `add-playground` |\n| `github-ops` | Handles branches, commits, pull requests, issues, labels and GitHub releases. Verifies the collaborator identity (verify-identity) before any commit or push. | `verify-identity`, `start-work`, `commit`, `finish-work`, `sync-after-merge`, `open-pr` |\n| `native-expert` | React Native and Expo specialist: native components on the shared contracts and themes, gestures, mobile accessibility, native charts with charts-core and the Expo Router demo app. | `component-status`, `create-native-component`, `modify-component` |\n| `react-expert` | React specialist: React 19 custom elements and @lit/react wrappers, SSR/Next.js compatibility, React examples and the portfolio demo app. | `modify-component` |\n| `release-manager` | Owns Changesets, semantic versioning, changelogs, deprecations and npm publishing. | `add-changeset`, `release-pr`, `release`, `publish-setup` |\n| `researcher` | Read-only researcher: studies specifications (WAI-ARIA APG, HTML, Open UI) and public libraries for a feature, compares behavior, accessibility, APIs and licenses, and recommends using a dependency or implementing it in Cosmos. | `research-reference` |\n| `reviewer` | Read-only reviewer: conventions, contract parity across platforms, accessibility, security, blocked terms, third-party licenses and changesets. Use before merging. | — |\n| `test-engineer` | Test strategy owner: shared contract scenarios, drift tests, Playwright and axe accessibility checks, coverage and flaky tests. | `add-contract-tests` |\n\n## Skills\n\n| Skill (prompt) | Main agent | What it does |\n| --- | --- | --- |\n| `/add-changeset` | `release-manager` | Writes a Changesets release note for every publishable package changed in the branch. |\n| `/add-contract-tests` | `test-engineer` | Adds shared behavior scenarios to a contract and runs them on the web, React, Angular and React Native through drivers. |\n| `/add-docs-page` | `docs-writer` | Adds a documentation page in English and Spanish with Playground, examples per framework, API table and accessibility notes. |\n| `/add-playground` | `docs-writer` | Adds the interactive Playground to a component page: controls generated from the contract, code tabs for HTML, React, Angular and React Native, copy button, theme/mode pickers and the native demo link. |\n| `/add-theme` | `design-system` | Adds a theme with defineTheme (seeds, harmony, light/dark), validates contrast and color vision deficiencies, and shows it in the docs gallery and in React Native. |\n| `/add-token` | `design-system` | Adds a token to every output (CSS variables, Tailwind theme, React Native values, JSON) with tests. |\n| `/audit-a11y` | `test-engineer` | Audits accessibility on web and React Native: axe, keyboard, focus, screen readers, contrast and motion. |\n| `/commit` | `github-ops` | Creates a Conventional Commit on a work branch after verifying identity, running validation and the blocked-terms check. |\n| `/component-from-design` | `design-system` | Turns a Figma URL (via Figma MCP), screenshot or image into a contract, a visual spec mapped to Cosmos tokens and a generated component. |\n| `/component-status` | `architect` | Reports the component inventory (npm run status), explains gaps and proposes or creates the next components according to their dependencies. Run it before creating, modifying or composing components. |\n| `/create-chart` | `chart-builder` | Creates a chart: pure layout in charts-core, SVG rendering on the web, React Native rendering, accessibility and docs. |\n| `/create-component` | `component-builder` | Creates a new Cosmos component end-to-end following docs/conventions/component-anatomy.md: contract and scenarios, Lit Web Component, React and Angular wrappers, React Native component and demo, tests, docs pages (EN/ES), llms.md and changeset. |\n| `/create-native-component` | `native-expert` | Creates a React Native component on a contract, core logic and tokens, with shared scenarios, drift test, demo screen and docs, following the component anatomy. |\n| `/define-contract` | `architect` | Creates or updates a component contract (props, events, states, slots, parts, keyboard, ARIA) and its shared scenarios in core, with the DOM/React/Angular/React Native mapping. |\n| `/deploy-docs` | `devops` | Deploys the docs site (and demos) to GitHub Pages once enabled. |\n| `/design-component` | `design-system` | Writes the visual spec of a component: anatomy, sizes, variants, states, tokens used, responsive behavior and light/dark notes, then styles it with tokens only. |\n| `/finish-work` | `github-ops` | Finishes a task: validates, pushes the branch and opens a pull request to develop with the template filled, labels and reviewers; optionally requests a Copilot review. |\n| `/modify-component` | `component-builder` | Changes the API or behavior of an existing component while keeping parity and the anatomy: contract → Lit → wrappers → React Native → scenarios → docs → llms.md → changeset. |\n| `/open-pr` | `github-ops` | Opens a pull request for an existing pushed branch (develop for work branches, main only for release PRs). Prefer finish-work, which validates first. |\n| `/publish-setup` | `release-manager` | One-time checklist to start publishing to npm: npm account with 2FA, first manual publication in dependency order, trusted publishers, GitHub environment and variables, verification. |\n| `/release` | `release-manager` | Runs the release flow: release PR develop → main, the Changesets \"Version Packages\" PR, npm publish with provenance and GitHub Releases; also snapshot prereleases with the next dist-tag. |\n| `/release-pr` | `release-manager` | Opens the release pull request develop → main with the summary of pending changesets. |\n| `/research-reference` | `researcher` | Researches specifications and public libraries for a feature, compares behavior, accessibility, APIs and licenses, and recommends a dependency or an own implementation. |\n| `/setup-ci` | `devops` | Creates or updates GitHub Actions workflows (CI, identity, release, docs) following the workflow rules. |\n| `/start-work` | `github-ops` | Starts a task: syncs develop, creates a work branch with a normalized name and optionally links it to an issue. |\n| `/sync-after-merge` | `github-ops` | After a pull request is merged: returns to develop, pulls with prune and deletes the local work branch. |\n| `/sync-icons` | `component-builder` | Updates the Lucide version, regenerates the icon definitions and catalog, and refreshes the license notice. |\n| `/update-ai-references` | `ai-tooling` | Keeps every AI reference in sync with the code: llms.md blocks (npm run llms), docs .md pages, /llms.txt, /llms-full.txt, the MCP server data and tools, and cosmos init-ai. |\n| `/verify-identity` | `github-ops` | Checks the Git and GitHub identity before a commit or push. Enforces .local/git-identity.json when it exists; otherwise reports the current identity and asks for confirmation. |\n| `/write-adr` | `architect` | Writes an architecture decision record NNNN-title.md (context → decision → consequences). |\n\n## What to ask\n\n- **One task at a time**, with the outcome you expect: \"Create the `switch` component for all\n platforms\" rather than \"work on forms\".\n- **Give references**: an issue number, a Figma link, a pattern of the WAI-ARIA APG.\n- **Let them validate**: every skill ends with tests and `npx biome ci . && npx turbo run typecheck test\n build`; ask for the output when in doubt.\n- **Review before merging**: ask `reviewer` for a review of the branch.\n\n## Copyable prompts\n\n```text\n/component-status all — and tell me which three components I should build next and why.\n```\n\n```text\n/start-work feat elements switch, linked to issue #12\n```\n\n```text\nUse the component-builder agent: create the \"switch\" component (WAI-ARIA switch pattern) for web,\nReact, Angular and React Native, with controlled and uncontrolled `checked` state and a `cosm-change`\nevent. Follow the create-component skill and finish with the structure test.\n```\n\n```text\n/component-from-design https://www.figma.com/design/<file>?node-id=<node> as \"chip\"\n```\n\n```text\nUse the design-system agent: add a theme called \"aurora\" with a teal primary and a triadic harmony;\nit must pass the accessibility validation in light and dark.\n```\n\n```text\nUse the reviewer agent: review the current branch against develop and list only high-confidence\nproblems.\n```\n\n```text\n/finish-work \"feat(elements): add cosm-switch\" closes #12\n```\n"},{"slug":"getting-started/installation","title":"Installation","markdown":"# Installation\n\n> Install Cosmos UI for the web, React, Angular, React Native and Tailwind CSS.\n\nCosmos UI is not published yet. Once released, packages are installed from npm. Each framework has a\ncomplete guide: [React](../../guides/react-vite/), [Next.js](../../guides/nextjs/),\n[Angular](../../guides/angular/), [HTML / CDN](../../guides/html-cdn/),\n[React Native](../../guides/react-native/) and [Tailwind CSS](../../guides/tailwind/). To let an AI\nassistant do it, see [Use with AI](../../ai/overview/).\n\n**Web Components**\n```bash\nnpm install @joralvmel/cosmos-elements @joralvmel/cosmos-tokens\n```\n\n```js\nimport '@joralvmel/cosmos-tokens/tokens.css';\nimport '@joralvmel/cosmos-elements/button';\n```\n\n**React**\n```bash\nnpm install @joralvmel/cosmos-react @joralvmel/cosmos-tokens\n```\n\n```tsx\nimport '@joralvmel/cosmos-tokens/tokens.css';\n\nexport const Save = () => <Button onPress={event => console.log(event.detail.source)}>Save</Button>;\n```\n\n**Angular**\n```bash\nnpm install @joralvmel/cosmos-angular @joralvmel/cosmos-tokens\n```\n\n```ts\n\n@Component({\n selector: 'app-save',\n imports: [CosmButtonComponent],\n template: `<cosm-button (press)=\"save()\">Save</cosm-button>`,\n})\nexport class SaveComponent {\n save() {}\n}\n```\n\n**React Native**\n```bash\nnpm install @joralvmel/cosmos-native\n```\n\n```tsx\n\nexport default function App() {\n return (\n <CosmosThemeProvider theme=\"nebula\" mode=\"system\">\n <Button onPress={({ source }) => console.log(source)}>Save</Button>\n </CosmosThemeProvider>\n );\n}\n```\n\n## Theme and mode\n\nSet the theme and mode on any element (usually `<html>`). `data-mode=\"system\"` follows the operating\nsystem; without `data-mode` the light mode is used.\n\n```html\n<html data-theme=\"nebula\" data-mode=\"system\"></html>\n```\n\n## Tailwind CSS v4 (optional)\n\n```css\n@import \"tailwindcss\";\n@import \"@joralvmel/cosmos-tailwind\";\n```\n\nUtilities such as `bg-primary`, `text-fg-muted`, `rounded-md`, `dark:bg-surface` or\n`theme-nebula:text-accent` use the Cosmos tokens.\n"},{"slug":"getting-started/introduction","title":"Introduction","markdown":"# Introduction\n\n> What Cosmos UI is and how its packages fit together.\n\nCosmos UI is a design system that ships the same components to the web (Web Components, React,\nAngular) and to React Native. Each component is defined once as a **contract** in\n`@joralvmel/cosmos-core`; every platform implementation is tested against that contract and its shared\nbehavior scenarios.\n\n## Packages\n\n| Package | Purpose |\n| --- | --- |\n| `@joralvmel/cosmos-tokens` | Theme engine and design tokens (CSS variables, JSON, React Native values) |\n| `@joralvmel/cosmos-tailwind` | Tailwind CSS v4 theme mapped to the tokens |\n| `@joralvmel/cosmos-core` | Contracts, shared scenarios and headless logic |\n| `@joralvmel/cosmos-elements` | Web Components built with Lit |\n| `@joralvmel/cosmos-react` | React wrappers |\n| `@joralvmel/cosmos-angular` | Angular standalone components |\n| `@joralvmel/cosmos-native` | React Native components |\n\nCharts, icons, i18n, the MCP server and the CLI are in early development.\n\n## Principles\n\n- **Contracts first**: props, events, slots, keyboard support and ARIA roles are decided before code.\n- **Tokens only**: components are styled with `--cosm-*` variables, so every theme and mode works.\n- **Accessible by default**: WAI-ARIA patterns, visible focus, reduced motion and verified contrast.\n"},{"slug":"guides/angular","title":"Angular","markdown":"# Angular\n\n> Use Cosmos UI in Angular with standalone components, signals and forms.\n\n`@joralvmel/cosmos-angular` provides one standalone component per Web Component, with the same\nselector (`cosm-button`…). Inputs set element properties; outputs re-emit the original `CustomEvent`.\n\n## Setup\n\n```bash\nnpm install @joralvmel/cosmos-angular @joralvmel/cosmos-tokens\n```\n\n**Load the tokens** (`angular.json`)\n\n```json\n\"styles\": [\"node_modules/@joralvmel/cosmos-tokens/dist/tokens.css\", \"src/styles.css\"]\n```\n\n**Choose theme and mode** (`src/index.html`)\n\n```html\n<html data-theme=\"cosmos\" data-mode=\"system\">\n```\n\n**Import components** (`src/app/app.component.ts`)\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmButtonComponent } from '@joralvmel/cosmos-angular';\n\n@Component({\n selector: 'app-root',\n imports: [CosmButtonComponent],\n template: `<cosm-button (press)=\"save($event.detail.source)\">Save</cosm-button>`,\n})\nexport class AppComponent {\n save(source: string) {}\n}\n```\n\n- Components are standalone; import them individually or spread `COSMOS_COMPONENTS`.\n- Outputs re-emit the original CustomEvent: use `$event.detail`. Form controls provide ControlValueAccessors.\n\nGuide: https://joralvmel.github.io/cosmos-ui/guides/angular/\n\n## Inputs, outputs and signals\n\n```ts\n\n@Component({\n selector: 'app-save',\n imports: [CosmButtonComponent],\n template: `\n <cosm-button [loading]=\"saving()\" variant=\"soft\" (press)=\"save()\">Save</cosm-button>\n `,\n})\nexport class SaveComponent {\n readonly saving = signal(false);\n\n save() {\n this.saving.set(true);\n }\n}\n```\n\n- Boolean inputs accept attributes (`loading`, `fullWidth`) and bindings (`[loading]=\"saving()\"`).\n- Outputs use the contract names: `(press)`, `(valueChange)`, `(openChange)`… Read `$event.detail`.\n- The components work in zoneless applications.\n\n## Forms\n\n`<cosm-button type=\"submit\">` submits the surrounding `<form>`. Form controls (text field, checkbox…)\nship `ControlValueAccessor`s so they work with `formControlName` and `[(ngModel)]` as they become\navailable (see the [component status](../../components/status/)).\n\n## All components at once\n\n```ts\n\n@Component({ imports: [...COSMOS_COMPONENTS], template: '…' })\nexport class Page {}\n```\n"},{"slug":"guides/html-cdn","title":"HTML and CDN","markdown":"# HTML and CDN\n\n> Use Cosmos UI Web Components in plain HTML, from a CDN or with any bundler.\n\nThe Web Components of `@joralvmel/cosmos-elements` work in any page: no framework needed.\n\n## Setup\n\n**Load tokens and components from a CDN** (`index.html`)\n\n```html\n<!doctype html>\n<html lang=\"en\" data-theme=\"cosmos\" data-mode=\"system\">\n <head>\n <link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/@joralvmel/cosmos-tokens/dist/tokens.css\" />\n <script type=\"module\" src=\"https://esm.sh/@joralvmel/cosmos-elements/button\"></script>\n </head>\n <body>\n <cosm-button variant=\"soft\">Save</cosm-button>\n <script type=\"module\">\n document.querySelector('cosm-button').addEventListener('cosm-press', event => {\n console.log(event.detail.source);\n });\n </script>\n </body>\n</html>\n```\n\n- With a bundler, `npm install @joralvmel/cosmos-elements @joralvmel/cosmos-tokens` and import `@joralvmel/cosmos-elements/<component>`.\n- DOM events are `cosm-*` CustomEvents that bubble and cross shadow roots.\n\nGuide: https://joralvmel.github.io/cosmos-ui/guides/html-cdn/\n\n## With a bundler\n\n```bash\nnpm install @joralvmel/cosmos-elements @joralvmel/cosmos-tokens\n```\n\n```js\nimport '@joralvmel/cosmos-tokens/tokens.css';\nimport '@joralvmel/cosmos-elements/button'; // one import per component\n```\n\n## Properties, attributes and events\n\n- Styling props are attributes in kebab-case (`full-width`, `variant=\"soft\"`); every prop is also a\n JavaScript property (`button.fullWidth = true`).\n- Events are `cosm-*` `CustomEvent`s that bubble and cross shadow roots, so you can listen on a parent.\n- Theme hooks: `--cosm-<component>-*` custom properties and `::part()` selectors (see each component API).\n\n```html\n<form>\n <cosm-button type=\"submit\">Send</cosm-button>\n</form>\n<script type=\"module\">\n document.addEventListener('cosm-press', event => console.log(event.target, event.detail));\n</script>\n```\n\n## Switching theme and mode\n\n```html\n<script type=\"module\">\n setTheme('nebula');\n setMode('dark');\n</script>\n```\n"},{"slug":"guides/nextjs","title":"Next.js","markdown":"# Next.js\n\n> Use Cosmos UI with the Next.js App Router, Server and Client Components.\n\nCosmos components are Web Components wrapped for React. They work with the App Router as long as they\nare rendered from **Client Components**.\n\n## Setup\n\n```bash\nnpm install @joralvmel/cosmos-react @joralvmel/cosmos-tokens\n```\n\n**Load the tokens and avoid a theme flash** (`app/layout.tsx`)\n\n```tsx\nimport '@joralvmel/cosmos-tokens/tokens.css';\nimport { themeInitScript } from '@joralvmel/cosmos-tokens/runtime';\nimport Script from 'next/script';\n\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\n return (\n <html lang=\"en\" data-theme=\"cosmos\" data-mode=\"system\" suppressHydrationWarning>\n <body>\n <Script id=\"cosmos-theme\" strategy=\"beforeInteractive\">\n {themeInitScript()}\n </Script>\n {children}\n </body>\n </html>\n );\n}\n```\n\n**Use components in Client Components** (`app/save-button.tsx`)\n\n```tsx\n'use client';\n\nimport { Button } from '@joralvmel/cosmos-react';\n\nexport function SaveButton() {\n return <Button onPress={() => console.log('saved')}>Save</Button>;\n}\n```\n\n- Cosmos components are Web Components: render them from Client Components (`'use client'`). Server Components can render the Client Component that wraps them.\n- The server HTML contains the custom element tag; it upgrades in the browser.\n\nGuide: https://joralvmel.github.io/cosmos-ui/guides/nextjs/\n\n## Server and Client Components\n\n- The wrappers set element properties and listen to events in effects, so the file that imports\n `@joralvmel/cosmos-react` must start with `'use client'`.\n- Server Components can render those Client Components and pass serializable props (strings,\n numbers, booleans). Handlers stay inside the Client Component.\n- The server HTML contains the custom element tag and its text; the element upgrades in the browser.\n\n```tsx\n// app/page.tsx (Server Component)\n\nexport default function Page() {\n return <SaveButton />;\n}\n```\n\n## Avoiding a theme flash\n\n`themeInitScript()` returns a small, validated inline script that restores the theme and mode stored by\n`setTheme()` / `setMode()` before the first paint. Load it with `next/script` and\n`strategy=\"beforeInteractive\"` as shown above, and keep `suppressHydrationWarning` on `<html>` because\nthe script may change `data-theme` / `data-mode` before hydration.\n\n## Tailwind\n\nUse `@tailwindcss/postcss` with the [Cosmos Tailwind theme](../tailwind/).\n"},{"slug":"guides/react-native","title":"React Native and Expo","markdown":"# React Native and Expo\n\n> Use Cosmos UI components and themes in React Native apps with Expo.\n\n`@joralvmel/cosmos-native` implements the same component contracts with React Native primitives and\nuses the same themes as the web.\n\n## Setup\n\n```bash\nnpx expo install @joralvmel/cosmos-native\n```\n\n**Provide a theme** (`app/_layout.tsx`)\n\n```tsx\nimport { CosmosThemeProvider } from '@joralvmel/cosmos-native';\nimport { Stack } from 'expo-router';\n\nexport default function Layout() {\n return (\n <CosmosThemeProvider theme=\"cosmos\" mode=\"system\">\n <Stack />\n </CosmosThemeProvider>\n );\n}\n```\n\n**Use components** (`app/index.tsx`)\n\n```tsx\nimport { Button } from '@joralvmel/cosmos-native';\n\nexport default function Home() {\n return <Button onPress={({ source }) => console.log(source)}>Save</Button>;\n}\n```\n\n- Callbacks receive the event detail directly (`onPress(detail)`).\n- `useTheme()` returns colors, spacing, radius and typography as numbers for your own styles.\n\nGuide: https://joralvmel.github.io/cosmos-ui/guides/react-native/\n\n## Theme and mode\n\n`CosmosThemeProvider` accepts `theme` (`cosmos`, `nebula`…) and `mode` (`light`, `dark` or `system`,\nwhich follows the device appearance).\n\n## Your own styles with the theme\n\n```tsx\n\nexport function Card({ title }: { title: string }) {\n const theme = useTheme();\n return (\n <View style={{ backgroundColor: theme.colors.surface, borderRadius: theme.radius.lg, padding: theme.space.lg }}>\n <Text style={{ color: theme.colors.fg, fontSize: theme.text.lg }}>{title}</Text>\n </View>\n );\n}\n```\n\n## Accessibility\n\nComponents set `accessibilityRole`, `accessibilityState` and labels, and small controls extend their\ntouch area to 44 points. Test with TalkBack and VoiceOver.\n\n## Demo app\n\nThe repository includes an Expo Router app with a screen per component: see\n[Contribute → Getting started](../../contribute/getting-started/#native-demo).\n"},{"slug":"guides/react-vite","title":"React (Vite)","markdown":"# React (Vite)\n\n> Use Cosmos UI in a React 19 app built with Vite.\n\n`@joralvmel/cosmos-react` wraps the Cosmos Web Components for React 19. Props are set as element\nproperties and event props receive the original `CustomEvent`.\n\n## Setup\n\n```bash\nnpm install @joralvmel/cosmos-react @joralvmel/cosmos-tokens\n```\n\n**Load the tokens once** (`src/main.tsx`)\n\n```tsx\nimport '@joralvmel/cosmos-tokens/tokens.css';\n```\n\n**Choose theme and mode** (`index.html`)\n\n```html\n<html data-theme=\"cosmos\" data-mode=\"system\">\n```\n\n**Use components** (`src/App.tsx`)\n\n```tsx\nimport { Button } from '@joralvmel/cosmos-react';\n\nexport default function App() {\n return <Button onPress={event => console.log(event.detail.source)}>Save</Button>;\n}\n```\n\n- Event props (`onPress`, `onChange`…) receive the original CustomEvent: read `event.detail`.\n- Change theme and mode at runtime with `setTheme()` / `setMode()` from `@joralvmel/cosmos-tokens/runtime`.\n\nGuide: https://joralvmel.github.io/cosmos-ui/guides/react-vite/\n\n## Events\n\nEvent props follow the contract names (`onPress`, `onChange`, `onOpenChange`…). Read the payload from\n`event.detail`; its type is exported by `@joralvmel/cosmos-core`.\n\n```tsx\n\nfunction Save() {\n const onPress = (event: CustomEvent<ButtonPressDetail>) => console.log(event.detail.source);\n return <Button onPress={onPress}>Save</Button>;\n}\n```\n\n## Controlled and uncontrolled state\n\nStateful components (value, open, selected tab…) work uncontrolled by default. Pass the state prop to\ncontrol it: the component then proposes changes through its event and waits for your new prop value\n([ADR 0003](https://github.com/joralvmel/cosmos-ui/blob/develop/docs/adr/0003-state-ownership-and-events.md)).\n\n## Switching theme and mode\n\n```tsx\n\nsetTheme('nebula');\nsetMode('dark'); // 'light' | 'dark' | 'system'\n```\n\nThe choice is stored in `localStorage`. To restore it before the first paint, add the script returned\nby `themeInitScript()` to `<head>` (see the [Next.js guide](../nextjs/)).\n\n## Next steps\n\n- Style your own UI with tokens or the [Tailwind theme](../tailwind/).\n- Browse the [components](../../components/status/) and their playgrounds.\n"},{"slug":"guides/tailwind","title":"Tailwind CSS","markdown":"# Tailwind CSS\n\n> Style your app with Tailwind CSS v4 utilities mapped to Cosmos tokens and themes.\n\n`@joralvmel/cosmos-tailwind` turns the Cosmos tokens into a Tailwind CSS v4 theme. Every utility follows\nthe active theme and mode, and Cosmos components keep working without Tailwind.\n\n## Setup\n\n```bash\nnpm install @joralvmel/cosmos-tailwind && npm install -D tailwindcss @tailwindcss/vite\n```\n\n**Import the Cosmos theme after Tailwind** (`src/styles.css`)\n\n```css\n@import \"tailwindcss\";\n@import \"@joralvmel/cosmos-tailwind\";\n```\n\n**Use token utilities**\n\n```html\n<div class=\"bg-surface text-fg rounded-lg shadow-md p-4 dark:bg-surface-raised\">\n <p class=\"text-fg-muted\">Uses Cosmos tokens in every theme and mode.</p>\n</div>\n```\n\n- Default Tailwind colors are disabled: use semantic colors (`bg-primary`, `text-danger-text`…).\n- `dark:` follows `data-mode` (including `system`); `theme-<name>:` targets one theme.\n\nGuide: https://joralvmel.github.io/cosmos-ui/guides/tailwind/\n\nPlugins: Vite uses `@tailwindcss/vite`; Next.js and Angular use `@tailwindcss/postcss`.\n\n## Utilities\n\n| Group | Examples |\n| --- | --- |\n| Colors | `bg-bg`, `bg-surface`, `text-fg`, `text-fg-muted`, `bg-primary text-primary-fg`, `bg-danger-subtle text-danger-text`, `border-border`, `ring-focus-ring` |\n| Scales | `bg-primary-3`, `text-neutral-11` (steps 1–12) |\n| Spacing | `p-4` (= 4 × `--cosm-space-unit`), `gap-sm`, `px-lg` |\n| Shape | `rounded-sm` … `rounded-xl`, `rounded-full`, `shadow-sm` / `shadow-md` / `shadow-lg` |\n| Typography | `text-xs` … `text-4xl`, `font-semibold`, `leading-tight` |\n\nDefault Tailwind colors (`bg-blue-500`…) are disabled so only theme colors are used.\n\n## Variants\n\n- `dark:` applies in dark mode, including `data-mode=\"system\"` when the OS is dark.\n- `theme-<name>:` targets one theme, e.g. `theme-nebula:rounded-none`.\n"},{"slug":"","title":"Cosmos UI","markdown":"# Cosmos UI\n\n> Themeable design system with Web Components, React, Angular and React Native built from one contract per component.\n\n### Contracts first\n Every component starts as a typed contract: props, events, slots, keyboard and ARIA. Web, React,\n Angular and React Native implementations are tested against it.\n### Themes you can generate\n Pick seed colors and a harmony; Cosmos builds light and dark palettes in OKLCH and verifies WCAG\n contrast and color vision deficiencies.\n### Tailwind friendly\n Utilities like `bg-primary` or `rounded-md` map to Cosmos tokens through a Tailwind CSS v4 theme.\n### AI ready\n Machine-readable references (`llms.txt`) and an MCP server keep assistants aligned with the real API.\n"},{"slug":"theming/themes","title":"Themes","markdown":"# Themes\n\n> Built-in Cosmos themes in light and dark mode, with their accessibility report.\n\nEach theme is generated from seed colors and a color harmony with `defineTheme`. The engine builds\n12-step OKLCH scales, a dark mode with its own lightness curve, status colors that keep their meaning and\nan 8-color chart palette. Every theme is validated against WCAG 2.2 AA (normative), APCA (informative)\nand simulated protanopia, deuteranopia and tritanopia.\n\n- **Cosmos** (`data-theme=\"cosmos\"`), light and dark.\n- **Nebula** (`data-theme=\"nebula\"`), light and dark.\n\n## Create a theme\n\n```ts\n\nconst aurora = defineTheme({\n name: 'aurora',\n seeds: { primary: 'oklch(0.56 0.15 165)' },\n harmony: 'triadic',\n radius: 'pill',\n});\n\nconst resolved = resolveTheme(aurora);\nconsole.log(validateTheme(resolved).pass);\nconst css = toCss([resolved]);\n```\n\nTheme names cannot be `light`, `dark` or `system`; those are mode names.\n"}]
1
+ [{"slug":"ai/mcp","title":"MCP server","markdown":"# MCP server\n\n> Connect AI assistants to the Cosmos UI MCP server to query components, themes, tokens and setup.\n\n`@joralvmel/cosmos-mcp` is a [Model Context Protocol](https://modelcontextprotocol.io/) server\n(stdio). It ships the contracts, snippets, status, themes and docs of its version, so the answers match\nwhat you install.\n\n## Connect\n\n**VS Code**\n`npx @joralvmel/cosmos-cli init-ai` does it for you, or add to `.vscode/mcp.json`:\n\n```json\n{\n \"servers\": {\n \"cosmos-ui\": { \"type\": \"stdio\", \"command\": \"npx\", \"args\": [\"-y\", \"@joralvmel/cosmos-mcp\"] }\n }\n}\n```\n**Claude Code**\n```bash\nclaude mcp add cosmos-ui -- npx -y @joralvmel/cosmos-mcp\n```\n**Other clients**\nRun the command `npx -y @joralvmel/cosmos-mcp` as a stdio server in your client configuration.\n\n## Tools\n\n| Tool | Arguments | Returns |\n| --- | --- | --- |\n| `list_components` | `status?` (`planned`, `in-progress`, `stable`) | Every catalog component with category, platforms, dependencies and status. |\n| `get_component` | `name` | Contract (props, events per platform, slots, parts, keyboard), API table, snippets for HTML, React, Angular and React Native, imports and status. |\n| `list_themes` | — | Built-in themes and their modes. |\n| `get_tokens` | `theme?`, `mode?` | Semantic color tokens and radii of a theme and mode. |\n| `get_setup` | `framework` (`react`, `next`, `angular`, `html`, `react-native`, `tailwind`) | Install commands, setup code and rules. |\n| `search_docs` | `query`, `limit?` | Matching docs pages and package references with an excerpt. |\n\nResources: `cosmos://llms/<package>` returns the `llms.md` of each package.\n\n## Example questions\n\n- \"Which Cosmos components are stable, and which ones can I use for a form?\"\n- \"Show me the Angular code for a danger outline button that is loading.\"\n- \"What are the dark-mode tokens of the nebula theme?\"\n"},{"slug":"ai/overview","title":"Use Cosmos UI with AI","markdown":"# Use Cosmos UI with AI\n\n> Give AI assistants the real Cosmos API with init-ai, llms.txt, Markdown pages and the MCP server.\n\nAI assistants write better UI code when they know the real components, props, events and tokens. Cosmos\ngives them that knowledge in three ways, all generated from the component contracts.\n\n## 1. Prepare your project with `init-ai`\n\n1. Run it in your project folder with your stack (`react`, `next`, `angular`, `html` or `react-native`):\n\n ```bash\n npx @joralvmel/cosmos-cli init-ai --stack react\n ```\n\n2. It writes a marked block with the Cosmos rules into `.github/copilot-instructions.md` and\n `AGENTS.md` (add `--claude` for `CLAUDE.md`), registers the MCP server in `.vscode/mcp.json` and\n prints the installation steps. Run it again at any time: only the marked block is replaced.\n\n3. Ask your assistant to install Cosmos UI (see the [ready-made prompts](../prompts/)).\n\n## 2. Reference files\n\n| Resource | Use |\n| --- | --- |\n| [`/llms.txt`](../../llms.txt) | Index of every package reference and page, for assistants that read `llms.txt`. |\n| [`/llms-full.txt`](../../llms-full.txt) | The whole documentation and every package reference in one file. |\n| `/<page>.md` | Every page as Markdown (button **Copy page for AI** below each title). |\n| `node_modules/@joralvmel/cosmos-*/llms.md` | Reference of each installed package: setup, components with props, events and examples, themes and rules. |\n\n## 3. MCP server\n\nThe [MCP server](../mcp/) answers questions about components, themes, tokens and setup with data that\nmatches the installed version.\n\n## Install with AI (copy and paste)\n\n```text\nInstall Cosmos UI in this project. First run `npx @joralvmel/cosmos-cli init-ai --stack <my stack>`,\nthen follow the steps it prints. Use the cosmos-ui MCP server (get_setup, list_components,\nget_component) or https://joralvmel.github.io/cosmos-ui/llms.txt to check every component and prop\nbefore using it. Style only with Cosmos tokens or the Cosmos Tailwind theme.\n```\n"},{"slug":"ai/prompts","title":"Ready-made prompts","markdown":"# Ready-made prompts\n\n> Copyable prompts to build UI with Cosmos in React, Next.js, Angular, HTML and React Native.\n\nCopy a prompt, replace the part in angle brackets and paste it in your assistant. They assume you ran\n[`init-ai`](../overview/) or that the assistant can read `llms.txt` or the MCP server.\n\n**React**\n```text\nUsing Cosmos UI (@joralvmel/cosmos-react) in this React + Vite app, build <a settings page with a\nform and a save button>. Check each component with the cosmos-ui MCP server (get_component) before\nusing it, handle events through event.detail, style the layout with Cosmos tokens or the Cosmos\nTailwind theme, support light and dark mode and keep keyboard access.\n```\n**Next.js**\n```text\nUsing Cosmos UI (@joralvmel/cosmos-react) in this Next.js App Router project, build <a dashboard\nheader with actions>. Put Cosmos components in Client Components ('use client'), keep pages as\nServer Components, load @joralvmel/cosmos-tokens/tokens.css in app/layout.tsx and use\nthemeInitScript() to avoid a theme flash. Check props with the cosmos-ui MCP server.\n```\n**Angular**\n```text\nUsing Cosmos UI (@joralvmel/cosmos-angular) in this standalone Angular app, build <a profile form>.\nImport the Cosmos standalone components you need, bind inputs with signals, listen to outputs with\n$event.detail and keep forms accessible. Check each component with the cosmos-ui MCP server.\n```\n**HTML**\n```text\nBuild <a landing page section> in plain HTML with Cosmos UI Web Components from a CDN\n(@joralvmel/cosmos-elements and @joralvmel/cosmos-tokens). Use <cosm-*> elements, listen to cosm-*\nevents, set data-theme and data-mode on <html> and use only var(--cosm-*) tokens in custom CSS.\n```\n**React Native**\n```text\nUsing Cosmos UI (@joralvmel/cosmos-native) in this Expo app, build <a login screen>. Wrap the app in\nCosmosThemeProvider with mode=\"system\", use useTheme() for custom styles, keep touch targets of at\nleast 44 points and accessibility labels. Check each component with the cosmos-ui MCP server.\n```\n\n## Prompts for the component library itself\n\nTo add or change components in the Cosmos repository, use the agents and prompts of the repository\n(`/create-component`, `/component-status`…): see [Working with agents](../../contribute/working-with-agents/).\n"},{"slug":"components/button","title":"Button","markdown":"# Button\n\n> Triggers an action or submits a form. Web Component, React, Angular and React Native.\n\nStatus: **stable** (web, react, angular, native).\n\n`<cosm-button>` triggers an action. It follows the\n[WAI-ARIA button pattern](https://www.w3.org/WAI/ARIA/apg/patterns/button/), renders a native\n`<button>` and takes part in forms (`type=\"submit\"` / `type=\"reset\"`). Use it for actions; use a link\nfor navigation.\n\n## Playground\n\n**HTML / Web Component**\n\n```html\n<cosm-button>Save changes</cosm-button>\n\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/button';\n\n const element = document.querySelector('cosm-button');\n element.addEventListener('cosm-press', event => console.log(event.detail));\n</script>\n```\n\n**React**\n\n```tsx\nimport { Button } from '@joralvmel/cosmos-react';\n\nexport function Example() {\n return (\n <Button onPress={event => console.log(event.detail)}>Save changes</Button>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmButtonComponent } from '@joralvmel/cosmos-angular';\nimport type { ButtonPressDetail } from '@joralvmel/cosmos-core';\n\n@Component({\n selector: 'app-example',\n imports: [CosmButtonComponent],\n template: `<cosm-button (press)=\"onPress($event.detail)\">Save changes</cosm-button>`,\n})\nexport class ExampleComponent {\n onPress(detail: ButtonPressDetail) {\n console.log(detail);\n }\n}\n```\n\n**React Native**\n\n```tsx\nimport { Button } from '@joralvmel/cosmos-native';\n\nexport function Example() {\n return (\n <Button onPress={detail => console.log(detail)}>Save changes</Button>\n );\n}\n```\n\n## Variants\n\n`variant` sets the emphasis and `tone` the color role. Use one `solid` button per view for the main\naction.\n\n```html\n<cosm-button>Solid</cosm-button>\n<cosm-button variant=\"soft\">Soft</cosm-button>\n<cosm-button variant=\"outline\">Outline</cosm-button>\n<cosm-button variant=\"ghost\">Ghost</cosm-button>\n<cosm-button tone=\"neutral\">Neutral</cosm-button>\n<cosm-button tone=\"danger\">Delete</cosm-button>\n```\n\n```html\n<cosm-button size=\"sm\">Small</cosm-button>\n<cosm-button>Medium</cosm-button>\n<cosm-button size=\"lg\">Large</cosm-button>\n```\n\n## States\n\n```html\n<cosm-button loading>Saving</cosm-button>\n<cosm-button disabled>Disabled</cosm-button>\n```\n\n- `loading` keeps the button focusable, sets `aria-busy` and ignores presses.\n- `disabled` removes it from the tab order and ignores presses.\n- Hover, active and `:focus-visible` states use the theme tokens of the selected tone.\n\n## Accessibility\n\n- Native `<button>` semantics: <kbd>Enter</kbd> and <kbd>Space</kbd> activate it.\n- Give icon-only buttons a `label`; it becomes the accessible name.\n- Use `tone=\"danger\"` together with explicit text for destructive actions; color is never the only cue.\n- On React Native, small buttons extend their touch area to 44 points.\n\n## API\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `variant` | 'solid' \\| 'soft' \\| 'outline' \\| 'ghost' | `solid` | Visual emphasis, from highest (solid) to lowest (ghost). |\n| `tone` | 'primary' \\| 'neutral' \\| 'danger' | `primary` | Color role. Use danger for destructive actions. |\n| `size` | 'sm' \\| 'md' \\| 'lg' | `md` | Control height and padding. |\n| `disabled` | boolean | `false` | Prevents interaction and removes the button from the tab order. |\n| `loading` | boolean | `false` | Shows a spinner, sets aria-busy and ignores presses while keeping focus. |\n| `fullWidth` | boolean | `false` | Stretches the button to the width of its container. |\n| `type` | 'button' \\| 'submit' \\| 'reset' | `button` | Form behavior of the button. |\n| `label` | string | — | Accessible name when the visible content is not descriptive (icon-only buttons). |\n\n**Slots**\n\n| Name | Description |\n| --- | --- |\n| `(default)` | Button label. |\n| `start` | Content before the label, usually an icon. |\n| `end` | Content after the label, usually an icon. |\n\n**CSS parts**\n\n| Name | Description |\n| --- | --- |\n| `base` | The native button element. |\n| `label` | Wrapper of the label slot. |\n| `spinner` | Loading indicator. |\n\n**CSS custom properties**\n\n| Name | Description |\n| --- | --- |\n| `--cosm-button-radius` | Corner radius. |\n| `--cosm-button-gap` | Space between icon and label. |\n| `--cosm-button-font-weight` | Label font weight. |\n\n**Keyboard**\n\n| Keys | Action |\n| --- | --- |\n| `Enter`, `Space` | Activates the button. |\n\n## Events by platform\n\n| DOM | React | Angular | React Native | Detail | Description |\n| --- | --- | --- | --- | --- | --- |\n| `cosm-press` | `onPress` | `(press)` | `onPress` | `ButtonPressDetail` | The button was activated by pointer, keyboard or programmatically. |\n"},{"slug":"components/icon-button","title":"Icon Button","markdown":"# Icon Button\n\n> An accessible icon-only action or toggle for Web Components, React, Angular and React Native.\n\nStatus: **stable** (web, react, angular, native).\n\n`<cosm-icon-button>` performs an action or toggles a boolean state using a single decorative\n[Cosmos Icon](/components/icon/). It follows the\n[WAI-ARIA button pattern](https://www.w3.org/WAI/ARIA/apg/patterns/button/).\nUse it for familiar, compact actions; prefer a [Button](/components/button/) with visible text\nwhen the meaning is not obvious. It is not a navigation link.\n\n## Playground\n\n**HTML / Web Component**\n\n```html\n<cosm-icon-button label=\"IconButton\"><cosm-icon></cosm-icon></cosm-icon-button>\n\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/icon';\n import { heart } from '@joralvmel/cosmos-icons/heart';\n import '@joralvmel/cosmos-elements/icon-button';\n\n const element = document.querySelector('cosm-icon-button');\n element.addEventListener('cosm-press', event => console.log(event.detail));\n element.addEventListener('cosm-pressed-change', event => console.log(event.detail));\n\n const childElement = document.querySelector('cosm-icon');\n childElement.icon = heart;\n</script>\n```\n\n**React**\n\n```tsx\nimport { heart } from '@joralvmel/cosmos-icons/heart';\nimport { IconButton, Icon } from '@joralvmel/cosmos-react';\n\nexport function Example() {\n return (\n <IconButton\n label=\"IconButton\"\n onPress={event => console.log(event.detail)}\n onPressedChange={event => console.log(event.detail)}\n >\n <Icon icon={heart}></Icon>\n </IconButton>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { heart } from '@joralvmel/cosmos-icons/heart';\nimport { Component } from '@angular/core';\nimport { CosmIconButtonComponent, CosmIconComponent } from '@joralvmel/cosmos-angular';\nimport type { IconButtonPressDetail, IconButtonPressedChangeDetail } from '@joralvmel/cosmos-core';\n\n@Component({\n selector: 'app-example',\n imports: [CosmIconButtonComponent, CosmIconComponent],\n template: `<cosm-icon-button label=\"IconButton\" (press)=\"onPress($event.detail)\" (pressedChange)=\"onPressedChange($event.detail)\"><cosm-icon [icon]=\"heart\"></cosm-icon></cosm-icon-button>`,\n})\nexport class ExampleComponent {\n readonly heart = heart;\n onPress(detail: IconButtonPressDetail) {\n console.log(detail);\n }\n\n onPressedChange(detail: IconButtonPressedChangeDetail) {\n console.log(detail);\n }\n}\n```\n\n**React Native**\n\n```tsx\nimport { heart } from '@joralvmel/cosmos-icons/heart';\nimport { IconButton, Icon } from '@joralvmel/cosmos-native';\n\nexport function Example() {\n return (\n <IconButton\n label=\"IconButton\"\n onPress={detail => console.log(detail)}\n onPressedChange={detail => console.log(detail)}\n >\n <Icon icon={heart}></Icon>\n </IconButton>\n );\n}\n```\n\nTry `label`, `mode`, `variant`, `tone`, `size`, `disabled`, `pressed`, `defaultPressed` and web\n`type`. The **pressed** control offers autonomous state or an explicitly controlled `false` or\n`true`. Controlled values stay fixed on activation until you change them; autonomous toggles\nupdate themselves. Switch to `mode=\"toggle\"` to see pressed state. `defaultPressed` seeds\nautonomous state, not a controlled value; set it before the first interaction.\n\nThe code tabs generate Web Component, React, Angular and React Native examples from the same\ncontract. The icon is a child, **not an icon-definition prop on Icon Button**: use the default\nslot on the web and children in React and React Native. Import each definition from its own\nmodule, such as `@joralvmel/cosmos-icons/heart`; do not import a catalog or icon-name registry.\nThe child Icon stays decorative because the button supplies the accessible name.\n\n## Variants\n\n`variant` controls emphasis: `solid`, `soft`, `outline` or `ghost`. `tone` is `primary`, `neutral`\nor `danger`. The examples also show `sm`, `md` and `lg` square controls.\nDefaults are `solid`, `primary` and `md`.\n\nCustomize the existing Icon child with its own `size`, `strokeWidth`, `stroke` or `fill`;\nkeep it decorative. Its inherited foreground follows the button's tone and state. A filled\npath is not a separate solid icon collection; see the Icon page's geometry guidance.\n\n## States\n\nFrom left to right: disabled action, autonomous Favorite toggle (initially pressed), and controlled\nPin toggle (initially unpressed). The controlled example accepts each proposed value and writes\nit back to `pressed`.\n\n- `mode=\"action\"` emits `press` without toggling. `mode=\"toggle\"` also proposes a boolean\n through `pressedChange`; mixed state is not supported.\n- Omit `pressed` for autonomous state and use `defaultPressed` for its initial value.\n- Bind `pressed` for controlled state, **including `false`**. Accept the proposal by updating\n your bound value; ignoring it leaves the current state unchanged.\n- In Web Components, listen for `cosm-pressed-change` and assign `event.detail.pressed` to\n the element's `pressed` property. React uses `onPressedChange` with\n `setPressed(event.detail.pressed)`; Angular uses `[pressed]` and\n `(pressedChange)=\"pressed = $event.detail.pressed\"`. React Native's `onPressedChange`\n receives the detail directly: `setPressed(detail.pressed)`.\n- `disabled` blocks activation and both events. Hover, active, focus-visible and pressed\n styling follow theme tokens. There is no loading state.\n- On the web, `type=\"button\"` is the safe default; use `submit` or `reset` inside an HTML\n form for those actions. React Native has no `type` prop or HTML form submission/reset.\n\n## Accessibility\n\n- A non-empty, localized `label` is required. Name the action, not the glyph: “Delete”, not\n “Trash icon”. A missing or blank label is invalid.\n- Web uses a native button: <kbd>Enter</kbd> and <kbd>Space</kbd> activate it. Disabled buttons\n leave the tab order. Keep the focus-visible indicator.\n- Toggle mode exposes `aria-pressed` on the web. Keep its label stable (“Favorite”), rather\n than changing it to describe the next action. Action mode has no pressed semantics.\n- Keep the Icon child decorative and non-interactive; do not add another label or focus stop.\n Do not nest links or buttons inside the control.\n- React Native exposes button semantics and disabled/checked accessibility state (React Native Web\n uses `aria-pressed` for toggles); the touch\n target is at least 44 by 44 logical points, even for the small visual size. Web dimensions\n use the control tokens instead of native touch-target sizing.\n- Do not communicate destructive intent or pressed state through color alone. A label is an\n accessible name, not a tooltip; no tooltip is provided.\n\n## API\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `label` | string | Required | Required localized accessible name. Missing, empty or whitespace-only labels are rejected. |\n| `mode` | 'action' \\| 'toggle' | `action` | Action activates without toggle state; toggle exposes and changes pressed state. |\n| `variant` | 'solid' \\| 'soft' \\| 'outline' \\| 'ghost' | `solid` | Visual emphasis, from highest (solid) to lowest (ghost). |\n| `tone` | 'primary' \\| 'neutral' \\| 'danger' | `primary` | Color role. Use danger for destructive actions. |\n| `size` | 'sm' \\| 'md' \\| 'lg' | `md` | Size of the square visual control. |\n| `disabled` | boolean | `false` | Prevents activation and removes the web button from the tab order. |\n| `type` | 'button' \\| 'submit' \\| 'reset' | `button` | Native web button form behavior. |\n| `pressed` | boolean | `false` | Toggle state. If supplied, including false, activation proposes changes without committing them until the owner updates this prop. |\n| `defaultPressed` | boolean | `false` | Initial toggle state when pressed is not supplied; it does not control later changes. |\n\n**Slots**\n\n| Name | Description |\n| --- | --- |\n| `(default)` | Decorative icon content; the label supplies the accessible name. |\n\n**CSS parts**\n\n| Name | Description |\n| --- | --- |\n| `base` | The native button element. |\n\n**CSS custom properties**\n\n| Name | Description |\n| --- | --- |\n| `--cosm-icon-button-background` | Control background. |\n| `--cosm-icon-button-color` | Icon foreground color. |\n| `--cosm-icon-button-border` | Control border color. |\n| `--cosm-icon-button-radius` | Control corner radius. |\n| `--cosm-icon-button-focus` | Visible focus indicator color. |\n\n**Keyboard**\n\n| Keys | Action |\n| --- | --- |\n| `Tab`, `Shift+Tab` | Moves focus to or from the enabled button. |\n| `Enter`, `Space` | Activates the button; toggle mode also proposes a change. |\n\n## Events by platform\n\n| DOM | React | Angular | React Native | Detail | Description |\n| --- | --- | --- | --- | --- | --- |\n| `cosm-press` | `onPress` | `(press)` | `onPress` | `IconButtonPressDetail` | Reports each enabled activation by pointer, keyboard or programmatically. |\n| `cosm-pressed-change` | `onPressedChange` | `(pressedChange)` | `onPressedChange` | `IconButtonPressedChangeDetail` | Reports the proposed next pressed state on toggle activation; controlled state waits for the owner. |\n"},{"slug":"components/icon","title":"Icon","markdown":"# Icon\n\n> Render a Lucide-based SVG as a decorative or informative image.\n\nStatus: **stable** (web, react, angular, native).\n\n`<cosm-icon>` renders a structured SVG definition. Import only the glyphs you use from\n`@joralvmel/cosmos-icons`; per-icon modules keep application bundles tree-shakeable.\n\n## Playground\n\n**HTML / Web Component**\n\n```html\n<cosm-icon></cosm-icon>\n\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/icon';\n import { house } from '@joralvmel/cosmos-icons/house';\n\n const element = document.querySelector('cosm-icon');\n element.icon = house;\n</script>\n```\n\n**React**\n\n```tsx\nimport { Icon } from '@joralvmel/cosmos-react';\nimport { house } from '@joralvmel/cosmos-icons/house';\n\nexport function Example() {\n return (\n <Icon icon={house}></Icon>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmIconComponent } from '@joralvmel/cosmos-angular';\nimport { house } from '@joralvmel/cosmos-icons/house';\n\n@Component({\n selector: 'app-example',\n imports: [CosmIconComponent],\n template: `<cosm-icon [icon]=\"house\"></cosm-icon>`,\n})\nexport class ExampleComponent {\n readonly house = house;\n}\n```\n\n**React Native**\n\n```tsx\nimport { Icon } from '@joralvmel/cosmos-native';\nimport { house } from '@joralvmel/cosmos-icons/house';\n\nexport function Example() {\n return (\n <Icon icon={house}></Icon>\n );\n}\n```\n\nSearch by name or tag and filter by category. Choose a preview size and outline or filled paths;\nselect a card to update the preview and the highlighted code. Switch between HTML, React, Angular\nand React Native, then use **Copy code** for the selected technology. Thumbnails load in batches.\nFilled paths use SVG `fill`, not a separate solid collection; see the geometry caveats below.\nThe outline and fill color dropdowns sit alongside the filters. Choose inherited color, no paint\nor a Cosmos theme token; they update the selected icon, thumbnails and every snippet independently.\n**Preview size** is the only size control; choose **Custom** to enter a positive number of pixels.\nStroke width, the informative label and the decorative checkbox are in the same toolbar; there\nis no separate advanced panel. Thumbnails share the preview's theme and light/dark mode so color\ntokens resolve consistently. The catalog and its\nmodule map load only on the Icon playground, not on other component pages.\n\n## Variants\n\nChoose `sm` (16), `md` (20, default), `lg` (24), or a positive finite number. Numbers are CSS\npixels on the web and logical units on native. On the web `--cosm-icon-size` takes precedence,\nincluding `em` and `rem` values; it does not apply to native.\n\n```tsx\n\n<Icon icon={house} size=\"lg\" />;\n```\n\n`stroke` defaults to `currentColor` (inherited on web, `theme.colors.fg` on native), `fill` to\n`none`, and `strokeWidth` to `2` SVG viewBox units. Stroke width scales with the icon. Use\nnonnegative finite widths. Paints must be supported by the platform; URL paints are rejected.\nCSS custom-property paints work on the web, while native requires React Native color strings.\n\n```tsx\n\n<Icon icon={circle} size={32} stroke=\"var(--cosm-fg)\" fill=\"var(--cosm-primary)\" strokeWidth={1.5} />;\n```\n\n### Fill is not a solid variant\n\n`fill` works with every definition; it is not exclusive to particular icon names. The result\ndepends on the SVG geometry:\n\n- Closed contours, such as `circle` and `star`, can produce useful filled shapes.\n- SVG fills open paths as if their endpoints were joined. For example, filling `arrow-right`\n creates a triangle in its open arrowhead, not a purpose-designed solid arrow.\n- Multi-part outlines can lose details when filled. An explicit node fill, including `none`,\n takes precedence over the root fill.\n\nEach pair below shows `fill=\"none\"` on the left and `fill=\"var(--cosm-primary)\"` on the right.\nThe same generic property is used in all three pairs; there is no special-case rendering.\n\n<IconFillExamples label=\"Closed and open paths with and without fill\" />\n\nLucide is an outline set. Changing its fill does not provide a complete set of designed solid\nvariants; keep `fill=\"none\"` unless the selected geometry gives the intended result.\n\nIn React Native use `const theme = useTheme()` and pass `stroke={theme.colors.fg}` and\n`fill={theme.colors.primary}` instead. On native, a definition node\nwhose fill is `currentColor` (for example the dots of `brain-circuit`) also uses\n`theme.colors.fg`, independently of `stroke`. The Playground accepts `none`, `currentColor`, Cosmos\ncolor tokens such as `var(--cosm-primary)` and hex/rgb/hsl/named colors so every tab is valid; its\nReact Native tab turns token paints into `theme.colors` values from `useTheme()`.\n\n### Catalog versus application bundle\n\nThe package includes the full catalog, but application code should import individual glyphs, not\nthe demo's catalog loader. Web bundlers can discard unused modules. The native demo deliberately\nreferences every icon so its explorer can display any result: Metro includes those modules in the\nAndroid/iOS production bundle even though the loader uses `import()`. That demo is not a minimal\napplication bundle. Import only the icons your native application uses.\n\n## States\n\nIcons are non-interactive and have no state or events. They are decorative by default. To convey\nmeaning, set `decorative={false}` and provide a concise `label`.\n\n```tsx\n<Icon icon={house} decorative={false} label=\"Home\" />;\n```\n\n## Accessibility\n\n- Decorative icons are hidden from assistive technology and are not focusable.\n- Informative icons expose one image role and the provided accessible name.\n- `decorative={false}` without a non-empty `label` is an error; add a label or keep the icon\n decorative.\n- Do not use an icon alone as an interactive control. Put it inside a separately labeled button.\n\n## API\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `icon` | IconDefinition | Required | Structured icon definition, commonly imported from @joralvmel/cosmos-icons. |\n| `size` | 'sm' \\| 'md' \\| 'lg' \\| number | `md` | Semantic size (16, 20 or 24) or a positive finite number in pixels / native units. |\n| `stroke` | string | `currentColor` | Stroke paint; currentColor inherits on web and resolves to the theme foreground on native. |\n| `fill` | string | `none` | Root fill paint. Explicit node fills take precedence. |\n| `strokeWidth` | number | `2` | Finite nonnegative stroke width in SVG viewBox units. |\n| `label` | string | — | Accessible name required when decorative is false. |\n| `decorative` | boolean | `true` | Hides the icon from assistive technology when true. |\n\n**CSS parts**\n\n| Name | Description |\n| --- | --- |\n| `icon` | Rendered SVG image. |\n\n**CSS custom properties**\n\n| Name | Description |\n| --- | --- |\n| `--cosm-icon-size` | Override the rendered icon width and height. |\n\n## Events by platform\n\nNo events.\n"},{"slug":"components/listbox","title":"Listbox","markdown":"# Listbox\n\n> Accessible single or multiple selection from a vertical collection.\n\nStatus: **stable** (web, react, angular, native).\n\nListbox selects one or more values from a named vertical collection. Use it as a standalone\nselection list or as the behavioral foundation of a future Select or Combobox. It does not open a\npanel, filter data or submit a form: compose those responsibilities separately.\n\n## Playground\n\n**HTML / Web Component**\n\n```html\n<cosm-listbox label=\"Listbox\"></cosm-listbox>\n\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/listbox';\n const grouped = [{\"label\":\"Fruit\",\"options\":[{\"value\":\"apple\",\"label\":\"Apple\"},{\"value\":\"cherry\",\"label\":\"Cherry\",\"description\":\"Seasonal\"}]},{\"label\":\"Vegetables\",\"options\":[{\"value\":\"carrot\",\"label\":\"Carrot\"},{\"value\":\"broccoli\",\"label\":\"Broccoli\",\"disabled\":true}]}];\n const empty = [];\n\n const element = document.querySelector('cosm-listbox');\n element.items = grouped;\n element.defaultSelectedValues = empty;\n element.addEventListener('cosm-selection-change', event => console.log(event.detail));\n</script>\n```\n\n**React**\n\n```tsx\nimport { Listbox } from '@joralvmel/cosmos-react';\nconst grouped = [{\"label\":\"Fruit\",\"options\":[{\"value\":\"apple\",\"label\":\"Apple\"},{\"value\":\"cherry\",\"label\":\"Cherry\",\"description\":\"Seasonal\"}]},{\"label\":\"Vegetables\",\"options\":[{\"value\":\"carrot\",\"label\":\"Carrot\"},{\"value\":\"broccoli\",\"label\":\"Broccoli\",\"disabled\":true}]}] as const;\nconst empty = [] as const;\n\nexport function Example() {\n return (\n <Listbox\n label=\"Listbox\"\n items={grouped}\n defaultSelectedValues={empty}\n onSelectionChange={event => console.log(event.detail)}\n >\n </Listbox>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmListboxComponent } from '@joralvmel/cosmos-angular';\nconst grouped = [{\"label\":\"Fruit\",\"options\":[{\"value\":\"apple\",\"label\":\"Apple\"},{\"value\":\"cherry\",\"label\":\"Cherry\",\"description\":\"Seasonal\"}]},{\"label\":\"Vegetables\",\"options\":[{\"value\":\"carrot\",\"label\":\"Carrot\"},{\"value\":\"broccoli\",\"label\":\"Broccoli\",\"disabled\":true}]}] as const;\nconst empty = [] as const;\nimport type { ListboxSelectionChangeDetail } from '@joralvmel/cosmos-core';\n\n@Component({\n selector: 'app-example',\n imports: [CosmListboxComponent],\n template: `<cosm-listbox label=\"Listbox\" [items]=\"grouped\" [defaultSelectedValues]=\"empty\" (selectionChange)=\"onSelectionChange($event.detail)\"></cosm-listbox>`,\n})\nexport class ExampleComponent {\n readonly grouped = grouped;\n readonly empty = empty;\n onSelectionChange(detail: ListboxSelectionChangeDetail) {\n console.log(detail);\n }\n}\n```\n\n**React Native**\n\n```tsx\nimport { Listbox } from '@joralvmel/cosmos-native';\nconst grouped = [{\"label\":\"Fruit\",\"options\":[{\"value\":\"apple\",\"label\":\"Apple\"},{\"value\":\"cherry\",\"label\":\"Cherry\",\"description\":\"Seasonal\"}]},{\"label\":\"Vegetables\",\"options\":[{\"value\":\"carrot\",\"label\":\"Carrot\"},{\"value\":\"broccoli\",\"label\":\"Broccoli\",\"disabled\":true}]}] as const;\nconst empty = [] as const;\n\nexport function Example() {\n return (\n <Listbox\n label=\"Listbox\"\n items={grouped}\n defaultSelectedValues={empty}\n onSelectionChange={detail => console.log(detail)}\n >\n </Listbox>\n );\n}\n```\n\nTry single/multiple selection, flat/grouped collections, disabled/read-only, variants and sizes.\nChoose **Custom** to enter a positive minimum option height. Arrow keys move focus; Enter or Space\nselects. Type a prefix to navigate without filtering.\n\nThe selection controls use named sample arrays. `selectedValues` is autonomous when omitted; choosing\nan array binds it and shows proposals without accepting them automatically. Changing mode or initial\nvalues remounts this preview. The native demo includes owner acceptance/refusal and external reset.\n\n## Variants\n\n`plain` has no container border and composes inside Popover. `outlined` adds a boundary for standalone\nuse; neither adds a shadow. Both follow the selected theme and light/dark mode.\n\n**HTML / Web Component**\n\n```html\n<cosm-listbox label=\"Listbox\" variant=\"outlined\" size=\"56\"></cosm-listbox>\n\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/listbox';\n const grouped = [{\"label\":\"Fruit\",\"options\":[{\"value\":\"apple\",\"label\":\"Apple\"},{\"value\":\"cherry\",\"label\":\"Cherry\",\"description\":\"Seasonal\"}]},{\"label\":\"Vegetables\",\"options\":[{\"value\":\"carrot\",\"label\":\"Carrot\"},{\"value\":\"broccoli\",\"label\":\"Broccoli\",\"disabled\":true}]}];\n const empty = [];\n\n const element = document.querySelector('cosm-listbox');\n element.items = grouped;\n element.defaultSelectedValues = empty;\n element.addEventListener('cosm-selection-change', event => console.log(event.detail));\n</script>\n```\n\n**React**\n\n```tsx\nimport { Listbox } from '@joralvmel/cosmos-react';\nconst grouped = [{\"label\":\"Fruit\",\"options\":[{\"value\":\"apple\",\"label\":\"Apple\"},{\"value\":\"cherry\",\"label\":\"Cherry\",\"description\":\"Seasonal\"}]},{\"label\":\"Vegetables\",\"options\":[{\"value\":\"carrot\",\"label\":\"Carrot\"},{\"value\":\"broccoli\",\"label\":\"Broccoli\",\"disabled\":true}]}] as const;\nconst empty = [] as const;\n\nexport function Example() {\n return (\n <Listbox\n label=\"Listbox\"\n items={grouped}\n defaultSelectedValues={empty}\n variant=\"outlined\"\n size={56}\n onSelectionChange={event => console.log(event.detail)}\n >\n </Listbox>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmListboxComponent } from '@joralvmel/cosmos-angular';\nconst grouped = [{\"label\":\"Fruit\",\"options\":[{\"value\":\"apple\",\"label\":\"Apple\"},{\"value\":\"cherry\",\"label\":\"Cherry\",\"description\":\"Seasonal\"}]},{\"label\":\"Vegetables\",\"options\":[{\"value\":\"carrot\",\"label\":\"Carrot\"},{\"value\":\"broccoli\",\"label\":\"Broccoli\",\"disabled\":true}]}] as const;\nconst empty = [] as const;\nimport type { ListboxSelectionChangeDetail } from '@joralvmel/cosmos-core';\n\n@Component({\n selector: 'app-example',\n imports: [CosmListboxComponent],\n template: `<cosm-listbox label=\"Listbox\" [items]=\"grouped\" [defaultSelectedValues]=\"empty\" variant=\"outlined\" [size]=\"56\" (selectionChange)=\"onSelectionChange($event.detail)\"></cosm-listbox>`,\n})\nexport class ExampleComponent {\n readonly grouped = grouped;\n readonly empty = empty;\n onSelectionChange(detail: ListboxSelectionChangeDetail) {\n console.log(detail);\n }\n}\n```\n\n**React Native**\n\n```tsx\nimport { Listbox } from '@joralvmel/cosmos-native';\nconst grouped = [{\"label\":\"Fruit\",\"options\":[{\"value\":\"apple\",\"label\":\"Apple\"},{\"value\":\"cherry\",\"label\":\"Cherry\",\"description\":\"Seasonal\"}]},{\"label\":\"Vegetables\",\"options\":[{\"value\":\"carrot\",\"label\":\"Carrot\"},{\"value\":\"broccoli\",\"label\":\"Broccoli\",\"disabled\":true}]}] as const;\nconst empty = [] as const;\n\nexport function Example() {\n return (\n <Listbox\n label=\"Listbox\"\n items={grouped}\n defaultSelectedValues={empty}\n variant=\"outlined\"\n size={56}\n onSelectionChange={detail => console.log(detail)}\n >\n </Listbox>\n );\n}\n```\n\n`size` accepts `sm`, `md` (default), `lg`, or a positive finite number: minimum **option** height in\nCSS pixels on web and logical units on native. Descriptions and text scaling can make rows taller.\nNative touch targets stay at least 44 units even with a smaller numeric value.\n\nUse the documented CSS variables and `::part()` hooks for colors, borders, radius, text and spacing.\nSet the host width and `--cosm-listbox-max-height` to control dimensions and scrolling. Native exposes\ntyped style hooks for the equivalent surfaces and text; numeric sizing is not a fixed clipping height.\nKeep selected text/background and keyboard focus distinguishable when overriding colors.\n\nNative hooks are `style`, `listStyle`, `optionStyle`, `selectedStyle`, `labelStyle` and\n`descriptionStyle`. The typed `appearance` object controls `background`, `text`, `border`, `radius`,\n`optionPadding`, `gap`, `fontSize`, `descriptionColor`, `selectedBackground`, `selectedColor`, `focus`\nand `maxHeight`.\n\nItems contain a stable unique `value`, nonempty `label`, optional `description`, `icon` and `disabled`.\nGroups contain a nonempty `label` and nonempty `options`. Icon values are structured definitions from\nindividual `@joralvmel/cosmos-icons/<name>` imports, rendered decoratively by Cosmos Icon (ADR 0005).\nNo catalog import or icon-name registry is needed.\n\n## States\n\n**HTML / Web Component**\n\n```html\n<cosm-listbox label=\"Listbox\" selection-mode=\"multiple\" variant=\"outlined\" size=\"56\"></cosm-listbox>\n\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/listbox';\n const grouped = [{\"label\":\"Fruit\",\"options\":[{\"value\":\"apple\",\"label\":\"Apple\"},{\"value\":\"cherry\",\"label\":\"Cherry\",\"description\":\"Seasonal\"}]},{\"label\":\"Vegetables\",\"options\":[{\"value\":\"carrot\",\"label\":\"Carrot\"},{\"value\":\"broccoli\",\"label\":\"Broccoli\",\"disabled\":true}]}];\n const empty = [];\n\n const element = document.querySelector('cosm-listbox');\n element.items = grouped;\n element.selectedValues = empty;\n element.defaultSelectedValues = empty;\n element.addEventListener('cosm-selection-change', event => console.log(event.detail));\n</script>\n```\n\n**React**\n\n```tsx\nimport { Listbox } from '@joralvmel/cosmos-react';\nconst grouped = [{\"label\":\"Fruit\",\"options\":[{\"value\":\"apple\",\"label\":\"Apple\"},{\"value\":\"cherry\",\"label\":\"Cherry\",\"description\":\"Seasonal\"}]},{\"label\":\"Vegetables\",\"options\":[{\"value\":\"carrot\",\"label\":\"Carrot\"},{\"value\":\"broccoli\",\"label\":\"Broccoli\",\"disabled\":true}]}] as const;\nconst empty = [] as const;\n\nexport function Example() {\n return (\n <Listbox\n label=\"Listbox\"\n items={grouped}\n selectionMode=\"multiple\"\n selectedValues={empty}\n defaultSelectedValues={empty}\n variant=\"outlined\"\n size={56}\n onSelectionChange={event => console.log(event.detail)}\n >\n </Listbox>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmListboxComponent } from '@joralvmel/cosmos-angular';\nconst grouped = [{\"label\":\"Fruit\",\"options\":[{\"value\":\"apple\",\"label\":\"Apple\"},{\"value\":\"cherry\",\"label\":\"Cherry\",\"description\":\"Seasonal\"}]},{\"label\":\"Vegetables\",\"options\":[{\"value\":\"carrot\",\"label\":\"Carrot\"},{\"value\":\"broccoli\",\"label\":\"Broccoli\",\"disabled\":true}]}] as const;\nconst empty = [] as const;\nimport type { ListboxSelectionChangeDetail } from '@joralvmel/cosmos-core';\n\n@Component({\n selector: 'app-example',\n imports: [CosmListboxComponent],\n template: `<cosm-listbox label=\"Listbox\" [items]=\"grouped\" selectionMode=\"multiple\" [selectedValues]=\"empty\" [defaultSelectedValues]=\"empty\" variant=\"outlined\" [size]=\"56\" (selectionChange)=\"onSelectionChange($event.detail)\"></cosm-listbox>`,\n})\nexport class ExampleComponent {\n readonly grouped = grouped;\n readonly empty = empty;\n onSelectionChange(detail: ListboxSelectionChangeDetail) {\n console.log(detail);\n }\n}\n```\n\n**React Native**\n\n```tsx\nimport { Listbox } from '@joralvmel/cosmos-native';\nconst grouped = [{\"label\":\"Fruit\",\"options\":[{\"value\":\"apple\",\"label\":\"Apple\"},{\"value\":\"cherry\",\"label\":\"Cherry\",\"description\":\"Seasonal\"}]},{\"label\":\"Vegetables\",\"options\":[{\"value\":\"carrot\",\"label\":\"Carrot\"},{\"value\":\"broccoli\",\"label\":\"Broccoli\",\"disabled\":true}]}] as const;\nconst empty = [] as const;\n\nexport function Example() {\n return (\n <Listbox\n label=\"Listbox\"\n items={grouped}\n selectionMode=\"multiple\"\n selectedValues={empty}\n defaultSelectedValues={empty}\n variant=\"outlined\"\n size={56}\n onSelectionChange={detail => console.log(detail)}\n >\n </Listbox>\n );\n}\n```\n\nBoth selection modes use readonly string arrays: `[]`, `['home']`, or multiple values in multiple\nmode. Omit `selectedValues` for autonomous state initialized once from `defaultSelectedValues`.\nBind `selectedValues`, including `[]`, to control it. Proposals commit only when the owner updates\nthe bound value; later default changes do not reset an existing component. Repeated activation of\nan already selected single option does not emit a redundant change.\n\nReact/Angular handlers receive the original typed `CustomEvent`; read `event.detail.selectedValues`\nand explicitly assign accepted values. Native `onSelectionChange` receives the detail directly.\nAbsent collection keys are retained in selection; the component does not silently prune owner data.\nSingle mode rejects more than one selected value, and duplicate option values are invalid.\n\n`disabled` prevents interaction. `readOnly` permits exploring options without changing selection.\nIndividual disabled options cannot be activated and are skipped by keyboard navigation.\n\n## Accessibility\n\n- Supply a meaningful `label`; `labelHidden` hides it visually, not from accessibility APIs.\n- Web uses named listbox/option/group semantics, one Tab stop, visible roving focus and selected\n states. Up/Down, Home/End and typeahead move focus without changing selection. Enter/Space commits;\n multiple mode toggles without requiring modifier keys. Navigation stops at list boundaries.\n- Typeahead uses `locale`, otherwise inherited web language or the native runtime locale.\n Active options scroll into view. Group headings do not receive option focus.\n- Options support concise text, descriptions and decorative icons, **not nested buttons, links or\n interactive checkboxes**. See the [WAI-ARIA Listbox pattern](https://www.w3.org/WAI/ARIA/apg/patterns/listbox/).\n- React Native Web is validated separately from native. Android/iOS use touch and native accessible\n labels/selection/disabled states, not an assumed identical ARIA interaction model. Native hardware\n keyboard/D-pad navigation is deferred; iOS and manual screen-reader runs are not verified (optional).\n- Future Combobox input/option references must share a compatible tree. Reuse shared headless logic;\n do not point `aria-activedescendant` across private component shadow roots.\n- Filtering, asynchronous loading, virtualization, range/select-all shortcuts, loading/empty\n presentation and form submission/validation are outside this primitive's initial scope.\n\n## API\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `label` | string | Required | Required nonempty accessible label, visible unless labelHidden is true. |\n| `labelHidden` | boolean | `false` | Visually hides the label without removing its accessible name. |\n| `items` | ListboxItems | Required | Readonly collection of options or named groups. Options have globally unique nonempty value and label strings, optional description, decorative IconDefinition and disabled. Groups have a nonempty label and options array. |\n| `selectionMode` | 'single' \\| 'multiple' | `single` | Single permits at most one selected value; multiple toggles each activation. |\n| `selectedValues` | ListboxValues | — | Controlled selected values, including an empty array. Activation only proposes changes until the owner updates this prop. Missing collection values are retained, not automatically selected or removed. |\n| `defaultSelectedValues` | ListboxValues | — | Initial autonomous selected values (empty by default). Later changes do not reset selection. |\n| `variant` | 'plain' \\| 'outlined' | `plain` | Plain composes inside a panel; outlined adds a standalone container boundary. |\n| `size` | 'sm' \\| 'md' \\| 'lg' \\| number | `md` | Semantic size or a positive finite minimum option height in CSS pixels/native logical units. Content may grow; native touch targets remain at least 44. |\n| `disabled` | boolean | `false` | Prevents interaction and removes the list from keyboard navigation. |\n| `readOnly` | boolean | `false` | Allows exploring options without proposing or committing selection changes. |\n| `locale` | string | — | BCP 47 locale for typeahead. Web inherits the nearest language; native uses the runtime locale when omitted. Invalid locale identifiers are rejected. |\n\n**CSS parts**\n\n| Name | Description |\n| --- | --- |\n| `base` | Outer container. |\n| `label` | Visible or visually hidden accessible label. |\n| `list` | Scrollable listbox. |\n| `group` | Named option group. |\n| `group-label` | Noninteractive group heading. |\n| `option` | Selectable row; selected, disabled and active states are exposed on the row. |\n| `icon` | Decorative option icon. |\n| `content` | Text content wrapper. |\n| `option-label` | Primary option text. |\n| `description` | Optional supporting text. |\n| `indicator` | Decorative selected-state indicator. |\n\n**CSS custom properties**\n\n| Name | Description |\n| --- | --- |\n| `--cosm-listbox-background` | Container background. |\n| `--cosm-listbox-color` | Primary foreground. |\n| `--cosm-listbox-border` | Outlined container border color. |\n| `--cosm-listbox-radius` | Container and option corner radius. |\n| `--cosm-listbox-option-height` | Minimum option height. |\n| `--cosm-listbox-option-padding` | Option padding. |\n| `--cosm-listbox-gap` | Space between icon, content and selection indicator. |\n| `--cosm-listbox-font-size` | Primary option text size. |\n| `--cosm-listbox-description-color` | Supporting text color. |\n| `--cosm-listbox-selected-background` | Selected option background. |\n| `--cosm-listbox-selected-color` | Selected option foreground. |\n| `--cosm-listbox-focus` | Visible keyboard focus outline color. |\n| `--cosm-listbox-max-height` | Maximum scrollable list height. |\n\n**Keyboard**\n\n| Keys | Action |\n| --- | --- |\n| `Tab`, `Shift+Tab` | Enters or leaves the list as one Tab stop. |\n| `ArrowDown`, `ArrowUp`, `Home`, `End` | Moves focus among enabled options without changing selection; stops at the ends. |\n| `Enter`, `Space` | Selects the focused option; multiple mode toggles it. Read-only never changes selection. |\n| `Printable characters` | Moves focus to a matching option using locale-aware typeahead without filtering. |\n\n## Events by platform\n\n| DOM | React | Angular | React Native | Detail | Description |\n| --- | --- | --- | --- | --- | --- |\n| `cosm-selection-change` | `onSelectionChange` | `(selectionChange)` | `onSelectionChange` | `ListboxSelectionChangeDetail` | Proposes the next selectedValues for an enabled activation. Autonomous selection commits; controlled selection waits for the owner. Arrows and typeahead never select. |\n"},{"slug":"components/popover","title":"Popover","markdown":"# Popover\n\n> Non-modal content anchored to a consumer-supplied trigger.\n\nStatus: **stable** (web, react, angular, native).\n\nPopover displays content next to a trigger without blocking the rest of the interface. Use it for\nsupplementary information or actions; it does not implement a menu, tooltip or modal dialog.\n\n## Playground\n\n**HTML / Web Component**\n\n```html\n<cosm-popover><cosm-icon-button slot=\"trigger\" label=\"Details\" variant=\"ghost\" tone=\"neutral\"><cosm-icon></cosm-icon></cosm-icon-button>Additional information.</cosm-popover>\n\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/popover';\n import { info } from '@joralvmel/cosmos-icons/info';\n document.querySelector('cosm-popover [slot=\"trigger\"] cosm-icon').icon = info;\n\n const element = document.querySelector('cosm-popover');\n element.addEventListener('cosm-open-change', event => console.log(event.detail));\n</script>\n```\n\n**React**\n\n```tsx\nimport { Popover, IconButton, Icon } from '@joralvmel/cosmos-react';\nimport { info } from '@joralvmel/cosmos-icons/info';\n\nexport function Example() {\n return (\n <Popover\n onOpenChange={event => console.log(event.detail)}\n >\n <IconButton slot=\"trigger\" label=\"Details\" variant=\"ghost\" tone=\"neutral\"><Icon icon={info} /></IconButton>\n Additional information.\n </Popover>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmPopoverComponent, CosmIconButtonComponent, CosmIconComponent } from '@joralvmel/cosmos-angular';\nimport { info } from '@joralvmel/cosmos-icons/info';\nimport type { PopoverOpenChangeDetail } from '@joralvmel/cosmos-core';\n\n@Component({\n selector: 'app-example',\n imports: [CosmPopoverComponent, CosmIconButtonComponent, CosmIconComponent],\n template: `<cosm-popover (openChange)=\"onOpenChange($event.detail)\"><cosm-icon-button slot=\"trigger\" label=\"Details\" variant=\"ghost\" tone=\"neutral\"><cosm-icon [icon]=\"info\" /></cosm-icon-button>Additional information.</cosm-popover>`,\n})\nexport class ExampleComponent {\n readonly info = info;\n onOpenChange(detail: PopoverOpenChangeDetail) {\n console.log(detail);\n }\n}\n```\n\n**React Native**\n\n```tsx\nimport { Popover, PopoverProvider, IconButton, Icon } from '@joralvmel/cosmos-native';\nimport { info } from '@joralvmel/cosmos-icons/info';\nimport { Text } from 'react-native';\n\nexport function Example() {\n return (\n <PopoverProvider>\n <Popover\n trigger={props => <IconButton {...props} label=\"Details\" variant=\"ghost\" tone=\"neutral\"><Icon icon={info} /></IconButton>}\n onOpenChange={detail => console.log(detail)}\n >\n <Text>Additional information.</Text>\n </Popover>\n </PopoverProvider>\n );\n}\n```\n\nTry `closable`, `arrow`, `gap` (including zero), `triggerMode`, side, alignment and dismissal.\nThe trigger is the library's IconButton with an individual information icon.\nChoose autonomous or controlled open\nstate to see the difference: a controlled value changes only when its owner accepts a proposal.\nChanging `defaultOpen` remounts the preview to demonstrate its initial value. The native demo link\nopens the corresponding example screen.\n\nOn React Native, wrap the app in `PopoverProvider` and supply safe-area insets when available.\n`trigger` accepts content inside the built-in accessible button or a render function for composing\nan IconButton without nesting interactive controls (see the generated native example). Pass\n`usePopoverHost().onScroll` to scroll containers that can move a trigger, composing it with any\nexisting scroll handler. Native `onOpenChange` receives the detail directly; use a ref to call\n`requestClose()` from a panel action.\n\n## Variants\n\nPopover has one neutral surface, sized to its content. Theme tokens and panel styling hooks allow\ncustomization; its trigger and content are supplied by the consumer.\n\n**HTML / Web Component**\n\n```html\n<cosm-popover trigger-mode=\"hover\" closable gap=\"24\" arrow><cosm-icon-button slot=\"trigger\" label=\"Details\" variant=\"ghost\" tone=\"neutral\"><cosm-icon></cosm-icon></cosm-icon-button>Additional information.</cosm-popover>\n\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/popover';\n import { info } from '@joralvmel/cosmos-icons/info';\n document.querySelector('cosm-popover [slot=\"trigger\"] cosm-icon').icon = info;\n\n const element = document.querySelector('cosm-popover');\n element.addEventListener('cosm-open-change', event => console.log(event.detail));\n</script>\n```\n\n**React**\n\n```tsx\nimport { Popover, IconButton, Icon } from '@joralvmel/cosmos-react';\nimport { info } from '@joralvmel/cosmos-icons/info';\n\nexport function Example() {\n return (\n <Popover\n triggerMode=\"hover\"\n closable\n gap={24}\n arrow\n onOpenChange={event => console.log(event.detail)}\n >\n <IconButton slot=\"trigger\" label=\"Details\" variant=\"ghost\" tone=\"neutral\"><Icon icon={info} /></IconButton>\n Additional information.\n </Popover>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmPopoverComponent, CosmIconButtonComponent, CosmIconComponent } from '@joralvmel/cosmos-angular';\nimport { info } from '@joralvmel/cosmos-icons/info';\nimport type { PopoverOpenChangeDetail } from '@joralvmel/cosmos-core';\n\n@Component({\n selector: 'app-example',\n imports: [CosmPopoverComponent, CosmIconButtonComponent, CosmIconComponent],\n template: `<cosm-popover triggerMode=\"hover\" closable [gap]=\"24\" arrow (openChange)=\"onOpenChange($event.detail)\"><cosm-icon-button slot=\"trigger\" label=\"Details\" variant=\"ghost\" tone=\"neutral\"><cosm-icon [icon]=\"info\" /></cosm-icon-button>Additional information.</cosm-popover>`,\n})\nexport class ExampleComponent {\n readonly info = info;\n onOpenChange(detail: PopoverOpenChangeDetail) {\n console.log(detail);\n }\n}\n```\n\n**React Native**\n\n```tsx\nimport { Popover, PopoverProvider, IconButton, Icon } from '@joralvmel/cosmos-native';\nimport { info } from '@joralvmel/cosmos-icons/info';\nimport { Text } from 'react-native';\n\nexport function Example() {\n return (\n <PopoverProvider>\n <Popover\n trigger={props => <IconButton {...props} label=\"Details\" variant=\"ghost\" tone=\"neutral\"><Icon icon={info} /></IconButton>}\n triggerMode=\"hover\"\n closable\n gap={24}\n arrow\n onOpenChange={detail => console.log(detail)}\n >\n <Text>Additional information.</Text>\n </Popover>\n </PopoverProvider>\n );\n}\n```\n\n`closable` adds a neutral ghost IconButton with an X. Localize its `closeLabel`; activating it\nproposes reason `close-button` and respects cancellation and controlled state.\n\n`gap` defaults to 8 CSS pixels (native logical units). Zero joins the surfaces. With `arrow`,\nthe distance is measured to the tip, not the panel edge. The decorative 16-by-8 pointer follows\nthe actual side and trigger center after flip/shift; it is hidden when it cannot point without\ncrossing a corner or viewport edge. Collision handling takes priority over the requested gap.\n\nCustomize background, text and border via theme tokens or `cosm-popover::part(panel)`. The arrow\nfollows the panel background and border. Native uses `panelStyle`; style consumer text directly.\nHeading, links and action layouts remain consumer content, not special Popover properties.\n\n## States\n\nOmit `open` for autonomous state and use `defaultOpen` for its initial value. Bind `open`,\nincluding `false`, to control it. An open-change event proposes a value; assigning the accepted\nvalue commits it. Close requests are cancelable. Panel actions can request closure through\n`requestClose()`; this does not override a controlled owner.\n\nThe requested side and alignment can adapt when there is insufficient space. Outside press, and\nEscape on web and React Native Web, close by default and can be disabled. Outside interaction is\nnot consumed. On Android, Back requests closure while the panel is open. Hardware Escape is not\nsupported on native Android or iOS.\n\nOn browsers with the Popover API, the panel uses the top layer. The fixed-position fallback in\nolder browsers can be clipped or displaced by ancestor overflow, transforms or containment.\n\n`triggerMode=\"hover\"` adds pointer and keyboard-focus opening on web, React, Angular and React\nNative Web; press activation remains available. Android/iOS use press instead. Pointer or focus\nwithin the trigger/panel keeps it open, including pointer travel across the gap. Leaving both\nrequests closure after 150ms. Escape or the X dismisses without immediate reopening until both\npointer and focus leave. Hover/focus opening never moves focus into the panel, even with\n`initialFocus`. The mode does not turn the content into a tooltip.\n\n## Accessibility\n\n- Supply a keyboard-operable, named trigger and semantics and a label appropriate to the content.\n Popover does not impose a role or modal behavior.\n- Focus is not trapped. Initial focus stays on the trigger unless `initialFocus` is enabled.\n Focus restoration depends on the close reason and does not steal focus from an outside target.\n- The consumer is responsible for making the trigger and panel controls accessible and for\n providing appropriate touch target sizes on native.\n- Hover content must remain dismissible, hoverable and persistent\n ([WCAG 1.4.13](https://www.w3.org/WAI/WCAG22/Understanding/content-on-hover-or-focus.html)).\n Keep Escape enabled in hover mode when the panel can obscure meaningful content.\n\n## API\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `open` | boolean | `false` | Committed visibility. Supplying this prop, including false, controls state; its metadata default does not establish a binding. |\n| `defaultOpen` | boolean | `false` | Initial autonomous visibility only; ignored when open is supplied. Later updates do not reset state. |\n| `triggerMode` | 'press' \\| 'hover' | `press` | Hover adds pointer and keyboard-focus opening on web and React Native Web, while keeping press activation. Android/iOS use press. Does not change panel semantics. |\n| `closable` | boolean | `false` | Shows a built-in IconButton with an X. Requests a cancelable close with reason close-button. |\n| `closeLabel` | string | `Close` | Localized accessible name of the close button. Must be non-empty when closable is true. |\n| `gap` | number | `8` | Non-negative finite distance from trigger to panel, or to the arrow tip. CSS pixels on web, logical units on native. Viewport/safe-area collision handling takes priority. |\n| `arrow` | boolean | `false` | Shows a decorative triangular pointer (16 wide, 8 deep), following the actual side, panel background and border. Hidden if it cannot point to the trigger without crossing a corner or viewport edge. |\n| `closeOnEscape` | boolean | `true` | Requests closure on unhandled Escape on web and React Native Web. Native Android and iOS hardware Escape is not supported. |\n| `closeOnOutsidePress` | boolean | `true` | Requests closure on an outside press without preventing its interaction or restoring trigger focus. |\n| `initialFocus` | boolean | `false` | On committed opening (including initially open), focus the first focusable panel descendant, falling back to the panel without adding semantics. False leaves focus unchanged. Native moves accessible/input focus where supported. |\n| `restoreFocus` | boolean | `true` | After committed trigger, Escape, action or Back closure, restore focus only if still inside the panel and the trigger is connected and focusable. Never steal outside focus, restore after outside press, or restore for unsolicited prop closure. |\n| `side` | 'top' \\| 'right' \\| 'bottom' \\| 'left' | `bottom` | Requested physical side; actual placement may flip. Recompute for trigger/panel size, viewport/safe-area, scrolling and orientation changes. |\n| `align` | 'start' \\| 'center' \\| 'end' | `center` | Cross-axis alignment. On top/bottom, start/end follow inline direction (RTL reverses them); on left/right they mean top/bottom. |\n| `flip` | boolean | `true` | Try the opposite side when the requested side overflows the available viewport/safe area; flip only if it reduces main-axis overflow. Ties keep the requested side. Runs before shift. |\n| `shift` | boolean | `true` | After flip, translate within available viewport/safe-area bounds to reduce overflow. Constrain oversized panels to that region regardless of collision flags; flags never change requested props. |\n\n**Slots**\n\n| Name | Description |\n| --- | --- |\n| `trigger` | Consumer-supplied accessible trigger; its appearance and label belong to the consumer. Native accepts content or a render function receiving onPress, ref and accessibilityState for composing an IconButton without nested buttons. |\n| `(default)` | Consumer-supplied panel content and semantics. Native maps this content to children. |\n\n**CSS parts**\n\n| Name | Description |\n| --- | --- |\n| `trigger` | Trigger container. |\n| `panel` | Non-modal anchored surface. |\n| `body` | Scrollable consumer content. |\n| `close` | Optional close IconButton. |\n| `arrow` | Decorative pointer; follows panel colors. |\n\n**CSS custom properties**\n\n| Name | Description |\n| --- | --- |\n| `--cosm-popover-z-index` | Panel stacking level. |\n| `--cosm-popover-padding` | Panel padding. |\n| `--cosm-popover-radius` | Panel corner radius. |\n| `--cosm-popover-shadow` | Panel shadow. |\n\n**Keyboard**\n\n| Keys | Action |\n| --- | --- |\n| `Enter`, `Space` | The focused trigger activates once and toggles open. |\n| `Escape` | On web and React Native Web, requests close when open and closeOnEscape is true, unless a child already handled the key. |\n| `Tab`, `Shift+Tab` | Moves focus normally without a focus trap or automatic dismissal. |\n| `Android Back` | Requests close while open on Android only. |\n\n## Events by platform\n\n| DOM | React | Angular | React Native | Detail | Description |\n| --- | --- | --- | --- | --- | --- |\n| `cosm-open-change` | `onOpenChange` | `(openChange)` | `onOpenChange` | `PopoverOpenChangeDetail` | Proposes visibility changes by trigger, hover or focus, or closure by Escape, outside press, panel action, close button or Android Back. Closing only is cancelable, synchronously via the web event or detail.preventDefault(); native uses detail.preventDefault(). Not a committed-state notification. (cancelable) |\n"},{"slug":"components/status","title":"Component status","markdown":"# Component status\n\n> Inventory of every planned Cosmos component, with what exists on each platform.\n\nThis page is generated from the repository on every build: the canonical list lives in\n`packages/core/src/catalog.ts` and `npm run status` detects which pieces exist for each component\n(contract, scenarios, each platform, tests, docs, AI reference and changeset).\n\n- **Stable**: every piece exists for every platform of the component.\n- **In progress**: some pieces exist.\n- **Planned**: nothing exists yet. A planned component can start when its dependencies are stable.\n\n6 stable · 0 in progress · 32 planned (38 total)\n\nNext: `badge`, `avatar`, `divider`, `calendar`, `textarea`\n\n| Component | Status | Priority | Contract | Scenarios | Web Component | React | Angular | React Native | Native demo | Tests | Docs (EN) | Docs (ES) | llms.md | Changeset | Depends on |\n| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |\n| button | stable | 1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | — |\n| icon | stable | 1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | — |\n| icon-button | stable | 2 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | button, icon |\n| badge | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| spinner | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| avatar | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| divider | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| listbox | stable | 1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | icon |\n| calendar | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | button |\n| text-field | stable | 1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | icon, icon-button |\n| textarea | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| checkbox | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon |\n| radio-group | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| switch | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| number-field | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | text-field, icon-button |\n| select | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | popover, listbox, icon |\n| combobox | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | popover, listbox, text-field |\n| multi-select | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | popover, listbox, badge, checkbox |\n| slider | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| popover | stable | 1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | icon-button, icon |\n| tooltip | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | popover |\n| dialog | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | button, icon-button |\n| drawer | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | dialog |\n| toast | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon, icon-button |\n| menu | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | popover |\n| split-button | planned | 3 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | button, menu |\n| tabs | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| accordion | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon |\n| pagination | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | button, icon-button |\n| steps | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon |\n| breadcrumb | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon |\n| card | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| table | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | checkbox, pagination, icon-button |\n| date-picker | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | popover, calendar, text-field |\n| date-range-picker | planned | 3 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | date-picker |\n| bottom-sheet | planned | 3 | ✗ | ✗ | — | — | — | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| skeleton | planned | 3 | ✗ | ✗ | — | — | — | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| list-item | planned | 3 | ✗ | ✗ | — | — | — | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | icon |\n\nRun it locally:\n\n```bash\nnpm run status # table\nnpm run status -- --markdown\nnpm run status -- --json\n```\n"},{"slug":"components/text-field","title":"Text Field","markdown":"# Text Field\n\n> A labeled single-line text input with browser-native validation and form behavior.\n\nStatus: **stable** (web, react, angular, native).\n\n`<cosm-text-field>` is a labeled, single-line text-entry control. Use it for text, email, password,\ntelephone, URL and search input. It supports browser constraints and web form association; use a\nseparate number field or textarea for numeric or multiline editing.\n\n## Playground\n\nUse the dropdowns for type, variant, size, keyboard hint and a few sample icons, and the checkboxes\nfor boolean features. Less common form, content and action-label settings are under **Advanced\noptions**; the complete API remains below. The icon catalog is available on the Icon page rather\nthan loaded into this playground.\n\nText-valued properties use an independent text editor: edits update the preview and generated\nsnippets while keeping the editor separate from the preview.\n\nFor digit entry, choose `text` and `inputMode=\"numeric\"`; this requests a numeric keyboard, not\nnumeric validation or filtering. Use web `pattern` or consumer-owned validation when appropriate.\nThe example below lets you accept or reject a controlled value proposal:\n\n**HTML / Web Component**\n\n```html\n<cosm-text-field label=\"TextField\"></cosm-text-field>\n\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/text-field';\n import { search } from '@joralvmel/cosmos-icons/search';\n\n const element = document.querySelector('cosm-text-field');\n element.startIcon = search;\n element.endIcon = search;\n element.addEventListener('cosm-change', event => console.log(event.detail));\n element.addEventListener('cosm-submit', event => console.log(event.detail));\n</script>\n```\n\n**React**\n\n```tsx\nimport { TextField } from '@joralvmel/cosmos-react';\nimport { search } from '@joralvmel/cosmos-icons/search';\n\nexport function Example() {\n return (\n <TextField\n label=\"TextField\"\n startIcon={search}\n endIcon={search}\n onChange={event => console.log(event.detail)}\n onSubmit={event => console.log(event.detail)}\n >\n </TextField>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmTextFieldComponent } from '@joralvmel/cosmos-angular';\nimport { search } from '@joralvmel/cosmos-icons/search';\nimport type { TextFieldChangeDetail, TextFieldSubmitDetail } from '@joralvmel/cosmos-core';\n\n@Component({\n selector: 'app-example',\n imports: [CosmTextFieldComponent],\n template: `<cosm-text-field label=\"TextField\" [startIcon]=\"search\" [endIcon]=\"search\" (valueChange)=\"onValueChange($event.detail)\" (submit)=\"onSubmit($event.detail)\"></cosm-text-field>`,\n})\nexport class ExampleComponent {\n readonly search = search;\n onValueChange(detail: TextFieldChangeDetail) {\n console.log(detail);\n }\n\n onSubmit(detail: TextFieldSubmitDetail) {\n console.log(detail);\n }\n}\n```\n\n**React Native**\n\n```tsx\nimport { TextField } from '@joralvmel/cosmos-native';\nimport { search } from '@joralvmel/cosmos-icons/search';\n\nexport function Example() {\n return (\n <TextField\n label=\"TextField\"\n startIcon={search}\n endIcon={search}\n onValueChange={detail => console.log(detail)}\n onSubmitEditing={detail => console.log(detail)}\n >\n </TextField>\n );\n}\n```\n\n<TextFieldOwnershipDemo\n label=\"Account name\"\n value=\"Cosmos\"\n clearLabel=\"Clear account name\"\n acceptLabel=\"Accept\"\n rejectLabel=\"Reject\"\n pendingMessage=\"A value proposal is waiting for your decision.\"\n acceptedMessage=\"Proposal accepted.\"\n rejectedMessage=\"Proposal rejected; the previous value remains.\"\n/>\n\n## Variants\n\n`outlined` is the default. `filled` changes only the control surface; semantic sizes are `sm`, `md`\nand `lg`. A positive finite numeric `size` sets a minimum editable-control height in CSS pixels.\nLabel and supporting text remain outside that height.\n\nOn web the field defaults to `20ch`, capped at its container width. Override CSS `width` (for example\n`width: 100%`) for your layout. Clear/reveal actions and decorations consume space inside that width\ninstead of expanding it.\n\n```html\n<cosm-text-field label=\"Outlined\" placeholder=\"name@example.com\"></cosm-text-field>\n<cosm-text-field label=\"Filled\" variant=\"filled\" placeholder=\"name@example.com\"></cosm-text-field>\n```\n\n```html\n<cosm-text-field label=\"Small\" size=\"sm\"></cosm-text-field>\n<cosm-text-field label=\"Medium\" size=\"md\"></cosm-text-field>\n<cosm-text-field label=\"Large\" size=\"lg\"></cosm-text-field>\n<cosm-text-field label=\"Custom minimum height\" size=\"56\"></cosm-text-field>\n```\n\n## States\n\nHelp and external error text are associated with the input. `required`, `type`, `pattern`,\n`minLength` and `maxLength` use browser-native validity on web. A custom error or `invalid` state is\nconsumer-owned and is not inferred from business rules.\n\n```html\n<cosm-text-field label=\"Email\" type=\"email\" required help-text=\"Use your work email.\"></cosm-text-field>\n<cosm-text-field label=\"Invalid account\" value=\"taken\" error=\"That name is unavailable.\" invalid></cosm-text-field>\n<cosm-text-field\n label=\"Password\"\n type=\"password\"\n password-reveal\n reveal-password-label=\"Show password\"\n hide-password-label=\"Hide password\"\n value=\"sample secret\"\n></cosm-text-field>\n<cosm-text-field label=\"Search\" prefix=\"In\" suffix=\"All records\" clearable clear-label=\"Clear search\"></cosm-text-field>\n<cosm-text-field label=\"Read-only\" value=\"Cannot edit\" read-only></cosm-text-field>\n<cosm-text-field label=\"Disabled\" value=\"Unavailable\" disabled></cosm-text-field>\n```\n\nStructured `startIcon` and `endIcon` values are consumer-provided `IconDefinition`s; there is no\nglobal icon-name registry. Select icons in the playground, or pass the definition as a property.\nClear and password-reveal actions use local native buttons. Supply localized `clearLabel`, and both\n`revealPasswordLabel` and `hidePasswordLabel`, whenever those actions are enabled. Actions are\nhidden while disabled or read-only.\n\nPassword visibility resets when the field becomes disabled/read-only, reveal is turned off, or\nthe type changes away from password. Re-enabling the feature starts concealed. Web disabled\nfieldsets follow the same rule.\n\nLong labels and messages wrap. Prefixes and suffixes are single-line decorations that truncate\nwhen space is limited, preserving room for editing. In web search fields, enabling `clearable`\nreplaces the browser's built-in clear affordance instead of showing two clear buttons.\n\nOn web, the custom element is form-associated: it submits `name` and `value`, follows disabled\nfieldsets, supports reset/state restoration, and exposes browser-native validity. An autonomous\nreset returns to `defaultValue`; a controlled reset emits a proposal and waits for its owner.\nAngular integrates with `ControlValueAccessor`, including touched state, reset, disabled state and\n`updateOn: 'blur'`. Native does not emulate HTML form submission, email validation or regex\nvalidation; its consumer owns business validation and submit handling.\n\n## Icon colors\n\nThe field already renders the shared Icon component. Configure each decorative icon independently\nwithout changing input text, affixes, clear or reveal icons. Unset hooks preserve the current theme.\nA focus color is opt-in and falls back to the same icon's normal color when omitted.\n\n<TextFieldIconColorsDemo />\n\nHTML, React and Angular share these CSS hooks:\n\n```css\n.colored-icons {\n --cosm-text-field-start-icon-color: var(--cosm-success-text);\n --cosm-text-field-start-icon-focus-color: var(--cosm-primary-text);\n --cosm-text-field-end-icon-color: var(--cosm-danger-text);\n --cosm-text-field-end-icon-focus-color: var(--cosm-warning-text);\n}\n```\n\nKeep passing `startIcon` and `endIcon` definitions as usual. For example, with the shared CSS above:\n\n```html\n<cosm-text-field class=\"colored-icons\" label=\"Search\" icon-focus-scope=\"input\"></cosm-text-field>\n```\n\n```tsx\n<TextField className=\"colored-icons\" label=\"Search\"\n startIcon={search} endIcon={heart} iconFocusScope=\"input\" />\n```\n\n```html\n<cosm-text-field class=\"colored-icons\" label=\"Search\"\n [startIcon]=\"search\" [endIcon]=\"heart\" iconFocusScope=\"input\"></cosm-text-field>\n```\n\nReact Native uses the same four hooks in `appearance`, with native theme colors rather than CSS:\n\n```tsx\n<TextField label=\"Search\" startIcon={search} endIcon={heart} iconFocusScope=\"input\"\n appearance={{\n startIconColor: theme.colors['success-text'],\n startIconFocusColor: theme.colors['primary-text'],\n endIconColor: theme.colors['danger-text'],\n endIconFocusColor: theme.colors['warning-text'],\n }} />\n```\n\n`iconFocusScope=\"control\"` (default) includes the editable input and its clear/reveal buttons;\n`\"input\"` applies the configured focus colors only while the editable input is focused. Without a\nfocus-color hook, neither scope changes the icon color. No additional event handlers are needed.\nCustom colors remain the consumer's contrast responsibility; forced-colors mode may replace them\nwith system colors. Native accessibility focus is not keyboard/input focus.\n\n## Accessibility\n\n- Always provide a meaningful `label`. `labelHidden` visually hides it without removing its\n association with the editable input.\n- Placeholder text is only a hint, never a label. Help and error text use `aria-describedby`, and\n invalid/required states are exposed on the input.\n- Clear/reveal controls have localized accessible names, visible focus indication and native button\n keyboard behavior. They are unavailable in disabled or read-only states.\n- Web focus retains a single inward indicator in forced-colors mode, using the system highlight\n color rather than relying on a box shadow.\n- React Native Web also draws focus on the outer control, without a second browser outline\n around the editable input.\n- Decorative icons do not receive independent pointer or keyboard focus. Native reserves at\n least 44 units of editable width; long affixes shrink before taking that space from the input.\n- The editable input remains keyboard-operable; Enter reports `cosm-submit` and web form submission\n continues through the containing form.\n- Decorations follow logical inline direction for RTL. Font scaling may grow the control beyond a\n custom minimum height; content is not clipped.\n- React Native 0.88 exposes no native accessibility states for required or invalid. On native,\n include localized required wording in the existing label or help text and provide explicit error\n text for invalid fields. Hints may be disabled; error text is readable and is an Android live\n region, but TalkBack/VoiceOver behavior is not verified here. Do not assume semantic parity across\n devices.\n\nThe stable inventory status records implementation readiness with explicitly deferred validation:\niOS/VoiceOver, desktop screen readers, axe, full TalkBack state/error coverage and non-Latin/web\nIME composition remain unverified. Representative Android TalkBack output, Latin Gboard candidate\ninput and 200% Android text scaling have been checked; they do not certify the other environments.\n\n## API\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `label` | string | Required | Accessible name for the editable control. It is rendered above the control unless visually hidden. |\n| `labelHidden` | boolean | `false` | Visually hides the label while keeping it available to assistive technology. |\n| `value` | string | — | Current text. When bound, edits are proposals and the component waits for the owner to supply the accepted value. |\n| `defaultValue` | string | `` | Initial value for autonomous use. Web form reset restores this value; it does not control subsequent edits. |\n| `type` | 'text' \\| 'email' \\| 'password' \\| 'tel' \\| 'url' \\| 'search' | `text` | Single-line input type. Native maps it to supported keyboard, autofill and secure-entry behavior. |\n| `variant` | 'outlined' \\| 'filled' | `outlined` | Visual treatment of the editable control. |\n| `size` | 'sm' \\| 'md' \\| 'lg' \\| number | `md` | Semantic size or a positive finite minimum editable-control height in CSS pixels on web and logical units on native. |\n| `placeholder` | string | — | Short input hint; it never replaces the accessible label. |\n| `helpText` | string | — | Optional supporting text associated with the editable control. |\n| `error` | string | — | Optional externally supplied error text associated with the editable control. |\n| `invalid` | boolean | `false` | External invalid state, independent of browser constraints or consumer business validation. |\n| `required` | boolean | `false` | Exposes required semantics. On web, participates in native HTML constraint validation. |\n| `disabled` | boolean | `false` | Disables editing and interaction. On web, follows disabled fieldsets and excludes the value from form submission. |\n| `readOnly` | boolean | `false` | Prevents editing while remaining focusable and form-submittable on web; distinct from disabled. |\n| `minLength` | number | — | Minimum number of characters. Web uses native HTML validity; native business validation remains the consumer’s responsibility. |\n| `maxLength` | number | — | Maximum number of characters. Web uses native HTML validity and native applies supported input limits. |\n| `pattern` | string | — | Web-only HTML pattern constraint. Native does not emulate HTML regular-expression validation. |\n| `name` | string | — | Form field name on web. React Native has no HTML form association or name-based submission. |\n| `autoComplete` | string | — | Consumer-provided completion/autofill hint, mapped to attributes supported by each platform. |\n| `inputMode` | 'none' \\| 'text' \\| 'decimal' \\| 'numeric' \\| 'tel' \\| 'search' \\| 'email' \\| 'url' | — | Input or keyboard hint (none, text, decimal, numeric, tel, search, email or url); it does not add numeric or multiline field behavior. |\n| `startIcon` | IconDefinition | — | Optional structured decorative icon before the editable text. |\n| `endIcon` | IconDefinition | — | Optional structured decorative icon after the editable text. |\n| `iconFocusScope` | 'control' \\| 'input' | `control` | When configured icon focus colors apply: control includes the input and clear/reveal buttons; input includes only the editable input. Does not change icons without a focus-color override. |\n| `prefix` | string | — | Optional non-interactive text decoration before the editable text. |\n| `suffix` | string | — | Optional non-interactive text decoration after the editable text. |\n| `clearable` | boolean | `false` | Shows a clear action for non-empty editable fields. Supply clearLabel when enabled. |\n| `clearLabel` | string | — | Consumer-supplied localized accessible name for the clear action. |\n| `passwordReveal` | boolean | `false` | Opts into a reveal action for password fields. Supply both revealPasswordLabel and hidePasswordLabel when enabled. |\n| `revealPasswordLabel` | string | — | Consumer-supplied localized accessible name while the password is concealed. |\n| `hidePasswordLabel` | string | — | Consumer-supplied localized accessible name while the password is revealed. |\n\n**CSS parts**\n\n| Name | Description |\n| --- | --- |\n| `label` | Accessible label above the control. |\n| `control` | Visual control containing the editable input and decorations. |\n| `input` | The single-line editable input. |\n| `start` | Start icon or prefix decoration. |\n| `end` | End icon, suffix decoration or clear/reveal action. |\n| `help` | Supporting text associated with the editable input. |\n| `error` | External or native-validity error text associated with the editable input. |\n| `clear-button` | Optional accessible clear action. |\n| `reveal-button` | Optional accessible password visibility action. |\n\n**CSS custom properties**\n\n| Name | Description |\n| --- | --- |\n| `--cosm-text-field-background` | Editable control background. |\n| `--cosm-text-field-color` | Editable and decoration text color. |\n| `--cosm-text-field-placeholder` | Placeholder text color. |\n| `--cosm-text-field-border` | Editable control boundary color. |\n| `--cosm-text-field-focus` | Visible focus indicator color. |\n| `--cosm-text-field-radius` | Editable control corner radius. |\n| `--cosm-text-field-start-icon-color` | Start icon color, independent of text and affixes. |\n| `--cosm-text-field-start-icon-focus-color` | Start icon color within iconFocusScope; falls back to its normal color. |\n| `--cosm-text-field-end-icon-color` | End icon color, independent of text and affixes. |\n| `--cosm-text-field-end-icon-focus-color` | End icon color within iconFocusScope; falls back to its normal color. |\n\n**Keyboard**\n\n| Keys | Action |\n| --- | --- |\n| `Tab`, `Shift+Tab` | Moves focus to or from the enabled editable control. |\n| `Enter` | Invokes the submit action; web form behavior remains native. |\n\n## Events by platform\n\n`cosm-change` proposes `{ value }` for each edit or clear. An unbound field commits autonomously;\nwhen `value` is bound (including `''`), the owner accepts the proposal by updating the property.\nRejected proposals restore the controlled text without discarding the caret or an active IME\ncomposition. Password reveal changes presentation only.\n\n`cosm-submit` reports `{ value }` when Enter invokes the submit action. React and Angular receive the\noriginal bubbling, composed `CustomEvent`; React Native receives the detail through its callback.\n\n| DOM | React | Angular | React Native | Detail | Description |\n| --- | --- | --- | --- | --- | --- |\n| `cosm-change` | `onChange` | `(valueChange)` | `onValueChange` | `TextFieldChangeDetail` | Proposes the current text after each user edit, including clear; this is not a blur/commit event. |\n| `cosm-submit` | `onSubmit` | `(submit)` | `onSubmitEditing` | `TextFieldSubmitDetail` | Reports the current text when the user invokes the field submit action (Enter/return). |\n"},{"slug":"contribute/example-switch","title":"Example: from issue to release","markdown":"# Example: from issue to release\n\n> A complete walkthrough that creates the cosm-switch component with the agents and skills, from the issue to the npm release.\n\nThis walkthrough adds `cosm-switch` (WAI-ARIA switch) on every platform. Each step names the skill to\nrun (as a `/prompt` in VS Code or by asking the agent) and shows the commands it runs and the expected\noutput.\n\n## 1. Check the inventory — `component-status`\n\n```bash\nnpm run status\n```\n\n```text\nComponents: 38 · stable 1 · in progress 0 · planned 37\n…\nplanned 1 switch\n…\nNext suggested: icon, badge, avatar, divider, listbox\n```\n\n`switch` is planned, priority 1 and has no dependencies, so it can start now.\n\n## 2. Issue and branch — `start-work`\n\n```bash\ngit fetch origin\ngit switch develop\ngit pull --ff-only\ngit switch -c feat/elements-switch\n```\n\n```text\nSwitched to a new branch 'feat/elements-switch'\n```\n\nAn optional existing issue (for example #12) is linked in the eventual PR. The work branch stays\nlocal until the implementation review is accepted.\n\n## 3. Research — `research-reference`\n\nThe `researcher` agent summarizes the\n[APG switch pattern](https://www.w3.org/WAI/ARIA/apg/patterns/switch/): role `switch`,\n`aria-checked`, <kbd>Space</kbd> toggles, visible label, and recommends a native\n`<input type=\"checkbox\" role=\"switch\">` inside the Web Component (form participation for free).\n\nIt also compares public implementations and returns required behavior separately from suggested\nsizes, states and customization. The main chat asks what to include or defer, presents tradeoffs\nand summarizes the proposed scope and web/native acceptance scenarios. **It waits for your scope\nand design approval before generating files or editing the contract.**\n\n## 4. Accepted API plan — `define-contract`\n\nAfter acceptance, `architect` outlines the contract (for example props `checked`, `disabled`,\n`required`, `name`, `value`, `label`; event `change` → DOM `cosm-change`, React `onChange`, Angular\n`(checkedChange)`, React Native `onCheckedChange`; state `checked` with `defaultChecked`) and the shared\nscenarios (toggle by pointer and keyboard, disabled, controlled proposal without commit). These are\nillustrative decisions, not a feature list to assume. The contract files are finalized after the\nscaffold in step 6 and before platform behavior.\n\n## 5. Visual spec — `design-component`\n\nThe `design-system` agent writes `docs/design/switch.md`: track and thumb sizes per `size`, states\n(hover, focus-visible, checked, disabled, invalid), tokens (`--cosm-primary`, `--cosm-border-strong`,\n`--cosm-surface`), motion with `prefers-reduced-motion`, and checks contrast in every theme.\n\n## 6. Generate — `create-component`\n\n```bash\nnpm run generate -- component switch\n```\n\n```text\nWrote 21 files:\n packages/core/src/specs/switch.ts\n packages/core/src/specs/switch.scenarios.ts\n packages/core/src/index.ts\n packages/elements/src/components/switch/cosm-switch.ts\n …\n apps/docs/src/content/docs/es/components/switch.mdx\n .changeset/add-switch.md\n\nNext: resolve every TODO(generator) marker, then run\n npx biome ci . && npx turbo run typecheck test build\n```\n\n`component-builder` replaces the generated placeholders with the real contract, the Lit\nimplementation (anatomy order: imports, types, styles, class, registration), the React events map and\nthe Angular inputs and `(checkedChange)` output with a `ControlValueAccessor`.\n\n## 7. React Native — `create-native-component`\n\n`native-expert` implements `Switch` with `Pressable`, `accessibilityRole=\"switch\"`,\n`accessibilityState={{ checked, disabled }}`, a 44-point touch area and `useTheme()` colors, and\nfinishes the demo screen `apps/native-demo/app/switch.tsx`.\n\n## 8. Tests — `add-contract-tests`\n\n```bash\nnpx turbo run test --filter=...@joralvmel/cosmos-core\ncd tools && npx vitest run test/structure.test.mjs test/status.test.mjs\n```\n\n```text\n Tasks: N successful, N total\n ✓ test/structure.test.mjs\n ✓ test/status.test.mjs\n```\n\n## 9. Docs and AI references — `add-docs-page`, `add-playground`, `update-ai-references`\n\nThe pages follow the anatomy order (status, Playground, variants, states, accessibility, API, events by\nplatform) in English and Spanish. The Playground already shows HTML, React, Angular and React Native\ncode from the contract.\n\n```bash\nnpm run llms\nnpm run status\n```\n\n```text\nstable 1 switch\n```\n\nThe inventory checks structural completeness. Only mark the component `stable` when the accepted\nscope and required checks are complete. Under the default readiness policy, iOS and manual\nscreen-reader validation are optional/non-blocking and reported as not verified without a\nper-component waiver. Other required checks still block; file presence does not prove runtime readiness.\n\n## 10. Changeset — `add-changeset`\n\n```md\n---\n'@joralvmel/cosmos-core': minor\n'@joralvmel/cosmos-elements': minor\n'@joralvmel/cosmos-react': minor\n'@joralvmel/cosmos-angular': minor\n'@joralvmel/cosmos-native': minor\n---\n\nAdd the Switch component (`cosm-switch`) on every platform.\n```\n\n## 11. Local review, then pull request — `finish-work`, `open-pr`\n\n```text\n/finish-work \"feat(elements): add cosm-switch\" closes #12\n```\n\nThe agent runs repository checks and the relevant browser/wrapper/native scenarios, then verifies\nidentity and automatically commits only the task files locally. It reports the branch, SHA,\nvalidation matrix and how to try the component. **It stops without pushing or opening a PR.**\nMocks and exports are not native runtime evidence; unavailable devices/checks stay visible.\n\nTry that commit. If you request changes, the agent validates and creates a new commit, then waits\nagain. It does not amend the previous commit by default.\n\nOnly after you accept the current reviewed SHA does `open-pr` verify the unchanged HEAD, push the\nbranch and open the PR to `develop` (or reuse its existing open PR). For example:\n\n```text\nI approve the reviewed commit <SHA>. Push it and open the PR to develop.\n```\n\nCI runs lint, terms, typecheck, tests and build, the docs build (preview artifact), the changeset check\nand commit hygiene; the labeler adds `pkg:core`, `pkg:elements`, `pkg:react`, `pkg:angular`,\n`pkg:native`, `app:docs` and `app:native-demo`.\n\n## 12. Review and merge\n\nAsk `reviewer` for a review and address findings; fixes get another local commit and acceptance\nbefore pushing. GitHub approvals are optional, but checks and conversation resolution are required.\nThe maintainer merges with **Squash and merge** (the PR title becomes the commit message); the\nbranch is deleted automatically. Local acceptance does not authorize an automatic merge/release.\n\n## 13. Back to develop — `sync-after-merge`\n\n```bash\ngit switch develop && git pull --prune --ff-only && git branch -D feat/elements-switch\n```\n\n## 14. Release pull request — `release-pr`\n\n```bash\nnpx changeset status --since=origin/main\ngh pr create --base main --head develop --title \"chore(release): switch\" --label release\n```\n\nMerge it with **Create a merge commit**.\n\n## 15. Publish — `release`\n\nThe `Release` workflow opens **Version Packages** on main (versions `0.2.0`, changelogs). Merging it\npublishes to npm with provenance and creates the GitHub Releases:\n\n```bash\nnpm view @joralvmel/cosmos-elements version\n```\n\n```text\n0.2.0\n```\n"},{"slug":"contribute/getting-started","title":"Getting started","markdown":"# Getting started\n\n> Set up the Cosmos UI repository, run the docs and the native demo, and solve common problems.\n\n## Requirements\n\n- **Node.js 24** (see `.nvmrc`; `nvm use` or `fnm use`) and **npm 11**.\n- Git, and the [GitHub CLI](https://cli.github.com/) (`gh`) for the branch and pull request skills.\n- VS Code with GitHub Copilot to use the [agents](../working-with-agents/) (optional).\n- For the native demo: the Expo Go app on a phone, Android Studio (emulator) or Xcode (iOS simulator,\n macOS only).\n\n## First run\n\n1. Clone and install. `npm ci` also points Git to the hooks in `.githooks`:\n\n ```bash\n git clone https://github.com/joralvmel/cosmos-ui.git\n cd cosmos-ui\n npm ci\n ```\n\n2. Build, test and check everything (the same commands as CI):\n\n ```bash\n npx biome ci . && npx turbo run typecheck test build\n ```\n\n Turborepo caches results: a second run takes seconds.\n\n3. Open the docs site at http://localhost:4321:\n\n ```bash\n npm run docs\n ```\n\n4. See what exists and what is next:\n\n ```bash\n npm run status\n ```\n\n## Native demo\n\nThe Expo Router app in `apps/native-demo` has one screen per React Native component and a theme and\nmode switcher.\n\n```bash\nnpm run build # the demo uses the built packages\nnpm run dev --workspace=@joralvmel/cosmos-native-demo\n```\n\n- **Expo Go** (any OS): scan the QR code with the Expo Go app (Android) or the camera (iOS). The phone\n and the computer must be on the same network.\n- **Android emulator**: install Android Studio, create a virtual device, start it, then press `a` in\n the Expo terminal.\n- **iOS simulator** (macOS): install Xcode and its command line tools, then press `i`.\n- **Web preview**: press `w` in the Expo terminal, or run\n `npm run dev --workspace=@joralvmel/cosmos-native-demo -- --web`. This renders the native components\n with React Native Web; it does not replace testing on Android or iOS.\n\n`npm run build --workspace=@joralvmel/cosmos-native-demo` exports the web preview to\n`apps/native-demo/dist` after the library dependencies have been built. The monorepo build also runs\nthis export, so CI checks that the demo bundles for the browser.\n\n## Repository structure\n\n| Folder | Contents |\n| --- | --- |\n| `packages/*` | Publishable packages (`tokens`, `tailwind`, `core`, `elements`, `react`, `angular`, `native`, charts, `icons`, `i18n`, `mcp`, `cli`) |\n| `apps/docs` | This site (Astro + Starlight, English and Spanish) |\n| `apps/native-demo` | Expo demo app |\n| `tools/` | Generator, component status, AI references, Git and GitHub checks, release helpers |\n| `docs/adr`, `docs/conventions` | Architecture decisions and the component anatomy |\n| `.github/` | Workflows, agents, skills, prompts and path-specific instructions |\n\n## Browser tests\n\nUnit and behavior tests run in Vitest with happy-dom, so no browser is needed. Browser checks\n(Playwright with axe) are planned for keyboard behavior and accessibility; when they land they will\nneed `npx playwright install` once.\n\n## Troubleshooting\n\n| Problem | Fix |\n| --- | --- |\n| `EBADENGINE` / unsupported engine | Use Node.js 24 (`nvm use`). |\n| `EBUSY: resource busy or locked` on Windows during `npm ci` | An editor or language server holds a file in `node_modules`; close the project in other IDEs and run it again. |\n| `File content differs from formatting output` | `npm run lint:fix` (Biome formats with LF line endings). |\n| Hooks do not run | `npm ci` with `ignore-scripts` skips `prepare`: run `node tools/git/install-hooks.mjs`. |\n| `Commit blocked: the Git identity does not match` | Your `.local/git-identity.json` expects another identity; fix `git config --local user.*` or the file. |\n| `llms.md files are outdated` | `npm run llms` (the AI references are generated from the contracts). |\n| Strange cached results | `npx turbo run build --force`. |\n"},{"slug":"contribute/git-workflow","title":"Git workflow","markdown":"# Git workflow\n\n> Branches, commits, pull requests, reviews and releases in Cosmos UI.\n\n## Branches\n\n| Branch | Purpose | How changes arrive |\n| --- | --- | --- |\n| `main` | Released code; every push runs the release and docs deployment | Merge commit from `develop` (release pull request) |\n| `develop` | Integration, default branch | Squash work PRs; merge commit for main synchronization |\n| `<type>/<scope>-<description>` | One task | Created from `develop`, deleted after merge |\n\nTypes: `feat`, `fix`, `docs`, `chore`, `refactor`, `test`. Scope: package or area (`elements`, `tokens`,\n`docs`…). Example: `feat/elements-switch`. Contributors without write access fork the repository and\nopen the pull request from their fork.\n\n## Commits\n\n- [Conventional Commits](https://www.conventionalcommits.org/): `type(scope): summary`, several scopes\n separated by commas (`feat(mcp,cli): …`). The `commit-msg` hook checks it.\n- Use your own Git identity; prefer your GitHub noreply email. Sign off with `git commit -s`\n ([DCO](https://developercertificate.org/)) if you can.\n- Never use `--no-verify`.\n\n## Pull requests\n\n1. `start-work` creates a local branch from synchronized `develop`. Component work follows the\n [research and scope approval workflow](../working-with-agents/#research-decisions-and-local-review).\n2. `finish-work` validates, automatically commits locally, reports the SHA and local test steps,\n then **waits without push or PR**. Requested changes get a new commit and another review pause;\n previous commits are not amended by default.\n3. Explicit acceptance of that unchanged HEAD authorizes `open-pr` to verify identity, push and\n open/reuse the PR to `develop`. Initial task or scope approval does not accept unseen changes.\n New commits on an already open PR require the same local review before push.\n4. Required: green checks (lint, terms, typecheck, tests, build, packs, docs build, changeset, commit\n hygiene) and resolution of review conversations. Approvals are optional.\n5. Squash work PRs; the pull request title must be a Conventional Commit (checked by CI).\n Synchronization from main, including repair branches, uses a merge commit instead.\n6. `sync-after-merge` cleans up the local branch.\n\nApprovals are optional on `main` and `develop` so a sole maintainer can merge their own pull requests.\nThis policy applies to all contributors: classic branch protection on a personal repository does not\nsupport individual review exemptions. Pull requests, required checks and conversation resolution\nremain mandatory. Copilot reviews are advisory, not approving reviews.\nThe agent's local review pause is separate from GitHub review requirements; it changes no branch\nprotection settings. Agents never merge or publish just because local changes were accepted.\n\n## Releases\n\n`release-pr` opens `develop → main` with the pending changesets; merge it with a merge commit. The\n[Release and publishing](../publishing/) page explains the rest.\nAfter publication, synchronize main back into develop with a merge commit, never squash/rebase.\nVerify main is an ancestor of develop; never delete either long-lived branch.\n\n## Repository settings\n\nBranch protection, merge options and labels are code: `npm run setup-repo` shows the changes and\n`npm run setup-repo -- --apply` applies them with the GitHub CLI. Settings that only exist in the\nGitHub UI are printed at the end of the command.\n\n## Personal safeguards (optional)\n\nOn a computer with several GitHub accounts, create `.local/git-identity.json` (ignored by Git) with\nyour name, email and GitHub login: the `pre-commit` hook and the `verify-identity` skill then block\ncommits and pushes with another identity. On a computer with a single personal account nothing is\nneeded.\n"},{"slug":"contribute/prompt-cookbook","title":"Prompt cookbook","markdown":"# Prompt cookbook\n\n> Copyable prompts organized by task, from researching and creating components to fixes, tests and local review.\n\nUse these prompts in the **main chat opened in this repository**. It coordinates the specialists;\nyou do not need to switch agents for each step. Natural-language prompts work without a slash\ncommand. Names such as `create-component` refer to existing skills, not new commands.\n\nReplace the values in `[brackets]` and attach relevant files, screenshots, issue links or logs.\nRemove anything that does not apply; never paste credentials or private data into a prompt.\n\n## Choose your task\n\n| I want to… | Start here | Skill or role |\n| --- | --- | --- |\n| Choose what to build next | [Explore the backlog](#explore-the-backlog) | `component-status`, `researcher` |\n| Create a component | [Create from a need](#create-from-a-need) | `create-component` |\n| Use a Figma design | [Create from a design](#create-from-a-design) | `component-from-design` |\n| Copy a palette or imitate another project | [Use a reference](#use-a-reference) | `use-reference` |\n| Add a feature or change an API | [Extend behavior](#extend-behavior) | `modify-component` |\n| Polish an existing component | [Improve appearance](#improve-appearance) | `modify-component`, `design-system` |\n| Fix an error | [Reproduce and fix a bug](#reproduce-and-fix-a-bug) | `modify-component`, `test-engineer` |\n| Fix a platform-specific difference | [Restore platform parity](#restore-platform-parity) | Framework/native specialist |\n| Improve examples or controls | [Update documentation and demos](#update-documentation-and-demos) | `add-playground`, `docs-writer` |\n| Reuse available components in the docs | [Adopt components in the docs UI](#adopt-components-in-the-docs-ui) | `adopt-docs-components` |\n| Check quality without edits | [Review without changing files](#review-without-changing-files) | `reviewer`, `test-engineer` |\n| Cover a missing behavior with tests | [Add focused tests](#add-focused-tests) | `add-contract-tests` |\n| Add a theme, token or chart | [Other library work](#other-library-work) | `add-theme`, `add-token`, `create-chart` |\n| Review and deliver the result | [Continue the conversation](#continue-the-conversation) | `finish-work`, `open-pr` |\n| Prepare or verify a release | [Release and maintenance](#release-and-maintenance) | `release-pr`, `release`, `sync-after-merge` |\n| Update dependencies or fix a vulnerability | [Keep dependencies up to date](#keep-dependencies-up-to-date) | `upgrade-stack`, `devops` |\n\n### What every implementation includes\n\nThe [component workflow](https://github.com/joralvmel/cosmos-ui/blob/develop/docs/conventions/component-workflow.md)\nalready requires research-led scope approval for new behavior, contract/platform parity,\nappropriate tests, EN/ES docs, AI references and changesets for changed publishable packages.\nAn exact bug fix within the accepted contract does not need another feature interview.\n\nImplementation ends with a validated **local commit and a pause**. Neither the initial prompt nor\nscope approval authorizes push, PR, merge or release. Read-only research/review does not authorize\nedits or commits. If a browser, device or tool is unavailable, the agent must report it rather than\ncall the check passed.\n\n## Start a component\n\n### Explore the backlog\n\nUse this when you want advice, not implementation yet.\n\n```text\nCheck the current component inventory and its dependencies. Recommend three candidates to build\nnext, ordered by usefulness, effort and what they unblock. Research the most promising candidate\nand distinguish required, recommended and optional features, with sources and platform differences.\nPresent the decisions I should make next. This is read-only: do not generate files, commit or push.\n```\n\n### Create from a need\n\nCopy this template and fill in the brackets. Leave out the optional lines you do not need. The\nagent researches and asks before deciding, so you do not have to know every feature up front.\n\n```text\nCreate the [component] component using create-component and ADR 0005. The goal is [user need]\nin web, React, Angular and React Native.\n[Optional: Use use-reference only for this component: imitate [behavior or style] from [path or\nlink]; the reference is read-only.]\n\nCheck the inventory and research first. Recommend a useful initial scope, then ask me about\nvariants, sizes, customization, content, accessibility and platform differences in small batches.\nExplain what should be included, excluded or deferred; wait for my approval before generation\nor contract edits.\n\nAfter approval, implement and validate the agreement end-to-end, including representative demo\ncontrols. Create a local commit, show its SHA and how to try it, then wait without push or PR.\n```\n\nNot sure which component? Start with [Explore the backlog](#explore-the-backlog).\n\n### Create from a design\n\nA screenshot does not specify keyboard behavior, state ownership or all native interactions.\n\n```text\nUse component-from-design for [component] with this reference: [Figma frame link or screenshot].\nThe intended use is [user need]. Check whether an existing component already solves it.\n\nResearch the interaction pattern and map the design to current tokens. Show what the reference\ndefines, what is missing and which platform differences need a decision. Ask me before choosing\nunseen behavior or adding tokens/dependencies. Wait for scope/design approval, then complete the\naccepted component on every applicable platform. Validate, commit locally and pause for my review.\n```\n\n## Use a reference\n\nCosmos owns its components: another project is **evidence for one decision at a time**, never a\nlibrary to port. The [reference convention](https://github.com/joralvmel/cosmos-ui/blob/develop/docs/conventions/reference-projects.md)\nkeeps sources read-only and their identity out of the repository. `use-reference` has three modes.\n\n### Copy a palette into a theme\n\nYour own colors can be copied directly into a **new named theme**; the built-in themes stay as they are.\n\n```text\nUse use-reference in palette mode with [theme file of the other project]. Inspect it read-only.\nCreate a Cosmos theme named [name] with add-theme that keeps those colors in light and dark mode:\nbrand colors as seeds and the exact values per semantic role with mode overrides.\nShow the role mapping and the validation first. If a copied pair fails WCAG AA or the color-vision\nchecks, explain it and propose the nearest passing value; do not lower thresholds. Report what the\ntheme cannot express (fonts, spacing, motion). Wait for my approval, then implement, validate on\nweb and native, commit locally and pause without push or PR.\n```\n\n### Imitate a behavior or style in one component\n\nAdd the reference to a normal create or modify request; the Cosmos contract still decides the API.\n\n```text\nUse modify-component for [component]. As a reference, look read-only at [file, screenshot or link]:\nI want [the swipe-to-dismiss behavior / the compact density / the animation] it has.\nDescribe what the reference does (states, interaction, accessibility, platforms) and what Cosmos\nalready covers. Recommend how to bring that aspect into the current contract, ask the open\ndecisions and wait for my approval. Do not copy its props, code or text. After approval implement\non every platform, validate, commit locally and pause.\n```\n\n### Plan replacing an app's components with Cosmos\n\nRun this **in the app's repository**. Replace one component at a time in separate, authorized steps.\n\n```text\nUsing Cosmos's use-reference (replacement plan mode), plan how this app adopts Cosmos.\nInspect the app read-only: installed versions, providers, theme, imports and the UI components it\ndefines. List each one with its Cosmos equivalent (stable, in progress, planned or absent), the\ngaps and a replacement order with acceptance checks and rollback.\nMissing capabilities become Cosmos requests, not app code inside Cosmos. Do not edit the app,\ninstall packages, commit or push. Ask me which first replacement to implement.\n```\n\n## Evolve an existing component\n\n### Extend behavior\n\nDescribe the user outcome before prescribing a prop name. If the capability already exists,\nthe agent should explain how to use it instead of creating another API.\n\n```text\nUse modify-component for [component]. I need users to be able to [desired outcome].\nExample scenario: [input, interaction and expected result].\n\nCheck the current API, scenarios and docs first. If this is already supported, show me how and\ndo not make unnecessary changes. Otherwise research alternatives, recommend an API and explain\ncompatibility, accessibility and web/native trade-offs. Ask me to approve the scope before edits.\nAfter approval, update the contract, affected platforms, controls, tests and docs. State the\nversioning impact and add the required changeset. Commit locally and wait without push or PR.\n```\n\n### Improve appearance\n\nSeparate a visual adjustment from a new public customization API.\n\n```text\nPolish the appearance of [component]. Current issue: [what looks wrong].\nDesired result: [description or attached reference]. Keep its existing behavior and public API.\n\nInspect the current tokens and styling hooks; propose the smallest coherent adjustment. If it\nrequires a new prop, token, dependency or behavior, explain it and ask before expanding the scope.\nCheck light/dark, at least two themes, narrow/wide layouts and relevant focus/disabled states\nin the affected web and native demos. Update visual examples as needed, validate and create\na new local review commit. Do not push.\n```\n\n### Plan a breaking change\n\n```text\nI am considering changing [current API] to [desired API] in [component].\nResearch the alternatives and report affected consumers/platforms, migration steps, versioning\nimpact and a compatible option if one exists. Do not edit files yet. Ask me to choose the approach\nbefore implementing a breaking change.\n```\n\n## Diagnose and fix\n\n### Reproduce and fix a bug\n\nGive observable facts; a suspected cause is a hypothesis, not a constraint on the fix.\n\n```text\nFix this bug in [component] without redesigning its API.\nEnvironment: [framework/platform, relevant versions, browser or device].\nReproduction: [minimal numbered steps or attached example].\nExpected: [observable behavior].\nActual: [observable behavior and relevant error/log].\nFrequency: [always, intermittent or known conditions].\n\nReproduce it first and find the root cause. If you cannot reproduce it, explain the missing\ninformation rather than guessing. Add a focused regression that fails before the fix and passes\nafter it, preserve existing behavior and check the affected platform integration/console.\nIf the fix requires an API or scope change, ask first. Validate, commit locally and show me\nthe evidence and retry steps. Wait without push or PR.\n```\n\n### Restore platform parity\n\n```text\n[Component] behaves differently between [platform A] and [platform B].\nThe shared contract says [expected rule]. Reproduce using [steps or example].\n\nCompare both implementations and their wrapper/event integration. Fix the platform-specific\ncause without duplicating behavior in adapters. If the difference is intentional or the contract\ndoes not resolve it, explain the options and ask me before changing it. Test the affected\nintegration, controls and console. Separate React Native Web, mocked tests, native builds and\nactual device results; disclose unavailable environments. Commit locally and pause for review.\n```\n\n## Improve evidence and examples\n\n### Update documentation and demos\n\n```text\nImprove the docs and demos for [component] without adding new component behavior.\nUse case to explain: [user task]. Missing or confusing examples/controls: [observations].\n\nCheck the real contract first. Keep generated API tables/snippets tied to it; show normal use,\nrelevant states, customization and limitations rather than only the default appearance.\nUpdate EN/ES pages and applicable Playground/native demo controls. Try the examples and controls\nin the available environments, checking keyboard, state changes and console diagnostics.\nReport any contract/control gap instead of silently inventing an API. Validate the affected\nfiles, create a local commit and wait for my review.\n```\n\n### Adopt components in the docs UI\n\nRun this as a separate docs task after new components are available. It updates the site's own\ncontrols, not the public component API or every code sample. Native controls stay when there is\nno compatible stable replacement. You can also invoke `adopt-docs-components` directly.\n\n```text\nUse adopt-docs-components to update docs-owned controls with the available stable Cosmos components.\n[Optional: limit the review to component names or docs areas: ...]\n\nWork on an isolated docs branch from develop, separately from component work. Check the current\ninventory and contracts, then show a replacement mapping with behavior, accessibility and form gaps.\nWait for my scope approval before replacing controls. Do not create components, add dependencies\nor change library APIs; retain native controls where no stable equivalent covers the requirement.\n\nAfter approval, update shared controls and EN/ES docs without duplicating behavior or breaking\ngenerated snippets. Verify actual interactions, keyboard, focus, themes and narrow layouts in the\nbrowser, and add focused regressions. Adopted controls must use the active Cosmos theme and mode,\nincluding Playground overrides and return to the site setting; do not mask their tokens with\nStarlight-only colors. Check their rendered colors, focus and contrast against their actual\nbackground in at least two themes and both modes, not just the preview's attributes.\nReport replacements and deferrals, validate, create a local commit and wait for my review\nwithout push or PR.\n```\n\n### Review without changing files\n\n```text\nUse reviewer to inspect [component or current branch] against develop and the accepted scope.\nFocus on correctness, accessibility, API/platform parity, representative controls, bundle impact\nand missing runtime evidence. Report only actionable, high-confidence findings with file locations,\nseverity and reproduction steps where possible. Separate actual failures from unavailable checks.\nDo not edit files, commit, push or open a PR.\n```\n\nFor an accessibility-focused review, add the relevant keyboard, labeling, focus, motion or\nscreen-reader scenario. Automated checks alone do not prove accessibility.\n\n### Add focused tests\n\n```text\nAdd focused coverage for [component] using add-contract-tests where applicable.\nMissing behavior: [scenario and expected result from the accepted contract].\nCover relevant platform integration and edge cases, not implementation details or trivial getters.\nDo not change the API or chase a coverage percentage. If the tests expose a behavior bug, report it\nand agree the fix scope before expanding this task. Run the tests and required checks, distinguish\nmocks from runtime evidence, commit locally and pause without push or PR.\n```\n\n## Other library work\n\n### Add a theme or token\n\n```text\nUse design-system with add-theme/add-token as appropriate. I need [visual goal and affected uses].\nFirst check whether current themes/tokens already solve it. Recommend options for light/dark,\nsemantic roles, web/native parity and accessibility; ask me before adding public tokens or choosing\nthe design. After approval, use the generator for a new theme, validate contrast without lowering\nthresholds, update galleries/docs and add the required changeset. Commit locally and pause for review.\n```\n\n### Create a chart\n\n```text\nCreate [chart type] using create-chart for [data shape and user question].\nResearch accessible representations, interactions, data limits and web/native trade-offs first.\nRecommend an initial scope and ask me about axes, labels, empty/error states, customization,\nalternative text/table and any interaction before generation.\nAfter approval, implement the pure shared layout and applicable renderers, examples and tests.\nReport bundle costs and actual runtime evidence separately from builds. Commit locally and wait\nwithout push or PR.\n```\n\n## Release and maintenance\n\nA work PR goes to `develop`; releasing is a separate decision. The usual flow is\n`develop → main` (merge commit), then the generated **Version Packages** PR, then publication.\n`release-pr` decides which kind of release fits the current state (none, snapshot, patch/minor or\nmajor) and explains why; you approve before anything is opened or published.\nSee [release and publishing](../publishing/) for setup and commands. These prompts do not authorize\nautomatic merges, changes to publishing permissions, or a release while work is still unmerged.\n\n### Coordinate a release end-to-end\n\nUse one prompt for the whole workflow. The agent recommends the release, opens or reuses PRs,\nchecks publication and isolated consumers, and prepares synchronization. It asks for approval at\neach merge or publication gate and resumes after your answer. If interactive questions are not\navailable, reply in chat; if the session ends, resume from the reported stage and PR.\n\n```text\nCoordinate the next release end-to-end using release and release-manager. Assess and recommend the\nrelease type, prepare prerequisites and PRs, verify publication and isolated consumers, and\nsynchronize main back into develop. Ask for my explicit approval at each merge or publication gate,\nthen verify the current state and continue in this conversation. Report failures and unavailable\nchecks; do not bypass protections or publish without approval.\n```\n\nThe focused prompts below remain useful for assessment, review or recovery on their own.\n\n### Plan the next release\n\nUse this for advice only. To have the agent do the preparation, use the next prompt instead.\n\n```text\nUse release-pr to recommend the next release. This is read-only.\nCheck the remote state, merged work, CI, pending changesets and uncovered dependency updates\nagainst origin/main. Decide which kind of release fits (none, snapshot, patch/minor or major) and\nexplain why, with affected packages, resulting versions, migration notes and missing evidence.\nDo not change versions/changelogs, dispatch workflows, open or merge PRs, push tags or publish.\n```\n\n### Prepare and open the release PR\n\nThis includes local prerequisite repairs, not automatic publication. If no repair is needed,\nthe agent opens the release PR directly. Otherwise it prepares the repair and pauses at the\nlocal review gate; after acceptance and the prerequisite PR's approved merge, it resumes.\n\n```text\nPrepare the next release using release-pr, recommending the appropriate type from the current\nrepository state. I authorize opening/reusing the release PR once its prerequisites are met.\nVerify identity, fresh remote state, exact-SHA checks, changesets, dependency coverage and ancestry.\nIf synchronization, a dependency changeset or conflict repair is needed, prepare it on a dedicated\nwork branch, resolve only evidence-backed conflicts, regenerate the lockfile through npm and\nvalidate. Create a local commit and pause for my review before pushing prerequisite changes.\nAsk only about unresolved semantic decisions; do not stop at merely listing conflicts.\nAfter I accept the commit, open/reuse the prerequisite PR. Explain the required merge method and\nwait for merge approval; once merged, recheck and resume the release preparation.\nUse merge commits for main/develop synchronization and release promotion, never squash.\nReport packages, resulting versions, migration notes, limitations and the exact next approval.\nDo not merge PRs, change versions/changelogs manually, dispatch publication or publish.\n```\n\n### Review Version Packages\n\n```text\nReview the generated Version Packages PR [URL] without editing or merging.\nCompare its versions, dependency updates and changelogs with the accepted changesets and current\nrelease history. Check CI and identify missing/unexpected packages, bumps or migration notes.\nExplain what merging it will publish and which approvals remain. Do not publish, dispatch workflows\nor alter generated files; report blockers and wait for my decision.\n```\n\n### Verify publication and try it as a consumer\n\n```text\nVerify the release [version or workflow URL] without changing the repository.\nCheck actual workflow results, npm versions/dist-tags and provenance, Git tags/GitHub Releases,\nand the docs deployment. Separate published, pending and failed packages; green CI alone is not\nproof that npm publication succeeded.\nGive exact install/version and smoke-test steps for [React/Angular/web/React Native] using published\npackages in an isolated consumer, not workspace links. Do not install or modify that consumer yet.\nReport remaining compatibility/runtime checks rather than claiming they passed.\n```\n\n### Diagnose a failed publication\n\n```text\nDiagnose the failed release [workflow URL and relevant error]. Inspect the run and package state\nread-only first. Identify the root cause and whether some packages/tags were already published.\nDo not blindly rerun, delete/reuse published versions, weaken permissions, change registry settings\nor expose credentials. Propose the smallest recovery and ask for approval before changes or retry.\nAny code fix needs validation, a new local review commit and a pause before push.\n```\n\n### Try a snapshot before releasing\n\n```text\nAssess a next-tag snapshot for [merged scope] using release. Check workflow inputs, current branch,\nCI and package state first. Explain the exact dispatch, expected versions/dist-tag and install\ncommands; distinguish snapshot publication from a latest release.\nDo not dispatch or publish until I explicitly approve that operation. Do not move latest or create\nrelease tags. Report unavailable checks and the cleanup/migration plan for test consumers.\n```\n\n### Synchronize after merge or release\n\n```text\nSynchronize after [merged work/release PR URL] using sync-after-merge.\nCheck identity, remote state and local changes first; preserve unrelated work and never force-push.\nConfirm the PR really merged before removing its work branch. If Version Packages left main ahead\nof develop, use a synchronization PR with a merge commit, never squash. Prepare evidence-backed\nconflict repairs on a dedicated branch, validate and commit locally, then pause before push.\nAsk about unresolved semantic decisions. Do not merge automatically or delete main/develop.\nReport final branch/HEAD and anything still pending. Do not start another component or release.\n```\n\n## Keep dependencies up to date\n\nDependabot opens weekly minor/patch pull requests into `develop`, CI classifies them and the\nscheduled workflows keep a **security** issue and a **dependency report** issue up to date. See\n[release and publishing](../publishing/#dependency-maintenance) for what is automatic.\n\n### Review a Dependabot pull request\n\n```text\nReview Dependabot PR [URL] read-only. Read the CI classification, the dependency review and the\nrelease notes of each update. Tell me whether it is development-only, a runtime update deferred\nto the release, or a change that needs a decision and a changeset (major, peer range, pinned stack).\nCheck the failed checks if any. Recommend merge, changes or upgrade-stack; do not merge or push.\n```\n\n### Upgrade the stack or a major dependency\n\n```text\nUse upgrade-stack for [TypeScript 6.1 / Expo SDK 59 / React 20 / the open dependency report].\nResearch the release notes, migration guides and compatibility matrix first, and tell me the\nconsumer impact and the Cosmos semver of each package. Wait for my approval before changing\nmanifests. Then upgrade with npm, migrate the code, update the pinned versions and Dependabot\nrules, validate every platform and add changesets with migration notes. Commit locally and pause.\n```\n\n### Fix a vulnerability\n\n```text\nInvestigate the security issue [URL or advisory]. Say whether it reaches consumers (runtime of a\npublished package), the apps or only development tooling, and whether a compatible fix exists.\nIf the fix is a patch, apply it with npm, add a patch changeset for affected packages, validate,\ncommit locally and pause. If it needs a major or the pinned stack, propose an upgrade-stack plan\nand wait. Never disable the audit or the dependency review to get green checks.\n```\n\n## Continue the conversation\n\nThese are **separate messages at the appropriate stage**, not lines to append to the initial prompt.\nReplace `[SHA]` with the exact commit presented for local review.\n\n### Accept the proposed scope\n\n```text\nI approve the scope you just summarized, including its exclusions and deferred checks.\nImplement that agreement and run the checks. If a meaningful API, design or dependency decision\nchanges, ask me again. Finish with a local commit and pause; this does not authorize push or PR.\n```\n\n### Request another iteration\n\n```text\nI tried commit [SHA]. Change [specific observation] to [expected result].\nKeep the rest of the accepted scope. Validate the adjustment, create a new commit on this work\nbranch without amending earlier commits, and wait for me to review the new SHA. Do not push yet.\n```\n\n### Push the accepted commit and open the PR\n\nUse this only after checking the implementation and its reported limitations.\n\n```text\nI approve the reviewed commit [SHA] and its disclosed limitations. Use open-pr to verify identity,\nunchanged HEAD and validation evidence, push it and open or update its PR to develop.\nReport the URL and actual check status. Do not merge or publish.\n```\n\n### Resume in another chat\n\n```text\nResume [task] on branch [branch] at commit [SHA]. Read the accepted design, current diff and\nvalidation evidence: [file locations or previous handoff].\nSummarize what is done, pending and unverified before continuing. Do not infer scope or push\napproval from this message; ask again if the previous agreement/evidence cannot be recovered.\n```\n\nFor the complete delivery process, see [Git workflow](../git-workflow/) and\n[release and publishing](../publishing/). Opening a work PR is not a request to create a release.\n"},{"slug":"contribute/publishing","title":"Release and publishing","markdown":"# Release and publishing\n\n> How Cosmos UI is versioned and published to npm, and the one-time setup for maintainers.\n\nCosmos UI uses [Changesets](https://github.com/changesets/changesets) for versions and changelogs and\npublishes to the public npm registry with\n[trusted publishing](https://docs.npmjs.com/trusted-publishers) (OIDC, no npm token) and\n[provenance](https://docs.npmjs.com/generating-provenance-statements).\n\n## How releases work\n\nFor copyable prompts covering release planning, PR review, verification, recovery and branch\nsynchronization, see [release and maintenance](../prompt-cookbook/#release-and-maintenance).\nTo coordinate the whole process in one conversation, use\n[coordinate a release end-to-end](../prompt-cookbook/#coordinate-a-release-end-to-end). The\nagent requests separate approvals before merges and publication.\n\n1. Every pull request that changes `packages/*` adds a changeset (`npm run changeset`).\n2. When `develop` is ready, a maintainer runs `npm run deps:changeset` (patch changesets for\n runtime dependency updates merged from Dependabot), then opens the release pull request\n `develop → main` (skill `release-pr`) and merges it with a **merge commit**.\n3. On `main`, the `Release` workflow opens or updates the **Version Packages** pull request: it bumps\n versions and writes the changelogs.\n4. Merging **Version Packages** runs `changeset publish`: new versions go to npm with provenance, Git\n tags are pushed and a GitHub Release is created per package.\n5. The `Docs` workflow deploys the documentation site from `main`.\n6. Synchronize published `main` back into `develop` through a PR using a **merge commit**, never\n squash/rebase. Verify `git merge-base --is-ancestor origin/main origin/develop` succeeds after\n fetching. Matching files alone are not enough: preserving ancestry prevents repeated conflicts.\n\n`release-pr` distinguishes a read-only assessment from preparation. Preparation includes safe\nlocal repairs for synchronization, dependency changesets and conflicts, with validation and a\nlocal review commit before push. It resumes after prerequisite PRs merge; merge and publication\nstill need explicit approval. Use [the preparation prompt](../prompt-cookbook/#prepare-and-open-the-release-pr).\n\nPrereleases: run the `Release` workflow manually on `develop` (Actions → Release → Run workflow). It\npublishes a snapshot such as `0.2.0-next-20261110120000` with the dist-tag `next`:\n\n```bash\nnpm install @joralvmel/cosmos-react@next\n```\n\n## One-time setup (maintainers)\n\nThe skill `publish-setup` walks an agent through the same checklist.\n\n1. **npm account.** Create an account on [npmjs.com](https://www.npmjs.com/signup), verify the email\n and enable two-factor authentication (Account → Two-Factor Authentication, \"Authorization and\n writes\"). The scope `@joralvmel` is the account's user scope.\n\n2. **Check the packages.**\n\n ```bash\n npm ci\n npm run check-packs # builds, validates manifests and runs npm pack --dry-run\n npm run publish-order # dependencies first\n ```\n\n3. **First publication by hand.** Trusted publishing can only be configured for packages that exist.\n Publish the current version of every package once, in the order printed above:\n\n ```bash\n npm login\n cd packages/core && npm publish --access public --otp <code> && cd ../..\n # …repeat for each package in publish order\n ```\n\n The first version is a placeholder (`0.0.0`); you can mark it with\n `npm deprecate @joralvmel/cosmos-core@0.0.0 \"placeholder\"`.\n\n4. **Trusted publisher per package.** On npmjs.com open each package → Settings → Trusted Publisher →\n GitHub Actions and enter: owner `joralvmel`, repository `cosmos-ui`, workflow `release.yml`,\n environment `npm`. Then, under \"Publishing access\", choose\n \"Require two-factor authentication and disallow tokens\".\n\n5. **GitHub.** In the repository settings:\n - Environments → create `npm` (optionally with required reviewers).\n - Secrets and variables → Actions → Variables: `COSMOS_PUBLISH_ENABLED` = `true`.\n - For the docs site: Pages → Source \"GitHub Actions\" and the variable `COSMOS_DOCS_ENABLED` = `true`.\n\n6. **Verify** after the first automated release:\n\n ```bash\n npm view @joralvmel/cosmos-core versions dist-tags\n npm audit signatures # inside a project that installed the packages\n ```\n\n The package page on npmjs.com shows the provenance badge linking to the workflow run.\n\n## Dependency maintenance\n\n| What | Automation | Your part |\n| --- | --- | --- |\n| Minor/patch updates | Dependabot opens grouped PRs into `develop` every Monday (pinned stack: patches only) | Review and merge them |\n| Classification | CI (`Changeset present`) labels each update as development, runtime or needing a decision | Majors, peer ranges and the pinned stack need a changeset in the PR, usually through `upgrade-stack` |\n| Runtime updates | Deferred to the release; the release PR fails until they are covered | `npm run deps:changeset` on `develop` before `release-pr` |\n| New dependencies | `Dependency review` blocks high/critical vulnerabilities and licenses outside the allow list | Choose another package or discuss an exception |\n| Vulnerabilities | Dependabot alerts and security PRs; weekly `Security audit` keeps one `security` issue | Fix with a patch or plan an `upgrade-stack` |\n| Majors and pinned stack | Monthly `Dependency report` keeps one `dependencies` issue | Plan the upgrade with `upgrade-stack` |\n| Tooling auto-merge | Optional: with the variable `COSMOS_DEPENDABOT_AUTOMERGE` = `true`, minor/patch updates of development tooling merge themselves once checks pass | Nothing, or leave it off to review everything |\n\nRun the reports locally with `npm run deps:audit` and `npm run deps:outdated`. Merges made by the\nauto-merge use the workflow token, so they do not trigger workflows on `develop`; the next pull\nrequest or release runs the full checks. Prompts: [keep dependencies up to date](../prompt-cookbook/#keep-dependencies-up-to-date).\n\n## Troubleshooting\n\n| Symptom | Fix |\n| --- | --- |\n| Release promotion conflicts after an earlier synchronization | Check ancestry, not only file equality. Prepare a reviewed synchronization repair with `release-pr`; preserve published metadata and newer develop work, regenerate the lockfile with npm, and merge the synchronization with a merge commit. |\n| Synchronization merge commit is blocked by linear-history protection | Apply the reviewed `setup-repo` policy with maintainer approval. It allows merge commits while retaining PRs, required checks and force-push/deletion protections. Do not squash synchronization as a workaround. |\n| Release PR fails \"Released runtime dependency updates have changesets\" | Run `npm run deps:changeset` on a `develop` work branch and merge it before the release. |\n| Dependabot PR fails \"Classify dependency updates\" | It needs a decision: review it with `upgrade-stack` and add a changeset to the PR. |\n| `E404` / `ENEEDAUTH` on publish | The trusted publisher does not match: check owner, repository, workflow file name and environment. |\n| No \"Version Packages\" pull request | Allow GitHub Actions to create pull requests (`npm run setup-repo -- --apply` does it). |\n| Workflow skipped | `COSMOS_PUBLISH_ENABLED` is not `true`. |\n| `check-packs` fails | A manifest misses `publishConfig.access`, `files`, `exports`, `repository`, `license` or `llms.md`. |\n"},{"slug":"contribute/recipes","title":"Recipes","markdown":"# Recipes\n\n> Short guides to create a theme, add a token, build a component from Figma, change a component and create a chart.\n\nEach recipe names the skill that automates it (run it as a `/prompt` or ask its agent).\n\nFor ready-to-copy task requests, use the [prompt cookbook](../prompt-cookbook/).\nThese are technical recipes, not permission to skip research or scope approval: agree new\ncomponent/API/design decisions before generation or contract edits, following the\n[agent workflow](../working-with-agents/#research-decisions-and-local-review).\nImplementation ends at the local commit/review pause, not an automatic push or PR.\n\n## Create a theme — `add-theme`\n\n```bash\nnpm run generate -- theme aurora --seed \"oklch(0.58 0.14 165)\"\nnpx turbo run test build --filter=@joralvmel/cosmos-tokens...\n```\n\n1. Tune the definition in `packages/tokens/src/themes.ts`: seeds (OKLCH), `harmony`, neutral tint and\n `radius`. Add mode overrides only when unavoidable.\n2. The tokens tests check WCAG 2.2 AA and color vision deficiencies in light and dark. Never lower the\n thresholds; change the seeds instead.\n3. The theme appears in the theme gallery, the header picker, Tailwind (`theme-aurora:`) and\n `CosmosThemeProvider`.\n\n## Add a token — `add-token`\n\n1. Semantic color: add it to `semanticColors` (`packages/tokens/src/types.ts`), derive it in\n `generate.ts` and add contrast pairs in `validate.ts` when it carries text or UI.\n2. Base token (spacing, radius, motion…): add it to `base.ts`; map it in `toTailwindTheme` / `toNative`.\n3. Update the tokens and Tailwind tests, then `npm run llms`.\n\n## Component from Figma — `component-from-design`\n\n1. Share the Figma link of the frame (`?node-id=`) or a screenshot with the `design-system` agent.\n2. It extracts anatomy, variants and states and maps every value to existing tokens; a new token goes\n through `add-token`.\n3. After research and scope/design approval, `component-builder` runs the generator through\n `create-component`; `architect` finalizes the contract before platform behavior.\n\n## Change a component — `modify-component`\n\n1. `component-status` for the component and for any component it will use.\n2. Research new behavior and approve its scope first (exact fixes can reuse accepted decisions).\n Then update the contract and scenarios; decide the semver bump with `architect`.\n3. Update every platform, tests and docs; keep the anatomy (the structure test checks it).\n4. `npm run llms` and a changeset (`major` with a migration note when breaking).\n\n## Create a chart — `create-chart`\n\n```bash\nnpm run generate -- chart sparkline\n```\n\n1. Implement the pure layout in `packages/charts-core/src/sparkline-layout.ts` and test it without DOM.\n2. Render SVG in `packages/charts` and React Native in `packages/charts-native` with the same layout.\n3. Use theme chart colors (`--cosm-chart-1..8`), add a text description and a data table alternative.\n"},{"slug":"contribute/working-with-agents","title":"Working with agents","markdown":"# Working with agents\n\n> What each AI agent and skill of the repository does, how to use them in VS Code and what to ask.\n\nThe repository ships a team of specialized agents (`.github/agents/`) and step-by-step skills\n(`.github/skills/`, each with a prompt in `.github/prompts/`). They follow `AGENTS.md`, the rules in\n`.github/instructions/` and the [component anatomy](https://github.com/joralvmel/cosmos-ui/blob/develop/docs/conventions/component-anatomy.md).\n\n## How to use them in VS Code\n\n1. Open the repository in VS Code with GitHub Copilot and open the **Chat** view.\n2. **Agents**: pick one in the agent selector of the chat (for example `component-builder`), then\n describe the task. The agent loads its rules and uses its skills.\n3. **Prompts**: type `/` and the skill name, e.g. `/create-component`, `/component-status`,\n `/start-work`. The prompt asks for its inputs and runs the skill with the right agent.\n4. Attach context with `#` (a file, a folder or a Figma link) when it helps.\n\nOther assistants (Codex, Claude Code, Cursor…) read `AGENTS.md`; point them to a skill file, e.g.\n\"follow `.github/skills/create-component/SKILL.md` for `switch`\".\n\n## Research, decisions and local review\n\nFollow the [component workflow](https://github.com/joralvmel/cosmos-ui/blob/develop/docs/conventions/component-workflow.md).\nThe main chat coordinates specialists and keeps the conversation with you:\n\n1. The researcher compares standards and public implementations, with licenses, platform\n differences and costs. Its recommendation is not permission to implement everything.\n2. Copilot presents required, recommended and optional features, then asks small batches of\n design/API questions. You approve what is included, excluded or deferred **before generation\n or contract edits**. Examples do not silently become special cases or exclusive feature lists.\n3. Agents implement the accepted scope and run checks themselves. The evidence report distinguishes\n actual browser/wrapper checks, React Native Web, mocked tests, builds and Android/iOS runtime.\n Unavailable tools, devices and screen-reader checks must be reported, not marked passed.\n4. `finish-work` validates and automatically creates a **local commit**, reports its SHA and how\n to try it, then **waits without push or PR**. Request changes for another commit and review\n pause, or accept that exact commit to authorize `open-pr` to push and create/reuse the PR.\n\nAn initial request to implement and eventually open a PR is not approval of unseen changes.\nApproving the feature scope is different from accepting the implementation. A changed HEAD needs\nanother review; agents do not amend earlier commits by default.\n\nThe test and native agents include browser tools, and coordinating roles can delegate and ask\ninteractive questions. Availability still depends on your harness and enabled tools. The workflow\ndoes not bypass editor permissions or add a new GitHub approval requirement.\n\n## Readiness and optional validation\n\n`stable` means the implementation and required acceptance checks are complete, not that every\ndevice or assistive technology is certified. The\n[readiness policy](https://github.com/joralvmel/cosmos-ui/blob/develop/docs/conventions/component-workflow.md#default-readiness-policy)\nmakes iOS validation and manual screen-reader testing optional and non-blocking for all components.\nAgents do not attempt them unless explicitly requested and do not ask for a waiver on every task.\nThey report **not verified (optional)** instead of claiming a pass or holding a component in progress.\n\nAutomated tests, applicable browser integration and accessibility requirements such as names,\nroles, states, keyboard, focus, contrast, motion and touch targets still apply. Known defects remain\nblockers, including those discovered in an optional environment.\n\n## Agents\n\n| Agent | What it does | Skills |\n| --- | --- | --- |\n| `ai-tooling` | Maintains the AI tooling for consumers: MCP server, `cosmos init-ai`, consumer instructions and drift tests of llms.md against contracts. | `update-ai-references` |\n| `angular-expert` | Angular specialist: standalone proxy components, ControlValueAccessors for form controls, signals and zoneless apps, Angular examples. | `modify-component` |\n| `architect` | Owns architecture and patterns: package boundaries, component contracts in core, ADRs, new dependencies, performance, public API and breaking changes. Use before adding a component, a package, a dependency or changing a public API. | `write-adr`, `define-contract`, `component-status`, `research-reference`, `upgrade-stack` |\n| `chart-builder` | Builds charts: pure layout in charts-core, SVG rendering as Web Components, interaction and accessibility, and coordinates native rendering with native-expert. | `create-chart` |\n| `component-builder` | Builds or extends Cosmos web components end-to-end with the generator: contract, Lit Web Component, form association, React and Angular wrappers, React Native stub, tests and docs pages. Use for any \"create/add/extend a component\" task. | `component-status`, `create-component`, `modify-component` |\n| `design-system` | Design and layout specialist with deep color theory and visual accessibility knowledge: themes, palettes, light/dark modes, typography, spacing, motion, component anatomy and states, responsive layout, Tailwind theme and translation of Figma designs into tokens. | `design-component`, `component-from-design`, `use-reference`, `add-theme`, `add-token` |\n| `devops` | GitHub Actions, Turborepo caching, docs and demo deployments (GitHub Pages), Expo EAS, workflow security, SBOM and license reports. | `setup-ci`, `deploy-docs`, `publish-setup`, `upgrade-stack` |\n| `docs-writer` | Writes the English and Spanish documentation site, playgrounds, theme gallery, icon catalog, READMEs and the llms.md / llms.txt AI references. | `add-docs-page`, `add-playground`, `adopt-docs-components` |\n| `github-ops` | Handles branches, commits, pull requests, issues, labels and GitHub releases. Verifies the collaborator identity (verify-identity) before any commit or push. | `verify-identity`, `start-work`, `commit`, `finish-work`, `sync-after-merge`, `open-pr` |\n| `native-expert` | React Native and Expo specialist: native components on the shared contracts and themes, gestures, mobile accessibility, native charts with charts-core and the Expo Router demo app. | `component-status`, `create-native-component`, `modify-component` |\n| `react-expert` | React specialist: React 19 custom elements and @lit/react wrappers, SSR/Next.js compatibility, React examples and the portfolio demo app. | `modify-component` |\n| `release-manager` | Owns Changesets, semantic versioning, changelogs, deprecations and npm publishing. | `add-changeset`, `release-pr`, `release`, `sync-after-merge`, `finish-work` |\n| `researcher` | Read-only researcher: studies specifications (WAI-ARIA APG, HTML, Open UI) and public libraries for a feature, compares behavior, accessibility, APIs and licenses, and recommends using a dependency or implementing it in Cosmos. | `research-reference`, `use-reference` |\n| `reviewer` | Read-only reviewer: conventions, contract parity across platforms, accessibility, security, blocked terms, third-party licenses and changesets. Use before merging. | — |\n| `test-engineer` | Test strategy owner: shared contract scenarios, drift tests, Playwright and axe accessibility checks, coverage and flaky tests. | `add-contract-tests` |\n\n## Skills\n\n| Skill (prompt) | Main agent | What it does |\n| --- | --- | --- |\n| `/add-changeset` | `release-manager` | Writes a Changesets release note for every publishable package changed in the branch. |\n| `/add-contract-tests` | `test-engineer` | Adds shared behavior scenarios to a contract and runs them on the web, React, Angular and React Native through drivers. |\n| `/add-docs-page` | `docs-writer` | Adds a documentation page in English and Spanish with Playground, examples per framework, API table and accessibility notes. |\n| `/add-playground` | `docs-writer` | Adds the interactive Playground to a component page: controls generated from the contract, code tabs for HTML, React, Angular and React Native, copy button, theme/mode pickers and the native demo link. |\n| `/add-theme` | `design-system` | Adds a theme with defineTheme (seeds, harmony, light/dark), validates contrast and color vision deficiencies, and shows it in the docs gallery and in React Native. |\n| `/add-token` | `design-system` | Adds a token to every output (CSS variables, Tailwind theme, React Native values, JSON) with tests. |\n| `/adopt-docs-components` | `docs-writer` | Adopts available stable Cosmos components in the docs site itself. Use when asked to replace native or custom documentation controls with library components, refresh the docs after adding components, or review internal component reuse. |\n| `/audit-a11y` | `test-engineer` | Audits accessibility on web and React Native: axe, keyboard, focus, screen readers, contrast and motion. |\n| `/commit` | `github-ops` | Creates a local Conventional Commit after identity and validation checks, then pauses for user review without pushing. Revisions use new commits, not amendments. |\n| `/component-from-design` | `design-system` | Turns a Figma URL (via Figma MCP), screenshot or image into a contract, a visual spec mapped to Cosmos tokens and a generated component. |\n| `/component-status` | `architect` | Reports the component inventory (npm run status), explains gaps and proposes or creates the next components according to their dependencies. Run it before creating, modifying or composing components. |\n| `/create-chart` | `chart-builder` | Creates a chart: pure layout in charts-core, SVG rendering on the web, React Native rendering, accessibility and docs. |\n| `/create-component` | `component-builder` | Creates a new Cosmos component end-to-end following docs/conventions/component-anatomy.md: contract and scenarios, Lit Web Component, React and Angular wrappers, React Native component and demo, tests, docs pages (EN/ES), llms.md and changeset. |\n| `/create-native-component` | `native-expert` | Creates a React Native component on a contract, core logic and tokens, with shared scenarios, drift test, demo screen and docs, following the component anatomy. |\n| `/define-contract` | `architect` | Creates or updates a component contract (props, events, states, slots, parts, keyboard, ARIA) and its shared scenarios in core, with the DOM/React/Angular/React Native mapping. |\n| `/deploy-docs` | `devops` | Deploys the docs site (and demos) to GitHub Pages once enabled. |\n| `/design-component` | `design-system` | Writes the visual spec of a component: anatomy, sizes, variants, states, tokens used, responsive behavior and light/dark notes, then styles it with tokens only. |\n| `/finish-work` | `github-ops` | Validates implementation work, automatically creates a local commit and pauses for user testing. Push and PR creation resume only after approval of the reviewed HEAD. |\n| `/modify-component` | `component-builder` | Changes the API or behavior of an existing component while keeping parity and the anatomy: contract → Lit → wrappers → React Native → scenarios → docs → llms.md → changeset. |\n| `/open-pr` | `github-ops` | After explicit acceptance of the current local review commit, pushes the branch and opens or updates its PR to develop. Without that approval, returns to local review. |\n| `/publish-setup` | `release-manager` | One-time checklist to start publishing to npm: npm account with 2FA, first manual publication in dependency order, trusted publishers, GitHub environment and variables, verification. |\n| `/release` | `` | Coordinates a release from assessment through approved PRs, publication verification, consumer tests and synchronization; also supports snapshots. |\n| `/release-pr` | `release-manager` | Recommends the release type (none, snapshot, patch/minor, major) and opens the release pull request develop → main with the summary of pending changesets. |\n| `/research-reference` | `researcher` | Researches specifications and public libraries for a feature, compares behavior, accessibility, APIs and licenses, and recommends a dependency or an own implementation. |\n| `/setup-ci` | `devops` | Creates or updates GitHub Actions workflows (CI, identity, release, docs) following the workflow rules. |\n| `/start-work` | `github-ops` | Starts a task: syncs develop, creates a work branch with a normalized name and optionally links it to an issue. |\n| `/sync-after-merge` | `github-ops` | After a pull request is merged: returns to develop, pulls with prune and deletes the local work branch. |\n| `/sync-icons` | `component-builder` | Updates the Lucide version, regenerates the icon definitions and catalog, and refreshes the license notice. |\n| `/update-ai-references` | `ai-tooling` | Keeps every AI reference in sync with the code: llms.md blocks (npm run llms), docs .md pages, /llms.txt, /llms-full.txt, the MCP server data and tools, and cosmos init-ai. |\n| `/upgrade-stack` | `devops` | Use when upgrading the pinned stack or a major dependency (TypeScript, React, Angular, Expo/React Native, Lit, Vitest, Astro...), fixing a vulnerability that needs more than a Dependabot patch, or acting on the monthly dependency report. Researches compatibility and migration guides, asks for approval, upgrades with npm, validates every platform and commits locally. |\n| `/use-reference` | `` | Use when another project should inform Cosmos: copy its color palette into a named Cosmos theme, imitate one behavior or style while creating or modifying a single Cosmos component, or plan replacing an app's own components with Cosmos one at a time. Sources stay read-only; never batch-create components from a reference. |\n| `/verify-identity` | `github-ops` | Checks the Git and GitHub identity before a commit or push. Enforces .local/git-identity.json when it exists; otherwise reports the current identity and asks for confirmation. |\n| `/write-adr` | `architect` | Writes an architecture decision record NNNN-title.md (context → decision → consequences). |\n\n## What to ask\n\n- **One task at a time**, with the outcome you expect: \"Create the `switch` component for all\n platforms\" rather than \"work on forms\".\n- **Give references**: an issue number, a Figma link, a pattern of the WAI-ARIA APG.\n- **Let them validate**: implementation work includes tests and\n `npx biome ci . && npx turbo run typecheck test build`. Research-only work returns sources, not\n invented test results. Ask for the evidence and unavailable checks.\n- **Review before merging**: ask `reviewer` for a review of the branch.\n\n## Copyable prompts\n\nThe [prompt cookbook](../prompt-cookbook/) organizes ready-to-copy examples by task:\n\n- [Create a component or start from Figma](../prompt-cookbook/#start-a-component).\n- [Extend behavior, polish visuals or plan an API change](../prompt-cookbook/#evolve-an-existing-component).\n- [Reproduce a bug or restore platform parity](../prompt-cookbook/#diagnose-and-fix).\n- [Improve docs, demos, tests or a read-only review](../prompt-cookbook/#improve-evidence-and-examples).\n- [Add themes, tokens or charts](../prompt-cookbook/#other-library-work).\n- [Accept scope, request revisions, approve a PR or resume a chat](../prompt-cookbook/#continue-the-conversation).\n\nUse the [end-to-end example](../example-switch/) to follow a whole component through delivery;\nthe [technical recipes](../recipes/) explain the implementation steps behind individual tasks.\n"},{"slug":"getting-started/installation","title":"Installation","markdown":"# Installation\n\n> Install Cosmos UI for the web, React, Angular, React Native and Tailwind CSS.\n\nCosmos UI is not published yet. Once released, packages are installed from npm. Each framework has a\ncomplete guide: [React](../../guides/react-vite/), [Next.js](../../guides/nextjs/),\n[Angular](../../guides/angular/), [HTML / CDN](../../guides/html-cdn/),\n[React Native](../../guides/react-native/) and [Tailwind CSS](../../guides/tailwind/). To let an AI\nassistant do it, see [Use with AI](../../ai/overview/).\n\n**Web Components**\n```bash\nnpm install @joralvmel/cosmos-elements @joralvmel/cosmos-tokens\n```\n\n```js\nimport '@joralvmel/cosmos-tokens/tokens.css';\nimport '@joralvmel/cosmos-elements/button';\n```\n\n**React**\n```bash\nnpm install @joralvmel/cosmos-react @joralvmel/cosmos-tokens\n```\n\n```tsx\nimport '@joralvmel/cosmos-tokens/tokens.css';\n\nexport const Save = () => <Button onPress={event => console.log(event.detail.source)}>Save</Button>;\n```\n\n**Angular**\n```bash\nnpm install @joralvmel/cosmos-angular @joralvmel/cosmos-tokens\n```\n\n```ts\n\n@Component({\n selector: 'app-save',\n imports: [CosmButtonComponent],\n template: `<cosm-button (press)=\"save()\">Save</cosm-button>`,\n})\nexport class SaveComponent {\n save() {}\n}\n```\n\n**React Native**\n```bash\nnpm install @joralvmel/cosmos-native\n```\n\n```tsx\n\nexport default function App() {\n return (\n <CosmosThemeProvider theme=\"nebula\" mode=\"system\">\n <Button onPress={({ source }) => console.log(source)}>Save</Button>\n </CosmosThemeProvider>\n );\n}\n```\n\n## Theme and mode\n\nSet the theme and mode on any element (usually `<html>`). `data-mode=\"system\"` follows the operating\nsystem; without `data-mode` the light mode is used.\n\n```html\n<html data-theme=\"nebula\" data-mode=\"system\"></html>\n```\n\n## Tailwind CSS v4 (optional)\n\n```css\n@import \"tailwindcss\";\n@import \"@joralvmel/cosmos-tailwind\";\n```\n\nUtilities such as `bg-primary`, `text-fg-muted`, `rounded-md`, `dark:bg-surface` or\n`theme-nebula:text-accent` use the Cosmos tokens.\n\n## Stay up to date\n\nCosmos packages are released together through Changesets; while versions are `0.x`, a **minor**\nrelease may contain breaking changes. Read the package changelogs (GitHub Releases) before\nupdating and follow their migration notes. To get update pull requests in your app, group the\nCosmos packages in its Dependabot configuration so they move together:\n\n```yaml\nversion: 2\nupdates:\n - package-ecosystem: npm\n directory: /\n schedule:\n interval: weekly\n groups:\n cosmos:\n patterns: ['@joralvmel/cosmos-*']\n```\n\n## Adopt Cosmos in an existing app\n\nReplace one component at a time and keep the old one until the new one passes your checks. An\nassistant can plan the order for you from the app's repository: see\n[plan replacing an app's components](../../contribute/prompt-cookbook/#plan-replacing-an-apps-components-with-cosmos).\nTo keep your current colors, create a [theme from your palette](../../theming/themes/#keep-an-existing-palette).\n"},{"slug":"getting-started/introduction","title":"Introduction","markdown":"# Introduction\n\n> What Cosmos UI is and how its packages fit together.\n\nCosmos UI is a design system that ships the same components to the web (Web Components, React,\nAngular) and to React Native. Each component is defined once as a **contract** in\n`@joralvmel/cosmos-core`; every platform implementation is tested against that contract and its shared\nbehavior scenarios.\n\n## Packages\n\n| Package | Purpose |\n| --- | --- |\n| `@joralvmel/cosmos-tokens` | Theme engine and design tokens (CSS variables, JSON, React Native values) |\n| `@joralvmel/cosmos-tailwind` | Tailwind CSS v4 theme mapped to the tokens |\n| `@joralvmel/cosmos-core` | Contracts, shared scenarios and headless logic |\n| `@joralvmel/cosmos-elements` | Web Components built with Lit |\n| `@joralvmel/cosmos-react` | React wrappers |\n| `@joralvmel/cosmos-angular` | Angular standalone components |\n| `@joralvmel/cosmos-native` | React Native components |\n\nCharts, icons, i18n, the MCP server and the CLI are in early development.\n\n## Principles\n\n- **Contracts first**: props, events, slots, keyboard support and ARIA roles are decided before code.\n- **Tokens only**: components are styled with `--cosm-*` variables, so every theme and mode works.\n- **Accessible by default**: WAI-ARIA patterns, visible focus, reduced motion and verified contrast.\n"},{"slug":"guides/angular","title":"Angular","markdown":"# Angular\n\n> Use Cosmos UI in Angular with standalone components, signals and forms.\n\n`@joralvmel/cosmos-angular` provides one standalone component per Web Component, with the same\nselector (`cosm-button`…). Inputs set element properties; outputs re-emit the original `CustomEvent`.\n\n## Setup\n\n```bash\nnpm install @joralvmel/cosmos-angular @joralvmel/cosmos-tokens\n```\n\n**Load the tokens** (`angular.json`)\n\n```json\n\"styles\": [\"node_modules/@joralvmel/cosmos-tokens/dist/tokens.css\", \"src/styles.css\"]\n```\n\n**Choose theme and mode** (`src/index.html`)\n\n```html\n<html data-theme=\"cosmos\" data-mode=\"system\">\n```\n\n**Import components** (`src/app/app.component.ts`)\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmButtonComponent } from '@joralvmel/cosmos-angular';\n\n@Component({\n selector: 'app-root',\n imports: [CosmButtonComponent],\n template: `<cosm-button (press)=\"save($event.detail.source)\">Save</cosm-button>`,\n})\nexport class AppComponent {\n save(source: string) {}\n}\n```\n\n- Components are standalone; import them individually or spread `COSMOS_COMPONENTS`.\n- Outputs re-emit the original CustomEvent: use `$event.detail`. Form controls provide ControlValueAccessors.\n\nGuide: https://joralvmel.github.io/cosmos-ui/guides/angular/\n\n## Inputs, outputs and signals\n\n```ts\n\n@Component({\n selector: 'app-save',\n imports: [CosmButtonComponent],\n template: `\n <cosm-button [loading]=\"saving()\" variant=\"soft\" (press)=\"save()\">Save</cosm-button>\n `,\n})\nexport class SaveComponent {\n readonly saving = signal(false);\n\n save() {\n this.saving.set(true);\n }\n}\n```\n\n- Boolean inputs accept attributes (`loading`, `fullWidth`) and bindings (`[loading]=\"saving()\"`).\n- Outputs use the contract names: `(press)`, `(valueChange)`, `(openChange)`… Read `$event.detail`.\n- The components work in zoneless applications.\n\n## Forms\n\n`<cosm-button type=\"submit\">` submits the surrounding `<form>`. Form controls (text field, checkbox…)\nship `ControlValueAccessor`s so they work with `formControlName` and `[(ngModel)]` as they become\navailable (see the [component status](../../components/status/)).\n\n## All components at once\n\n```ts\n\n@Component({ imports: [...COSMOS_COMPONENTS], template: '…' })\nexport class Page {}\n```\n"},{"slug":"guides/html-cdn","title":"HTML and CDN","markdown":"# HTML and CDN\n\n> Use Cosmos UI Web Components in plain HTML, from a CDN or with any bundler.\n\nThe Web Components of `@joralvmel/cosmos-elements` work in any page: no framework needed.\n\n## Setup\n\n**Load tokens and components from a CDN** (`index.html`)\n\n```html\n<!doctype html>\n<html lang=\"en\" data-theme=\"cosmos\" data-mode=\"system\">\n <head>\n <link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/@joralvmel/cosmos-tokens/dist/tokens.css\" />\n <script type=\"module\" src=\"https://esm.sh/@joralvmel/cosmos-elements/button\"></script>\n </head>\n <body>\n <cosm-button variant=\"soft\">Save</cosm-button>\n <script type=\"module\">\n document.querySelector('cosm-button').addEventListener('cosm-press', event => {\n console.log(event.detail.source);\n });\n </script>\n </body>\n</html>\n```\n\n- With a bundler, `npm install @joralvmel/cosmos-elements @joralvmel/cosmos-tokens` and import `@joralvmel/cosmos-elements/<component>`.\n- DOM events are `cosm-*` CustomEvents that bubble and cross shadow roots.\n\nGuide: https://joralvmel.github.io/cosmos-ui/guides/html-cdn/\n\n## With a bundler\n\n```bash\nnpm install @joralvmel/cosmos-elements @joralvmel/cosmos-tokens\n```\n\n```js\nimport '@joralvmel/cosmos-tokens/tokens.css';\nimport '@joralvmel/cosmos-elements/button'; // one import per component\n```\n\n## Properties, attributes and events\n\n- Styling props are attributes in kebab-case (`full-width`, `variant=\"soft\"`); every prop is also a\n JavaScript property (`button.fullWidth = true`).\n- Events are `cosm-*` `CustomEvent`s that bubble and cross shadow roots, so you can listen on a parent.\n- Theme hooks: `--cosm-<component>-*` custom properties and `::part()` selectors (see each component API).\n\n```html\n<form>\n <cosm-button type=\"submit\">Send</cosm-button>\n</form>\n<script type=\"module\">\n document.addEventListener('cosm-press', event => console.log(event.target, event.detail));\n</script>\n```\n\n## Switching theme and mode\n\n```html\n<script type=\"module\">\n setTheme('nebula');\n setMode('dark');\n</script>\n```\n"},{"slug":"guides/nextjs","title":"Next.js","markdown":"# Next.js\n\n> Use Cosmos UI with the Next.js App Router, Server and Client Components.\n\nCosmos components are Web Components wrapped for React. They work with the App Router as long as they\nare rendered from **Client Components**.\n\n## Setup\n\n```bash\nnpm install @joralvmel/cosmos-react @joralvmel/cosmos-tokens\n```\n\n**Load the tokens and avoid a theme flash** (`app/layout.tsx`)\n\n```tsx\nimport '@joralvmel/cosmos-tokens/tokens.css';\nimport { themeInitScript } from '@joralvmel/cosmos-tokens/runtime';\nimport Script from 'next/script';\n\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\n return (\n <html lang=\"en\" data-theme=\"cosmos\" data-mode=\"system\" suppressHydrationWarning>\n <body>\n <Script id=\"cosmos-theme\" strategy=\"beforeInteractive\">\n {themeInitScript()}\n </Script>\n {children}\n </body>\n </html>\n );\n}\n```\n\n**Use components in Client Components** (`app/save-button.tsx`)\n\n```tsx\n'use client';\n\nimport { Button } from '@joralvmel/cosmos-react';\n\nexport function SaveButton() {\n return <Button onPress={() => console.log('saved')}>Save</Button>;\n}\n```\n\n- Cosmos components are Web Components: render them from Client Components (`'use client'`). Server Components can render the Client Component that wraps them.\n- The server HTML contains the custom element tag; it upgrades in the browser.\n\nGuide: https://joralvmel.github.io/cosmos-ui/guides/nextjs/\n\n## Server and Client Components\n\n- The wrappers set element properties and listen to events in effects, so the file that imports\n `@joralvmel/cosmos-react` must start with `'use client'`.\n- Server Components can render those Client Components and pass serializable props (strings,\n numbers, booleans). Handlers stay inside the Client Component.\n- The server HTML contains the custom element tag and its text; the element upgrades in the browser.\n\n```tsx\n// app/page.tsx (Server Component)\n\nexport default function Page() {\n return <SaveButton />;\n}\n```\n\n## Avoiding a theme flash\n\n`themeInitScript()` returns a small, validated inline script that restores the theme and mode stored by\n`setTheme()` / `setMode()` before the first paint. Load it with `next/script` and\n`strategy=\"beforeInteractive\"` as shown above, and keep `suppressHydrationWarning` on `<html>` because\nthe script may change `data-theme` / `data-mode` before hydration.\n\n## Tailwind\n\nUse `@tailwindcss/postcss` with the [Cosmos Tailwind theme](../tailwind/).\n"},{"slug":"guides/react-native","title":"React Native and Expo","markdown":"# React Native and Expo\n\n> Use Cosmos UI components and themes in React Native apps with Expo.\n\n`@joralvmel/cosmos-native` implements the same component contracts with React Native primitives and\nuses the same themes as the web.\n\n## Setup\n\n```bash\nnpx expo install @joralvmel/cosmos-native\n```\n\n**Provide a theme** (`app/_layout.tsx`)\n\n```tsx\nimport { CosmosThemeProvider } from '@joralvmel/cosmos-native';\nimport { Stack } from 'expo-router';\n\nexport default function Layout() {\n return (\n <CosmosThemeProvider theme=\"cosmos\" mode=\"system\">\n <Stack />\n </CosmosThemeProvider>\n );\n}\n```\n\n**Use components** (`app/index.tsx`)\n\n```tsx\nimport { Button } from '@joralvmel/cosmos-native';\n\nexport default function Home() {\n return <Button onPress={({ source }) => console.log(source)}>Save</Button>;\n}\n```\n\n- Callbacks receive the event detail directly (`onPress(detail)`).\n- `useTheme()` returns colors, spacing, radius and typography as numbers for your own styles.\n\nGuide: https://joralvmel.github.io/cosmos-ui/guides/react-native/\n\n## Theme and mode\n\n`CosmosThemeProvider` accepts `theme` (`cosmos`, `nebula`…) and `mode` (`light`, `dark` or `system`,\nwhich follows the device appearance).\n\n## Your own styles with the theme\n\n```tsx\n\nexport function Card({ title }: { title: string }) {\n const theme = useTheme();\n return (\n <View style={{ backgroundColor: theme.colors.surface, borderRadius: theme.radius.lg, padding: theme.space.lg }}>\n <Text style={{ color: theme.colors.fg, fontSize: theme.text.lg }}>{title}</Text>\n </View>\n );\n}\n```\n\n## Accessibility\n\nComponents set `accessibilityRole`, `accessibilityState` and labels, and small controls extend their\ntouch area to 44 points. Test with TalkBack and VoiceOver.\n\n## Demo app\n\nThe repository includes an Expo Router app with a screen per component: see\n[Contribute → Getting started](../../contribute/getting-started/#native-demo).\n"},{"slug":"guides/react-vite","title":"React (Vite)","markdown":"# React (Vite)\n\n> Use Cosmos UI in a React 19 app built with Vite.\n\n`@joralvmel/cosmos-react` wraps the Cosmos Web Components for React 19. Props are set as element\nproperties and event props receive the original `CustomEvent`.\n\n## Setup\n\n```bash\nnpm install @joralvmel/cosmos-react @joralvmel/cosmos-tokens\n```\n\n**Load the tokens once** (`src/main.tsx`)\n\n```tsx\nimport '@joralvmel/cosmos-tokens/tokens.css';\n```\n\n**Choose theme and mode** (`index.html`)\n\n```html\n<html data-theme=\"cosmos\" data-mode=\"system\">\n```\n\n**Use components** (`src/App.tsx`)\n\n```tsx\nimport { Button } from '@joralvmel/cosmos-react';\n\nexport default function App() {\n return <Button onPress={event => console.log(event.detail.source)}>Save</Button>;\n}\n```\n\n- Event props (`onPress`, `onChange`…) receive the original CustomEvent: read `event.detail`.\n- Change theme and mode at runtime with `setTheme()` / `setMode()` from `@joralvmel/cosmos-tokens/runtime`.\n\nGuide: https://joralvmel.github.io/cosmos-ui/guides/react-vite/\n\n## Events\n\nEvent props follow the contract names (`onPress`, `onChange`, `onOpenChange`…). Read the payload from\n`event.detail`; its type is exported by `@joralvmel/cosmos-core`.\n\n```tsx\n\nfunction Save() {\n const onPress = (event: CustomEvent<ButtonPressDetail>) => console.log(event.detail.source);\n return <Button onPress={onPress}>Save</Button>;\n}\n```\n\n## Controlled and uncontrolled state\n\nStateful components (value, open, selected tab…) work uncontrolled by default. Pass the state prop to\ncontrol it: the component then proposes changes through its event and waits for your new prop value\n([ADR 0003](https://github.com/joralvmel/cosmos-ui/blob/develop/docs/adr/0003-state-ownership-and-events.md)).\n\n## Switching theme and mode\n\n```tsx\n\nsetTheme('nebula');\nsetMode('dark'); // 'light' | 'dark' | 'system'\n```\n\nThe choice is stored in `localStorage`. To restore it before the first paint, add the script returned\nby `themeInitScript()` to `<head>` (see the [Next.js guide](../nextjs/)).\n\n## Next steps\n\n- Style your own UI with tokens or the [Tailwind theme](../tailwind/).\n- Browse the [components](../../components/status/) and their playgrounds.\n"},{"slug":"guides/tailwind","title":"Tailwind CSS","markdown":"# Tailwind CSS\n\n> Style your app with Tailwind CSS v4 utilities mapped to Cosmos tokens and themes.\n\n`@joralvmel/cosmos-tailwind` turns the Cosmos tokens into a Tailwind CSS v4 theme. Every utility follows\nthe active theme and mode, and Cosmos components keep working without Tailwind.\n\n## Setup\n\n```bash\nnpm install @joralvmel/cosmos-tailwind && npm install -D tailwindcss @tailwindcss/vite\n```\n\n**Import the Cosmos theme after Tailwind** (`src/styles.css`)\n\n```css\n@import \"tailwindcss\";\n@import \"@joralvmel/cosmos-tailwind\";\n```\n\n**Use token utilities**\n\n```html\n<div class=\"bg-surface text-fg rounded-lg shadow-md p-4 dark:bg-surface-raised\">\n <p class=\"text-fg-muted\">Uses Cosmos tokens in every theme and mode.</p>\n</div>\n```\n\n- Default Tailwind colors are disabled: use semantic colors (`bg-primary`, `text-danger-text`…).\n- `dark:` follows `data-mode` (including `system`); `theme-<name>:` targets one theme.\n\nGuide: https://joralvmel.github.io/cosmos-ui/guides/tailwind/\n\nPlugins: Vite uses `@tailwindcss/vite`; Next.js and Angular use `@tailwindcss/postcss`.\n\n## Utilities\n\n| Group | Examples |\n| --- | --- |\n| Colors | `bg-bg`, `bg-surface`, `text-fg`, `text-fg-muted`, `bg-primary text-primary-fg`, `bg-danger-subtle text-danger-text`, `border-border`, `ring-focus-ring` |\n| Scales | `bg-primary-3`, `text-neutral-11` (steps 1–12) |\n| Spacing | `p-4` (= 4 × `--cosm-space-unit`), `gap-sm`, `px-lg` |\n| Shape | `rounded-sm` … `rounded-xl`, `rounded-full`, `shadow-sm` / `shadow-md` / `shadow-lg` |\n| Typography | `text-xs` … `text-4xl`, `font-semibold`, `leading-tight` |\n\nDefault Tailwind colors (`bg-blue-500`…) are disabled so only theme colors are used.\n\n## Variants\n\n- `dark:` applies in dark mode, including `data-mode=\"system\"` when the OS is dark.\n- `theme-<name>:` targets one theme, e.g. `theme-nebula:rounded-none`.\n"},{"slug":"","title":"Cosmos UI","markdown":"# Cosmos UI\n\n> Themeable design system with Web Components, React, Angular and React Native built from one contract per component.\n\n### Contracts first\n Every component starts as a typed contract: props, events, slots, keyboard and ARIA. Web, React,\n Angular and React Native implementations are tested against it.\n### Themes you can generate\n Pick seed colors and a harmony; Cosmos builds light and dark palettes in OKLCH and verifies WCAG\n contrast and color vision deficiencies.\n### Tailwind friendly\n Utilities like `bg-primary` or `rounded-md` map to Cosmos tokens through a Tailwind CSS v4 theme.\n### AI ready\n Machine-readable references (`llms.txt`) and an MCP server keep assistants aligned with the real API.\n"},{"slug":"theming/themes","title":"Themes","markdown":"# Themes\n\n> Built-in Cosmos themes in light and dark mode, with their accessibility report.\n\nEach theme is generated from seed colors and a color harmony with `defineTheme`. The engine builds\n12-step OKLCH scales, a dark mode with its own lightness curve, status colors that keep their meaning and\nan 8-color chart palette. Every theme is validated against WCAG 2.2 AA (normative), APCA (informative)\nand simulated protanopia, deuteranopia and tritanopia.\n\n- **Cosmos** (`data-theme=\"cosmos\"`), light and dark.\n- **Nebula** (`data-theme=\"nebula\"`), light and dark.\n\n## Create a theme\n\n```ts\n\nconst aurora = defineTheme({\n name: 'aurora',\n seeds: { primary: 'oklch(0.56 0.15 165)' },\n harmony: 'triadic',\n radius: 'pill',\n});\n\nconst resolved = resolveTheme(aurora);\nconsole.log(validateTheme(resolved).pass);\nconst css = toCss([resolved]);\n```\n\nTheme names cannot be `light`, `dark` or `system`; those are mode names.\n\n## Keep an existing palette\n\nTo reuse the colors of an existing product, use them as seeds and set the exact values per\nsemantic role and mode. `validateTheme` still checks every pair; when one fails, adjust that value\ninstead of lowering the requirement.\n\n```ts\nconst brand = defineTheme({\n name: 'brand',\n seeds: { primary: '#2f6fed', accent: '#f59e0b' },\n modes: {\n light: { primary: '#2f6fed', bg: '#ffffff', surface: '#f6f7f9', fg: '#111827' },\n dark: { primary: '#7aa2ff', bg: '#0b1020', surface: '#151b2e', fg: '#e5e7eb' },\n },\n});\n\nconsole.log(validateTheme(resolveTheme(brand)).pass);\n```\n\nTypography, spacing and motion are not theme inputs. To have an assistant map a palette for you,\nsee [use a reference](../../contribute/prompt-cookbook/#use-a-reference).\n"}]