@joralvmel/cosmos-mcp 0.1.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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/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"}]
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/badge","title":"Badge","markdown":"# Badge\n\n> Static status and category labels with optional decorative icons.\n\nStatus: **stable** (web, react, angular, native).\n\n`<cosm-badge>` presents a short, noninteractive status or category label. It can also show a\ncaller-formatted count as ordinary text and an optional decorative leading icon. Use it for static\ninformation, not as a button or a control.\n\n## Playground\n\n**HTML / Web Component**\n\n```html\n<cosm-badge>Ready</cosm-badge>\n\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/badge';\n import { heart } from '@joralvmel/cosmos-icons/heart';\n\n const element = document.querySelector('cosm-badge');\n element.startIcon = heart;\n</script>\n```\n\n**React**\n\n```tsx\nimport { Badge } from '@joralvmel/cosmos-react';\nimport { heart } from '@joralvmel/cosmos-icons/heart';\n\nexport function Example() {\n return (\n <Badge startIcon={heart}>Ready</Badge>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmBadgeComponent } from '@joralvmel/cosmos-angular';\nimport { heart } from '@joralvmel/cosmos-icons/heart';\n\n@Component({\n selector: 'app-example',\n imports: [CosmBadgeComponent],\n template: `<cosm-badge [startIcon]=\"heart\">Ready</cosm-badge>`,\n})\nexport class ExampleComponent {\n readonly heart = heart;\n}\n```\n\n**React Native**\n\n```tsx\nimport { Badge } from '@joralvmel/cosmos-native';\nimport { heart } from '@joralvmel/cosmos-icons/heart';\n\nexport function Example() {\n return (\n <Badge startIcon={heart}>Ready</Badge>\n );\n}\n```\n\n## Variants\n\nChoose a soft, solid, or outlined treatment independently from the semantic tone.\n\n```html\n<cosm-badge>Ready</cosm-badge>\n<cosm-badge variant=\"solid\" tone=\"success\">Complete</cosm-badge>\n<cosm-badge variant=\"outline\" tone=\"warning\">Review</cosm-badge>\n<cosm-badge tone=\"info\" size=\"sm\">New</cosm-badge>\n```\n\nCounts are caller-formatted text; zero is rendered like any other label. Longer labels wrap rather\nthan being silently truncated.\n\n```html\n<cosm-badge>0</cosm-badge>\n<cosm-badge>This deliberately long status label wraps when space is constrained</cosm-badge>\n```\n\nCustomize spacing, typography, colors and corner radius through the CSS properties below or the\n`base`, `label` and `icon` parts. For example, `--cosm-badge-radius: var(--cosm-radius-full)` gives a\npill shape. On React Native, use `style` for the container and `textStyle` for the label; the icon\nfollows the text color. Native text keeps font scaling enabled. Custom colors must preserve contrast.\n\n## States\n\nBadge has no interactive, disabled, loading, or selection states. Its appearance is selected with\n`variant`, `tone`, and `size`.\n\n## Accessibility\n\nBadge is static content with no added role, tab stop, or live region. Give labels enough context in\nthe surrounding content. The application is responsible for contextual labeling and for announcing\nchanging counts or statuses when needed. The optional icon is decorative and does not replace text.\nUse theme tokens and verify contrast for the chosen tone and variant.\n\n## API\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `variant` | 'soft' \\| 'solid' \\| 'outline' | `soft` | Visual treatment of the static label. |\n| `tone` | 'neutral' \\| 'info' \\| 'success' \\| 'warning' \\| 'danger' | `neutral` | Semantic color intent of the static label. |\n| `size` | 'sm' \\| 'md' \\| 'lg' | `md` | Semantic label size. |\n| `startIcon` | IconDefinition | — | Optional structured decorative icon before the label. |\n\n**Slots**\n\n| Name | Description |\n| --- | --- |\n| `(default)` | Label or caller-formatted count text. |\n\n**CSS parts**\n\n| Name | Description |\n| --- | --- |\n| `base` | Rounded label container. |\n| `label` | Label or caller-formatted count text. |\n| `icon` | Optional decorative leading icon wrapper. |\n\n**CSS custom properties**\n\n| Name | Description |\n| --- | --- |\n| `--cosm-badge-background` | Badge background color. |\n| `--cosm-badge-color` | Badge text and icon color. |\n| `--cosm-badge-border` | Badge border color. |\n| `--cosm-badge-padding-inline` | Badge inline padding. |\n| `--cosm-badge-padding-block` | Badge block padding. |\n| `--cosm-badge-gap` | Space between the icon and label. |\n| `--cosm-badge-font-family` | Badge label font family. |\n| `--cosm-badge-font-size` | Badge label font size. |\n| `--cosm-badge-font-weight` | Badge label font weight. |\n| `--cosm-badge-line-height` | Badge label line height. |\n| `--cosm-badge-radius` | Badge corner radius. |\n\n## Events by platform\n\nBadge emits no events on any platform.\n\nNo events.\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- Native Button forwards a Pressable ref for composition and focus management.\n- Button has no current-page prop. Use Pagination, which marks its current page with\n `aria-current=\"page\"` on the web and selected state on native. The former `currentPage` prop was\n removed; it was never a toggle or a visual variant.\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/calendar","title":"Calendar","markdown":"# Calendar\n\n> An inline, localized Gregorian calendar for selecting one date.\n\nStatus: **stable** (web, react, angular, native).\n\n`<cosm-calendar>` is an inline, single-date calendar. Use it when people need to choose a date\ndirectly in a page; use a date picker when the calendar should open from a text field or dialog.\nDates use the Gregorian calendar and the date-only `YYYY-MM-DD` format.\n\n## Playground\n\n**HTML / Web Component**\n\n```html\n<cosm-calendar></cosm-calendar>\n\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/calendar';\n\n const element = document.querySelector('cosm-calendar');\n element.addEventListener('cosm-change', event => console.log(event.detail));\n</script>\n```\n\n**React**\n\n```tsx\nimport { Calendar } from '@joralvmel/cosmos-react';\n\nexport function Example() {\n return (\n <Calendar onChange={event => console.log(event.detail)}></Calendar>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmCalendarComponent } from '@joralvmel/cosmos-angular';\nimport type { CalendarChangeDetail } from '@joralvmel/cosmos-core';\n\n@Component({\n selector: 'app-example',\n imports: [CosmCalendarComponent],\n template: `<cosm-calendar (valueChange)=\"onValueChange($event.detail)\"></cosm-calendar>`,\n})\nexport class ExampleComponent {\n onValueChange(detail: CalendarChangeDetail) {\n console.log(detail);\n }\n}\n```\n\n**React Native**\n\n```tsx\nimport { Calendar } from '@joralvmel/cosmos-native';\n\nexport function Example() {\n return (\n <Calendar onValueChange={detail => console.log(detail)}></Calendar>\n );\n}\n```\n\n## Variants\n\nCalendar has one responsive date-grid presentation, with seven equal weekday columns. It has no\nsize, tone or variant props. The selected date's month is shown initially; without a selection, the\ncurrent month is shown. Use the month and year buttons in the heading to jump directly to a month\nor year without repeated arrow presses.\n\n```html\n<cosm-calendar default-value=\"2024-06-15\"></cosm-calendar>\n```\n\nSet `locale` to choose localized month and weekday names, the first day of the week and text\ndirection. `min` and `max` are inclusive; dates outside them are unavailable.\n\n```html\n<cosm-calendar\n default-value=\"2024-06-15\"\n min=\"2024-06-10\"\n max=\"2024-06-22\"\n locale=\"es-ES\"\n></cosm-calendar>\n```\n\n## States\n\n`value` controls the selected date. Listen for the date proposal and update `value` to accept it.\nUse `defaultValue` for an autonomous selection. Selecting an adjacent-month date also changes the\ndisplayed month.\n\n```html\n<cosm-calendar default-value=\"2024-06-15\"></cosm-calendar>\n```\n\n```tsx\n\nfunction Schedule() {\n const [value, setValue] = useState('2024-06-15');\n return <Calendar value={value} onChange={event => setValue(event.detail.value)} />;\n}\n```\n\n```html\n<cosm-calendar\n [value]=\"value\"\n (valueChange)=\"value = $event.detail.value\"\n></cosm-calendar>\n```\n\n```tsx\n\nfunction Schedule() {\n const [value, setValue] = useState('2024-06-15');\n return <Calendar value={value} onValueChange={({ value }) => setValue(value)} />;\n}\n```\n\nThe `disabled` state prevents selection and month navigation.\n\n```html\n<cosm-calendar default-value=\"2024-06-15\" disabled></cosm-calendar>\n```\n\n## Accessibility\n\n- On the web, the calendar is an ARIA grid with one day in the Tab sequence. Arrow keys move by\n day or week; Home and End move to the localized week's first and last day. Page Up and Page Down\n move by month, and Shift + Page Up/Down move by year. Enter or Space selects an enabled date.\n- The focused date stays in view as you navigate. Month changes are announced, and dates expose\n localized names and selected, today and unavailable states.\n- Month and year choices are accessible buttons; unavailable choices respect `min` and `max`.\n- Native dates use accessible button semantics and localized labels, with touch targets of at\n least 44 points. On narrow screens, the date grid scrolls horizontally to preserve those target\n sizes. React Native Web uses browser keyboard events; Android and iOS follow native focus and\n screen-reader behavior instead of imitating the web-only ARIA grid keyboard model.\n- Today is indicated separately from the selected date. Selection, focus and unavailable states\n are not conveyed by color alone.\n- The web component follows the selected Cosmos theme and supports customization through its\n documented parts and `--cosm-calendar-*` properties. React Native styling follows `useTheme()`.\n\n## API\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `value` | string | — | Controlled selected date in YYYY-MM-DD format; when supplied, selection proposals wait for the owner to update this value. |\n| `defaultValue` | string | — | Initial autonomous selected date in YYYY-MM-DD format; later changes do not reset selection. |\n| `min` | string | — | Earliest selectable date in YYYY-MM-DD format, inclusive. |\n| `max` | string | — | Latest selectable date in YYYY-MM-DD format, inclusive. |\n| `locale` | string | — | BCP 47 locale for month and weekday names, week start, and text direction; defaults to the environment locale. Invalid locale identifiers are rejected. |\n| `disabled` | boolean | `false` | Disables date selection and calendar navigation. |\n\n**CSS parts**\n\n| Name | Description |\n| --- | --- |\n| `base` | Calendar root. |\n| `header` | Month heading and navigation controls. |\n| `previous` | Previous-month navigation button. |\n| `heading` | Localized month and year heading. |\n| `next` | Next-month navigation button. |\n| `weekday` | Localized weekday heading. |\n| `grid` | Seven-column date grid. |\n| `day` | Date button, including adjacent-month dates. |\n| `month-trigger` | Button that opens direct month selection. |\n| `year-trigger` | Button that opens direct year selection. |\n| `month-option` | Month choice in the month selection view. |\n| `year-option` | Year choice in the year selection view. |\n\n**CSS custom properties**\n\n| Name | Description |\n| --- | --- |\n| `--cosm-calendar-background` | Calendar surface background. |\n| `--cosm-calendar-color` | Primary calendar text color. |\n| `--cosm-calendar-muted-color` | Adjacent-month and weekday text color. |\n| `--cosm-calendar-selected-background` | Selected-date background. |\n| `--cosm-calendar-selected-color` | Selected-date text color. |\n| `--cosm-calendar-day-size` | Minimum date target dimensions. |\n| `--cosm-calendar-gap` | Space between date targets. |\n| `--cosm-calendar-radius` | Date target corner radius. |\n| `--cosm-calendar-focus` | Visible keyboard focus indicator color. |\n| `--cosm-calendar-today-border` | Non-color-only today marker. |\n\n**Keyboard**\n\n| Keys | Action |\n| --- | --- |\n| `Tab`, `Shift+Tab` | Moves between the navigation controls and one active date. |\n| `ArrowLeft`, `ArrowRight` | Moves the active date by one day; direction follows the visual RTL/LTR order. |\n| `ArrowUp`, `ArrowDown` | Moves the active date by one week. |\n| `Home`, `End` | Moves to the first or last day of the localized week. |\n| `PageUp`, `PageDown` | Moves the active date by one month. |\n| `Shift+PageUp`, `Shift+PageDown` | Moves the active date by one year. |\n| `Enter`, `Space` | Proposes selection of the active enabled date. |\n\n## Events by platform\n\n| DOM | React | Angular | React Native | Detail | Description |\n| --- | --- | --- | --- | --- | --- |\n| `cosm-change` | `onChange` | `(valueChange)` | `onValueChange` | `CalendarChangeDetail` | Proposes an enabled selected date as a YYYY-MM-DD value; autonomous selection commits and controlled selection waits for the owner. |\n"},{"slug":"components/checkbox","title":"Checkbox","markdown":"# Checkbox\n\n> An accessible independent boolean choice with form support on the web.\n\nStatus: **stable** (web, react, angular, native).\n\nUse Checkbox for an independent yes/no choice in a form. It supports controlled and autonomous\nstate, a presentation-only mixed state, and native form submission and required validation on the\nweb.\n\n## Playground\n\n**HTML / Web Component**\n\n```html\n<cosm-checkbox label=\"Checkbox\"></cosm-checkbox>\n\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/checkbox';\n\n const element = document.querySelector('cosm-checkbox');\n element.addEventListener('cosm-checked-change', event => console.log(event.detail));\n</script>\n```\n\n**React**\n\n```tsx\nimport { Checkbox } from '@joralvmel/cosmos-react';\n\nexport function Example() {\n return (\n <Checkbox\n label=\"Checkbox\"\n onCheckedChange={event => console.log(event.detail)}\n >\n </Checkbox>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmCheckboxComponent } from '@joralvmel/cosmos-angular';\nimport type { CheckboxCheckedChangeDetail } from '@joralvmel/cosmos-core';\n\n@Component({\n selector: 'app-example',\n imports: [CosmCheckboxComponent],\n template: `<cosm-checkbox label=\"Checkbox\" (checkedChange)=\"onCheckedChange($event.detail)\"></cosm-checkbox>`,\n})\nexport class ExampleComponent {\n onCheckedChange(detail: CheckboxCheckedChangeDetail) {\n console.log(detail);\n }\n}\n```\n\n**React Native**\n\n```tsx\nimport { Checkbox } from '@joralvmel/cosmos-native';\n\nexport function Example() {\n return (\n <Checkbox\n label=\"Checkbox\"\n onCheckedChange={detail => console.log(detail)}\n >\n </Checkbox>\n );\n}\n```\n\n## Variants\n\nCheckbox has one visual treatment. Use `sm`, `md` or `lg` for the standard scale; on the web,\n`--cosm-checkbox-size` customizes only the visual box.\n\n```html\n<cosm-checkbox label=\"Small\" size=\"sm\"></cosm-checkbox>\n<cosm-checkbox label=\"Medium\" size=\"md\"></cosm-checkbox>\n<cosm-checkbox label=\"Large\" size=\"lg\"></cosm-checkbox>\n<cosm-checkbox label=\"Custom box\" style=\"--cosm-checkbox-size: 28px\"></cosm-checkbox>\n```\n\nThe default label is visible. Set `labelHidden` only when nearby content already explains the choice.\nThe label property remains the accessible name; the default slot can add noninteractive inline\ncontent, but must not contain links or buttons.\n\n## States\n\nHover an enabled checkbox with a mouse to see its themed border; checked and mixed boxes use the\ntheme's hover color. Invalid borders keep their danger color, disabled boxes do not react to hover,\nand keyboard focus retains its separate outline. Touch does not simulate hover.\n\n```html\n<cosm-checkbox label=\"Checked\" default-checked></cosm-checkbox>\n<cosm-checkbox label=\"Mixed\" indeterminate></cosm-checkbox>\n<cosm-checkbox label=\"Disabled\" disabled></cosm-checkbox>\n<cosm-checkbox\n label=\"Invalid\"\n error-text=\"Choose this option to continue.\"\n helper-text=\"This setting is required.\"\n></cosm-checkbox>\n```\n\n`indeterminate` presents a mixed state; it is not a third checked value. An autonomous activation\ncommits the proposed checked value and clears mixed presentation. A controlled checkbox waits for\nits owner to update `checked` and, when appropriate, clear `indeterminate`.\n\nWhen an invalid checkbox is checked or mixed, the box stays transparent and the indicator matches\nthe danger border. Its help and error messages keep a stable position as the checked state changes.\n\n## Usage by platform\n\n### React\n\n```tsx\n\n<Checkbox\n label=\"Accept terms\"\n checked={accepted}\n onCheckedChange={event => setAccepted(event.detail.checked)}\n name=\"terms\"\n value=\"accepted\"\n/>\n```\n\n### Angular\n\n```html\n<cosm-checkbox\n label=\"Accept terms\"\n formControlName=\"accepted\"\n required\n (checkedChange)=\"onCheckedChange($event.detail.checked)\"\n/>\n```\n\nAngular Forms uses a boolean `ControlValueAccessor`; `name` and `value` are for web form\nsubmission, not the Angular control value.\n\n### React Native\n\n```tsx\n\n<Checkbox\n label=\"Accept terms\"\n defaultChecked={false}\n onCheckedChange={({ checked }) => setAccepted(checked)}\n helperText=\"You can change this choice later.\"\n/>\n```\n\nReact Native has no HTML form association or automatic required/invalid validation. Include\nconsumer-localized required and validation information in the label, `helperText` or `errorText`.\nThe native touch target is at least 44pt even when the visual box is smaller.\n\n## Accessibility\n\n- Supply a nonempty `label`; `labelHidden` hides it visually without removing its accessible name.\n- The web component uses a native checkbox input. Tab moves focus and Space toggles it; `required`\n participates in browser form validation.\n- `indeterminate` is exposed as mixed state. `helperText` and `errorText` are associated with the\n control; a nonempty trimmed `errorText` also exposes invalid state on the web. Whitespace-only\n `errorText` is ignored.\n- React Native exposes checkbox role, checked/mixed/disabled state and the supplied help/error as\n an accessibility hint. React Native does not expose equivalent required/invalid accessibility\n states or perform form validation.\n- Localize `helperText` and `errorText` in the consumer. Do not place interactive content in the label.\n\n## API\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `label` | string | Required | Required accessible name, visible unless labelHidden is true. |\n| `labelHidden` | boolean | `false` | Visually hides the label while keeping it available to assistive technology. |\n| `checked` | boolean | `false` | Controlled checked value when supplied, including false; activation proposes changes without self-committing. |\n| `defaultChecked` | boolean | `false` | Initial autonomous checked value; later changes do not reset it. |\n| `indeterminate` | boolean | `false` | Presentation-only mixed state. Autonomous activation clears it; controlled use leaves it to the owner. |\n| `size` | 'sm' \\| 'md' \\| 'lg' | `md` | Small, medium or large visual box. |\n| `disabled` | boolean | `false` | Prevents user interaction and excludes the value from web form submission. |\n| `required` | boolean | `false` | Exposes required semantics and participates in native web form validation. Native has no automatic validation. |\n| `invalid` | boolean | `false` | Externally supplied invalid presentation state when the visible error is supplied elsewhere; web form validity remains based on required. |\n| `helperText` | string | — | Optional consumer-localized supporting text associated with the checkbox. |\n| `errorText` | string | — | Optional consumer-localized error description; a nonempty trimmed value also exposes invalid state. |\n| `name` | string | — | Web form field name; React Native has no HTML form association. |\n| `value` | string | `on` | Web form value submitted when checked and enabled; defaults to on. Angular Forms uses checked as its boolean value. |\n\n**Slots**\n\n| Name | Description |\n| --- | --- |\n| `(default)` | Optional noninteractive inline label content; links and buttons are not allowed. |\n\n**CSS parts**\n\n| Name | Description |\n| --- | --- |\n| `base` | The label and visual checkbox control. |\n| `input` | The native checkbox input and web focus target. |\n| `box` | The visible checkbox box and indicator. |\n| `label` | Visible or visually hidden label text. |\n| `help-text` | Supporting text associated with the checkbox. |\n| `error-text` | Error description associated with the checkbox. |\n\n**CSS custom properties**\n\n| Name | Description |\n| --- | --- |\n| `--cosm-checkbox-size` | Visual box width and height. |\n| `--cosm-checkbox-background` | Unchecked box background. |\n| `--cosm-checkbox-checked-background` | Checked and mixed box background. |\n| `--cosm-checkbox-color` | Checked indicator foreground. |\n| `--cosm-checkbox-border` | Box boundary color. |\n| `--cosm-checkbox-radius` | Box corner radius. |\n| `--cosm-checkbox-focus` | Visible keyboard focus indicator color. |\n| `--cosm-checkbox-gap` | Space between the box and label. |\n\n**Keyboard**\n\n| Keys | Action |\n| --- | --- |\n| `Tab`, `Shift+Tab` | Moves focus to or from the enabled checkbox. |\n| `Space` | Toggles checked state and emits a checkedChange proposal. |\n\n## Events by platform\n\n| DOM | React | Angular | React Native | Detail | Description |\n| --- | --- | --- | --- | --- | --- |\n| `cosm-checked-change` | `onCheckedChange` | `(checkedChange)` | `onCheckedChange` | `CheckboxCheckedChangeDetail` | Proposes the next checked value after enabled user activation; controlled state waits for the owner. |\n"},{"slug":"components/dialog","title":"Dialog","markdown":"# Dialog\n\n> Modal content with a title, body and actions.\n\nStatus: **stable** (web, react, angular, native).\n\nDialog presents content above an inert background. Use it when a task needs the user's attention\nbefore they return to the rest of the interface. Supply a meaningful title, body and actions;\nforms and confirmations are composed as content rather than separate dialog variants.\n\n## Playground\n\n**HTML / Web Component**\n\n```html\n<cosm-button type=\"button\" id=\"open-dialog\">Open dialog</cosm-button>\n<cosm-dialog>\n <h2 slot=\"title\">Review details</h2>\n <p>Review the details before continuing.</p>\n <cosm-button slot=\"actions\" type=\"button\" id=\"done\">Done</cosm-button>\n</cosm-dialog>\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/dialog';\n import '@joralvmel/cosmos-elements/button';\n const dialog = document.querySelector('cosm-dialog');\n document.querySelector('#open-dialog').addEventListener('cosm-press', () => dialog.requestOpen());\n document.querySelector('#done').addEventListener('cosm-press', () => dialog.requestClose());\n dialog.addEventListener('cosm-open-change', event => {\n console.log(event.detail);\n });\n</script>\n```\n\n**React**\n\n```tsx\nimport { useRef } from 'react';\nimport { Button, Dialog } from '@joralvmel/cosmos-react';\nimport type { CosmDialog } from '@joralvmel/cosmos-elements/dialog';\n\nexport function Example() {\n const dialog = useRef<CosmDialog>(null);\n return (\n <>\n <Button onPress={() => dialog.current?.requestOpen()}>Open dialog</Button>\n <Dialog\n ref={dialog}\n onOpenChange={event => {\n const detail = event.detail;\n console.log(detail);\n }}\n >\n <h2 slot=\"title\">Review details</h2>\n <p>Review the details before continuing.</p>\n <Button slot=\"actions\" onPress={() => dialog.current?.requestClose()}>Done</Button>\n </Dialog>\n </>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { Component, ViewChild } from '@angular/core';\nimport { CosmButtonComponent, CosmDialogComponent } from '@joralvmel/cosmos-angular';\nimport type { DialogOpenChangeDetail } from '@joralvmel/cosmos-core';\n\n@Component({\n selector: 'app-example',\n imports: [CosmButtonComponent, CosmDialogComponent],\n template: `\n <cosm-button type=\"button\" (press)=\"dialog?.requestOpen()\">Open dialog</cosm-button>\n <cosm-dialog (openChange)=\"onOpenChange($event)\">\n <h2 slot=\"title\">Review details</h2>\n <p>Review the details before continuing.</p>\n <cosm-button slot=\"actions\" type=\"button\" (press)=\"dialog?.requestClose()\">Done</cosm-button>\n </cosm-dialog>\n `,\n})\nexport class ExampleComponent {\n @ViewChild(CosmDialogComponent) dialog?: CosmDialogComponent;\n onOpenChange(event: CustomEvent<DialogOpenChangeDetail>) {\n console.log(event.detail);\n }\n}\n```\n\n**React Native**\n\n```tsx\nimport { type ComponentRef, useRef } from 'react';\nimport { Button, Dialog, type DialogHandle } from '@joralvmel/cosmos-native';\nimport { type Pressable, Text } from 'react-native';\n\nexport function Example() {\n const dialog = useRef<DialogHandle>(null);\n const opener = useRef<ComponentRef<typeof Pressable>>(null);\n return (\n <>\n <Button ref={opener} onPress={() => dialog.current?.requestOpen()}>Open dialog</Button>\n <Dialog\n ref={dialog}\n title=\"Review details\"\n returnFocusTarget={opener}\n onOpenChange={detail => {\n console.log(detail);\n }}\n actions={<Button onPress={() => dialog.current?.requestClose()}>Done</Button>}\n >\n <Text>Review the details before continuing.</Text>\n </Dialog>\n </>\n );\n}\n```\n\nUse the open button to request opening. Choose an autonomous or controlled `open` value, and try\nthe basic, form and confirmation examples, long-content and close-veto controls before opening.\nIn controlled mode the preview owner accepts uncanceled proposals. Changing `defaultOpen`\nremounts the preview. Initial focus goes to the form field in the form example and to the body\nbutton otherwise; return focus goes to the opening button. Example selection, long content and\nveto affect the preview only; generated snippets show the basic example. If a close request is\nvetoed, use the action inside the dialog to allow close requests again.\n\n## Variants\n\n<DialogExamples section=\"variants\" />\n\n`presentation` selects `standard` or `fullscreen`. Standard sizes to its content, constrained by\nthe available space and `size`: `sm` caps at 400, `md` (the default) at 640, and `lg` at 960 CSS\npixels or native logical points. The dialog is always centered.\n\nFullscreen uses the available viewport or native safe area. `responsiveFullscreen` switches to\nfullscreen below 640 CSS pixels or logical points; explicit fullscreen takes precedence. Long\ncontent scrolls in the body; the title and actions remain visible when space permits.\n\n### Custom width\n\nPrefer `size` for standard widths. For other widths:\n\n- **Web:** set `--cosm-dialog-max-width` to replace the standard maximum (it defaults to the\n `size` value), and style `::part(base)` with `width: 100%` to fill the available width up to\n that maximum. The surface never exceeds the viewport.\n\n ```css\n cosm-dialog.wide {\n --cosm-dialog-max-width: 720px;\n }\n cosm-dialog.wide::part(base) {\n width: 100%;\n }\n ```\n\n- **Native:** pass a surface `style`, which is applied after the defaults, for example\n `style={{ maxWidth: 720 }}` or `style={{ width: '100%' }}`. A numeric `maxWidth` is still\n clamped to the available viewport.\n\nThe web surface exposes parts and CSS custom properties listed below. Localize `closeLabel` for\nthe built-in close IconButton; its X is decorative. On native, `title`, `description` and\n`actions` accept content, and `style` customizes the surface.\n\n## States\n\n<DialogExamples section=\"states\" />\n\nOmit `open` for autonomous state and use `defaultOpen` for its initial value. Supplying `open`,\nincluding `false`, makes the owner responsible for accepting visibility proposals. Use\n`requestOpen()` and `requestClose()` to request changes from an application action; they do not\noverride a controlled owner.\n\nClosing can be vetoed synchronously with `preventDefault()`. A rejected close leaves the dialog\nopen and does not restore focus. Close requests distinguish the close button, Escape, Android\nBack, backdrop and application actions. Escape and Android Back are enabled by default; backdrop\npresses do not dismiss by default. On web, cancel the original event or call\n`event.detail.preventDefault()`; native receives the detail directly.\n\n## Accessibility\n\n- Provide a descriptive title and use the optional description for short explanatory text.\n Supply accessible names for interactive content and localize the built-in close control.\n- On web, focus enters the modal and Tab and Shift+Tab remain inside it. On closure, focus returns\n to the invoking control or an available logical fallback. Initial and return focus targets can\n be customized.\n- On native, pass a usable `returnFocusTarget` to restore accessibility focus. React Native does\n not expose the current invoker for the dialog to discover automatically. Native focus and\n accessibility use platform mechanisms; DOM keyboard behavior is not assumed.\n Native hardware-keyboard Escape and iOS swipe dismissal are not supported. Guaranteed\n coordination of nested dialogs is outside the component's scope.\n- See the [WAI-ARIA modal dialog pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/).\n\n## API\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `open` | boolean | `false` | Committed visibility; supplying this prop, including false, controls state. |\n| `defaultOpen` | boolean | `false` | Initial autonomous visibility; subsequent changes do not reset state. |\n| `presentation` | 'standard' \\| 'fullscreen' | `standard` | Centered standard surface or fullscreen surface. |\n| `size` | 'sm' \\| 'md' \\| 'lg' | `md` | Maximum standard width: sm 400, md 640, lg 960 pixels or logical points. |\n| `responsiveFullscreen` | boolean | `false` | Use fullscreen when available viewport width is below 640 pixels or logical points. |\n| `closeLabel` | string | `Close` | Non-empty localized accessible name of the built-in close button. |\n| `closeOnEscape` | boolean | `true` | Request closure on unhandled Escape on web. |\n| `closeOnAndroidBack` | boolean | `true` | Request closure on Android Back; consume Back even if the request is canceled. |\n| `closeOnBackdropPress` | boolean | `false` | Request closure when the backdrop itself is pressed. |\n| `initialFocusTarget` | DialogFocusTarget | — | Optional platform focus target used on committed opening; it must be inside the dialog. |\n| `returnFocusTarget` | DialogFocusTarget | — | Optional platform focus target used after committed closure. |\n\n**Slots**\n\n| Name | Description |\n| --- | --- |\n| `title` | Required accessible title content. |\n| `description` | Optional short accessible description. |\n| `(default)` | Scrollable body content. |\n| `actions` | Consumer-supplied actions. |\n\n**CSS parts**\n\n| Name | Description |\n| --- | --- |\n| `backdrop` | Modal backdrop. |\n| `base` | Dialog surface. |\n| `header` | Title and close control area. |\n| `title` | Title container. |\n| `description` | Description container. |\n| `body` | Scrollable body. |\n| `actions` | Actions container. |\n| `close` | Close IconButton. |\n\n**CSS custom properties**\n\n| Name | Description |\n| --- | --- |\n| `--cosm-dialog-z-index` | Modal stacking level. |\n| `--cosm-dialog-max-width` | Standard surface maximum width. |\n| `--cosm-dialog-backdrop` | Backdrop background. |\n| `--cosm-dialog-surface` | Surface background. |\n| `--cosm-dialog-border` | Surface border. |\n| `--cosm-dialog-radius` | Surface radius. |\n| `--cosm-dialog-shadow` | Surface shadow. |\n| `--cosm-dialog-padding` | Section spacing. |\n\n**Keyboard**\n\n| Keys | Action |\n| --- | --- |\n| `Escape` | On web request close unless handled by a child or disabled. |\n| `Tab`, `Shift+Tab` | Keep keyboard focus inside the modal. |\n| `Android Back` | On Android request close unless disabled. |\n\n## Events by platform\n\n| DOM | React | Angular | React Native | Detail | Description |\n| --- | --- | --- | --- | --- | --- |\n| `cosm-open-change` | `onOpenChange` | `(openChange)` | `onOpenChange` | `DialogOpenChangeDetail` | Proposes opening or closing; only closing is synchronously cancelable. (cancelable) |\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`, `variant` or `color`; leave it unlabeled so\nit stays decorative. With the default `currentColor` it follows the button's tone and state.\n\n## States\n\nFrom left to right: disabled action, autonomous Favorite toggle (initially pressed), and controlled\nPin toggle (initially unpressed). The Favorite heart switches to `variant=\"filled\"` while pressed\nand back to `outline` when released; its label stays “Favorite”. The controlled example accepts\neach proposed value and writes it 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- Native `style` preserves larger numeric `minHeight`/`minWidth` values, while keeping\n each touch-target dimension at least 44 points. This changes the target, not the icon geometry.\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 select a card to update\nthe preview and the highlighted code. Switch between HTML, React, Angular and React Native, then\nuse **Copy code** for the selected technology. Thumbnails load in batches.\nThe color dropdown sits alongside the filters. Choose the inherited color or a Cosmos theme token;\nit updates the selected icon, thumbnails and every snippet.\n**Preview size** is the only size control; choose **Custom** to enter a positive number of pixels.\nThe **variant** dropdown switches the selected icon and thumbnails between `outline` and `filled`.\nThe optional label is in the same toolbar; there is no separate advanced panel. Thumbnails share\nthe preview's theme and light/dark mode so color tokens 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### Filled\n\n`variant` is `outline` (default) or `filled`. `outline` draws only the stroke. `filled` also fills\nthe icon shapes with the same resolved `color` as the stroke, which suits favorite or rating states\nsuch as a star or heart. Nodes with their own explicit fill in the definition, including `none`\ncut-outs, keep it in both variants. On the web `variant` is reflected as an attribute.\n\n```tsx\n\n<Icon icon={star} variant=\"filled\" color=\"var(--cosm-primary)\" />;\n<Icon icon={heart} variant={favorite ? 'filled' : 'outline'} />;\n```\n\nInside a toggle IconButton, switch the child Icon to `filled` while pressed and keep the button\nlabel stable (for example “Favorite”). The button's pressed state is what assistive technology\nannounces; the fill is visual only and does not replace the label.\n\n### Color\n\n`color` defaults to `currentColor`: on the web the icon inherits the surrounding text color, and on\nnative it follows the parent control (for example IconButton, Badge or TextField) or\n`theme.colors.fg`. Any other value paints the outline and every node whose fill is `currentColor`\n(for example the dots of `brain-circuit`). Nodes with their own explicit fill, including `none`,\nkeep it. Icons always use the standard outline width of 2 viewBox units, which scales with the\nicon size.\n\nColors must be supported by the platform. URLs, `javascript:`, declarations (`;`, `{`, `}`),\nbackslashes and control characters are rejected. CSS custom properties such as\n`var(--cosm-primary)` work on the web; native needs a React Native color string.\n\n```tsx\n\n<Icon icon={brainCircuit} size={32} color=\"var(--cosm-primary)\" />;\n```\n\nEach row below shows `currentColor`, `var(--cosm-primary)` and `var(--cosm-danger)`; the heart and\nstar rows use `variant=\"filled\"`.\n\n<IconColorExamples label=\"Icons with inherited, primary and danger colors\" />\n\nIn React Native use `const theme = useTheme()` and pass `color={theme.colors.primary}` instead.\nThe Playground accepts `currentColor`, Cosmos color tokens such as `var(--cosm-primary)` and\nhex/rgb/hsl/named colors so every tab is valid; its React Native tab turns token colors into\n`theme.colors` values from `useTheme()`.\n\nIcon does not expose raw fill, stroke or stroke-width knobs. Use `variant=\"filled\"` for a solid\nshape painted with `color`; the outline width stays 2.\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, provide a concise nonempty `label`; the icon then becomes an informative image.\n\n```tsx\n<Icon icon={house} label=\"Home\" />;\n```\n\n## Accessibility\n\n- Icons without a label, or with an empty or whitespace-only label, are decorative: hidden from\n assistive technology and not focusable.\n- Icons with a nonempty label expose one image role (`role=\"img\"` on the web, an image on native)\n and the trimmed label as accessible name.\n- Inside Button, IconButton, Badge, TextField and other controls, leave the Icon unlabeled; the\n control supplies the accessible name.\n- Do not use an icon alone as an interactive control. Put it inside a separately labeled button.\n\n### Migrating from 0.x icon props\n\n- Remove `decorative`; keep `label` only on icons that convey meaning.\n- Replace `stroke` with `color`. Remove `strokeWidth`; Icon always uses an outline of width 2 and\n keeps explicit node fills from the definition.\n- Replace `fill` with `variant=\"filled\"` where you wanted a solid shape in the icon color (for\n example `fill=\"currentColor\"`), and drop `fill=\"none\"`, which is the default `outline`. A fill\n color different from the outline is no longer supported.\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| `variant` | 'outline' \\| 'filled' | `outline` | Appearance. outline draws only the stroke; filled also fills the shapes with the icon color (for example a favorite star or heart). Explicit node fills in the definition always win. |\n| `color` | string | `currentColor` | Icon color (stroke, currentColor fills and the filled variant). currentColor inherits the surrounding text color on web and the parent control or theme foreground on native; otherwise a supported color without URLs. |\n| `label` | string | — | Accessible name. A nonempty label makes the icon an informative image; without one the icon is decorative and hidden from assistive technology. |\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.\nArrow keys move focus; Enter or Space selects. 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) or `lg` and sets the minimum **option** height. Descriptions and\ntext scaling can make rows taller. Native touch targets stay at least 44 units at every size. On the\nweb, `--cosm-listbox-option-height` sets another minimum option height.\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; sizes are not fixed clipping heights.\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' | `md` | Small, medium or large option rows. 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/pagination","title":"Pagination","markdown":"# Pagination\n\n> Localized button navigation for a known number of pages.\n\nStatus: **stable** (web, react, angular, native).\n\n`<cosm-pagination>` navigates a known, finite collection of pages with Cosmos Button and\nIconButton controls. Use it for in-place results, not URL navigation. It follows ordinary\n[navigation landmark](https://www.w3.org/WAI/ARIA/apg/practices/landmark-regions/) semantics;\nthere is no special pagination keyboard pattern.\n\n## Playground\n\n**HTML / Web Component**\n\n```html\n<cosm-pagination label=\"Pagination\"></cosm-pagination>\n\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/pagination';\n\n const element = document.querySelector('cosm-pagination');\n element.addEventListener('cosm-change', event => console.log(event.detail));\n</script>\n```\n\n**React**\n\n```tsx\nimport { Pagination } from '@joralvmel/cosmos-react';\n\nexport function Example() {\n return (\n <Pagination\n label=\"Pagination\"\n onChange={event => console.log(event.detail)}\n >\n </Pagination>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmPaginationComponent } from '@joralvmel/cosmos-angular';\nimport type { PaginationChangeDetail } from '@joralvmel/cosmos-core';\n\n@Component({\n selector: 'app-example',\n imports: [CosmPaginationComponent],\n template: `<cosm-pagination label=\"Pagination\" (pageChange)=\"onPageChange($event.detail)\"></cosm-pagination>`,\n})\nexport class ExampleComponent {\n onPageChange(detail: PaginationChangeDetail) {\n console.log(detail);\n }\n}\n```\n\n**React Native**\n\n```tsx\nimport { Pagination } from '@joralvmel/cosmos-native';\n\nexport function Example() {\n return (\n <Pagination\n label=\"Pagination\"\n onPageChange={detail => console.log(detail)}\n >\n </Pagination>\n );\n}\n```\n\nThe empty `page` control selects autonomous ownership. Set `page` to preview a controlled\nproposal: the component emits a change but waits for the application to update that prop.\nChanging `defaultPage` remounts the playground example; it is otherwise initial-only.\n\n## Variants\n\nThe current page supports `solid` (default), `soft` and `outline`; other controls are ghost.\nSizes are `sm`, `md` (default) and `lg`. Presentation is explicit, never changed by a breakpoint.\n\n```html\n<cosm-pagination label=\"Solid results\" total-pages=\"20\" default-page=\"5\"></cosm-pagination>\n```\n```html\n<cosm-pagination label=\"Soft results\" total-pages=\"20\" default-page=\"5\" variant=\"soft\" size=\"sm\"></cosm-pagination>\n```\n```html\n<cosm-pagination label=\"Outline results\" total-pages=\"20\" default-page=\"5\" variant=\"outline\" size=\"lg\" show-first-last></cosm-pagination>\n```\n```html\n<cosm-pagination label=\"Compact results\" total-pages=\"20\" default-page=\"5\" presentation=\"compact\"></cosm-pagination>\n```\n\nThe numbered range keeps seven equal-width positions (or all pages for smaller totals), including\nfirst/last and the current page. Extra neighbors fill the range near either boundary.\nEllipses occupy a full position, so changing pages does not move the navigation arrows.\nLarger gaps are decorative ellipses, never menus.\nFirst/last action buttons are optional and off by default.\nOn the web (including React and Angular), selection colors transition smoothly and changing\nnumbers crossfade in fixed slots using the normal-duration theme token. In the middle range,\nthe selected control stays centered instead of moving a different button into its place.\nInteraction is immediate, focus follows the logical page, and reduced-motion preferences\ndisable these effects.\n\nCustomize the shared theme tokens, exported parts or CSS variables. For example, set\n`--cosm-pagination-min-height: 56px` and `--cosm-pagination-radius: 999px` on the host.\nCurrent-page colors have dedicated hooks; normal Button hover, active and focus behavior\nremains in use. React Native accepts `style` for the container and `controlStyle` for controls;\nnumeric minimum dimensions are never smaller than 44 points.\n\n```html\n<cosm-pagination label=\"Custom results\" total-pages=\"12\" default-page=\"4\" style=\"--cosm-pagination-min-height: 56px; --cosm-pagination-radius: 999px;\"></cosm-pagination>\n```\n\n## States\n\nProvide a nonnegative safe integer `totalPages` and a non-empty localized `label`.\nPages are one-based safe integers. Invalid types, fractions and negative counts throw.\nValid out-of-range pages clamp to the available range; zero pages retain an anchor of one.\nZero or one page renders no navigation.\n\nAutonomous state starts at `defaultPage` (default 1), then commits user selections and clamps\npermanently if totals shrink. Controlled `page` retains the application's requested value:\nif totals grow again, it can become visible again. Prop corrections emit no change event.\nActivating the current page, a boundary or any disabled control emits nothing.\n\n```html\n<cosm-pagination label=\"First results page\" total-pages=\"10\" show-first-last></cosm-pagination>\n<cosm-pagination label=\"Unavailable results\" total-pages=\"10\" default-page=\"5\" disabled></cosm-pagination>\n```\n\nThere is no loading state. The application owns fetching, result announcements and moving\nfocus into new content. Page-size selection, jump input, links, unknown totals and infinite\nscroll are intentionally outside this component.\n\n## Accessibility\n\n- The web landmark uses the required `label`. Buttons are `type=\"button\"`, not form submits.\n- Tab/Shift+Tab moves through enabled buttons; Enter/Space activates. Arrow keys are not intercepted.\n- The internal native web button exposes [`aria-current=\"page\"`](https://www.w3.org/TR/wai-aria-1.2/#aria-current),\n not `aria-pressed`. React Native exposes selected state; Expo Web also exposes `aria-current`.\n- Ellipses are hidden from assistive technology. Compact mode replaces numbers with a plain summary,\n not an automatic live region.\n- All visible content and accessible names are localizable. `pageLabel` needs `{page}`;\n `summaryLabel` needs `{page}` and `{total}`. `locale` formats numbers only: it does not translate labels.\n- Set `direction=\"rtl\"` explicitly to reverse layout and directional icons. For Arabic-Indic digits,\n a locale such as `ar-EG-u-nu-arab` requests the numbering system explicitly.\n- Native touch targets are at least 44 points. Browser controls retain Button focus rings and\n reduced-motion behavior. Browser and native screen-reader output may differ.\n\n```html\n<cosm-pagination label=\"Resultados\" total-pages=\"12\" default-page=\"3\" locale=\"es\" presentation=\"compact\" previous-label=\"Página anterior\" next-label=\"Página siguiente\" page-label=\"Página {page}\" summary-label=\"Página {page} de {total}\"></cosm-pagination>\n<cosm-pagination label=\"RTL results\" total-pages=\"12\" default-page=\"5\" direction=\"rtl\" locale=\"ar-EG-u-nu-arab\"></cosm-pagination>\n```\n\n## API\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `totalPages` | number | Required | Required nonnegative safe integer page count. |\n| `page` | number | — | Controlled one-based safe integer page; out-of-range values are displayed clamped. |\n| `defaultPage` | number | `1` | Initial one-based page for autonomous state. |\n| `label` | string | Required | Required localized navigation landmark label. |\n| `previousLabel` | string | `Previous page` | Previous button label. |\n| `nextLabel` | string | `Next page` | Next button label. |\n| `firstLabel` | string | `First page` | First button label. |\n| `lastLabel` | string | `Last page` | Last button label. |\n| `pageLabel` | string | `Page {page}` | Page button label template; {page} is replaced with the localized number. |\n| `summaryLabel` | string | `Page {page} of {total}` | Compact summary template with {page} and {total} placeholders. |\n| `locale` | string | — | Locale for formatted page numbers. |\n| `direction` | 'ltr' \\| 'rtl' | `ltr` | Layout and directional icon direction. |\n| `presentation` | 'numbered' \\| 'compact' | `numbered` | Show up to seven fixed-width numbered positions or a compact summary. |\n| `variant` | 'solid' \\| 'soft' \\| 'outline' | `solid` | Selected page emphasis. |\n| `size` | 'sm' \\| 'md' \\| 'lg' | `md` | Control size. |\n| `showFirstLast` | boolean | `false` | Show first and last page controls. |\n| `disabled` | boolean | `false` | Disable all controls. |\n\n**CSS parts**\n\n| Name | Description |\n| --- | --- |\n| `base` | Navigation landmark. |\n| `control` | Navigation control. |\n| `page` | Page control. |\n| `current` | Current page control. |\n| `ellipsis` | Decorative omitted-page indicator. |\n| `summary` | Compact summary. |\n\n**CSS custom properties**\n\n| Name | Description |\n| --- | --- |\n| `--cosm-pagination-gap` | Gap between controls. |\n| `--cosm-pagination-min-height` | Minimum control height. |\n| `--cosm-pagination-radius` | Control corner radius. |\n| `--cosm-pagination-current-background` | Current page background. |\n| `--cosm-pagination-current-color` | Current page foreground. |\n| `--cosm-pagination-current-border` | Current page border color. |\n\n**Keyboard**\n\n| Keys | Action |\n| --- | --- |\n| `Tab`, `Shift+Tab` | Moves between enabled controls. |\n| `Enter`, `Space` | Activates the focused control. |\n\n## Events by platform\n\n| DOM | React | Angular | React Native | Detail | Description |\n| --- | --- | --- | --- | --- | --- |\n| `cosm-change` | `onChange` | `(pageChange)` | `onPageChange` | `PaginationChangeDetail` | Proposes a different page after enabled user activation. |\n\nThe change detail is `{ page: number }`. In controlled mode, assign the proposed value back:\nHTML uses `event.detail.page`, React uses `onChange={event => setPage(event.detail.page)}`,\nAngular uses `(pageChange)=\"page = $event.detail.page\"`, and React Native uses\n`onPageChange={({ page }) => setPage(page)}`. The Playground generates complete imports\nand platform syntax; add your application's state update rather than only logging the proposal.\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`, `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 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 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 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 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\nThe panel sits at the theme `space-sm` distance from the trigger (8 CSS pixels or native logical\nunits by default). With `arrow`, the distance is measured to the tip, not the panel edge. The\ndecorative 16-by-8 pointer follows the actual side and trigger center after collision handling;\nit is hidden when it cannot point without crossing a corner or viewport edge.\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 adapt automatically when there is insufficient space: the panel\nmoves to the opposite side when that side has more room, then shifts to stay within the viewport\nor native safe area. Placement follows scrolling, resizing and orientation changes. 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. 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 and opening never moves it: focus stays on the trigger and the panel\n follows it in the Tab order on web. If your content needs focus on opening (for example a\n field), move focus to it yourself after the panel opens; on native, request accessibility\n focus on your own content.\n- When the panel closes by the trigger, Escape, the X, an action or Android Back while focus is\n inside it, focus returns to the trigger. Outside presses and closes the owner makes without a\n request never move focus.\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| `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| `side` | 'top' \\| 'right' \\| 'bottom' \\| 'left' | `bottom` | Requested physical side; actual placement flips to the opposite side when that reduces viewport/safe-area overflow, then shifts within bounds. |\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\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/radio-group","title":"Radio Group","markdown":"# Radio Group\n\n> Accessible single selection with keyboard navigation and Web form support.\n\nStatus: **stable** (web, react, angular, native).\n\nRadio Group lets a person choose one option from a labeled set. Use it when the available choices\nshould remain visible; use a different control when the choice is optional but space is limited.\n\n## Playground\n\n**HTML / Web Component**\n\n```html\n<cosm-radio-group label=\"RadioGroup\"></cosm-radio-group>\n\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/radio-group';\n const contactMethods = [{\"value\":\"email\",\"label\":\"Email\",\"description\":\"Receive updates by email.\"},{\"value\":\"phone\",\"label\":\"Phone\",\"description\":\"Receive updates by text.\"},{\"value\":\"mail\",\"label\":\"Mail\",\"disabled\":true}];\n\n const element = document.querySelector('cosm-radio-group');\n element.options = contactMethods;\n element.addEventListener('cosm-change', event => console.log(event.detail));\n</script>\n```\n\n**React**\n\n```tsx\nimport { RadioGroup } from '@joralvmel/cosmos-react';\nconst contactMethods = [{\"value\":\"email\",\"label\":\"Email\",\"description\":\"Receive updates by email.\"},{\"value\":\"phone\",\"label\":\"Phone\",\"description\":\"Receive updates by text.\"},{\"value\":\"mail\",\"label\":\"Mail\",\"disabled\":true}] as const;\n\nexport function Example() {\n return (\n <RadioGroup\n label=\"RadioGroup\"\n options={contactMethods}\n onChange={event => console.log(event.detail)}\n >\n </RadioGroup>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmRadioGroupComponent } from '@joralvmel/cosmos-angular';\nconst contactMethods = [{\"value\":\"email\",\"label\":\"Email\",\"description\":\"Receive updates by email.\"},{\"value\":\"phone\",\"label\":\"Phone\",\"description\":\"Receive updates by text.\"},{\"value\":\"mail\",\"label\":\"Mail\",\"disabled\":true}] as const;\nimport type { RadioGroupChangeDetail } from '@joralvmel/cosmos-core';\n\n@Component({\n selector: 'app-example',\n imports: [CosmRadioGroupComponent],\n template: `<cosm-radio-group label=\"RadioGroup\" [options]=\"contactMethods\" (valueChange)=\"onValueChange($event.detail)\"></cosm-radio-group>`,\n})\nexport class ExampleComponent {\n readonly contactMethods = contactMethods;\n onValueChange(detail: RadioGroupChangeDetail) {\n console.log(detail);\n }\n}\n```\n\n**React Native**\n\n```tsx\nimport { RadioGroup } from '@joralvmel/cosmos-native';\nconst contactMethods = [{\"value\":\"email\",\"label\":\"Email\",\"description\":\"Receive updates by email.\"},{\"value\":\"phone\",\"label\":\"Phone\",\"description\":\"Receive updates by text.\"},{\"value\":\"mail\",\"label\":\"Mail\",\"disabled\":true}] as const;\n\nexport function Example() {\n return (\n <RadioGroup\n label=\"RadioGroup\"\n options={contactMethods}\n onValueChange={detail => console.log(detail)}\n >\n </RadioGroup>\n );\n}\n```\n\nTry **Contact methods**, **Plans**, or **Frequency**. Switching examples resets the preview selection.\nUse `size` to change the circle and dot: `sm`, `md` (default) or `lg`. The minimum hit area stays\nthe same. On the web, `--cosm-radio-group-control-size` sets another circle diameter.\n\nThe options control uses named sample collections. The playground shows autonomous and controlled\nsnippets for Web, React, Angular, and React Native.\n\n## Variants\n\nRadio Group has one standard circular appearance and a medium visual size. Choose vertical or\nwrapping horizontal orientation, and use the documented CSS custom properties to adapt its spacing\nand colors.\n\n<RadioGroupExamples />\n\n## States\n\n`defaultValue` initializes an autonomous group; it does not reset a group after initialization.\nSupplying `value`, including `null`, makes the group controlled. In controlled mode, the owner\ndecides whether to accept a proposed selection.\n\n<RadioGroupExamples kind=\"states\" />\n\n## Usage by platform\n\n### React\n\n```tsx\n\n<RadioGroup\n label=\"Contact method\"\n options={contactMethods}\n value={contactMethod}\n onChange={event => setContactMethod(event.detail.value)}\n/>;\n```\n\n### Angular\n\n```html\n<cosm-radio-group\n label=\"Contact method\"\n [options]=\"contactMethods\"\n formControlName=\"contactMethod\"\n name=\"contact-method\"\n/>\n```\n\nAngular Forms integrates through `ControlValueAccessor`. Without a form control, listen to\n`valueChange` and assign an accepted value explicitly.\n\n### React Native\n\n```tsx\n\n<RadioGroup\n label=\"Contact method\"\n options={contactMethods}\n value={contactMethod}\n onValueChange={({ value }) => setContactMethod(value)}\n/>;\n```\n\nReact Native has no HTML form association or browser constraint validation. Provide localized\nrequired and validation feedback through the label, help text, and error text as appropriate.\nA nonempty `errorText` also marks the group invalid; whitespace-only `errorText` is ignored, and\n`invalid` stays available for errors shown elsewhere.\n\n## Accessibility\n\n- Provide a visible, nonempty group `label` and concise labels for every option. Optional\n descriptions add context without replacing the label.\n- Tab enters the selected option, or the first enabled option when none is selected. Space selects\n the focused option. Arrow keys move focus and selection with wrapping, skipping disabled options.\n- Web uses native radio inputs within a labeled fieldset and supports form submission, required\n validity, disabled fieldsets, and reset. React and Angular use the same Web implementation.\n- React Native exposes `radiogroup` and `radio` semantics, checked and disabled state, and touch\n targets of at least 44 points. React Native Web also supports the documented keyboard behavior;\n HTML form behavior does not apply on native platforms.\n- Keep keyboard focus distinct from selection when customizing colors. Invalid and disabled states\n retain their semantic treatment.\n- Toolbar behavior, clearing a selection, multiple selection, custom option renderers, and native\n hardware-keyboard navigation are not part of this component.\n\n## API\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `label` | string | Required | Required visible accessible name for the group. |\n| `options` | RadioGroupOptions | Required | Readonly flat options with unique nonempty values and labels, optional descriptions and disabled states. |\n| `value` | RadioGroupValue | — | Controlled selected value; null means no selection, and a supplied null remains controlled. |\n| `defaultValue` | RadioGroupValue | — | Initial autonomous selection; null by default. |\n| `size` | 'sm' \\| 'md' \\| 'lg' | `md` | Small, medium or large radio indicator. |\n| `orientation` | 'vertical' \\| 'horizontal' | `vertical` | Vertical list or wrapping horizontal options. |\n| `disabled` | boolean | `false` | Prevents interaction and excludes the value from Web form submission. |\n| `required` | boolean | `false` | Requires a selection in Web form validation; Native exposes descriptive semantics. |\n| `invalid` | boolean | `false` | Externally supplied invalid presentation state when the visible error is supplied elsewhere. |\n| `helperText` | string | — | Optional supporting text associated with the group. |\n| `errorText` | string | — | Optional consumer-localized error text; a nonempty trimmed value also exposes invalid state. |\n| `name` | string | — | Web form field name; React Native has no HTML form association. |\n\n**CSS parts**\n\n| Name | Description |\n| --- | --- |\n| `base` | Group wrapper and accessible fieldset. |\n| `label` | Visible group label. |\n| `options` | Option collection. |\n| `option` | Selectable option row. |\n| `input` | Native radio input and Web focus target. |\n| `control` | Visible circular radio boundary. |\n| `indicator` | Selected radio dot. |\n| `option-label` | Primary option text. |\n| `description` | Optional option description. |\n| `help-text` | Supporting text associated with the group. |\n| `error-text` | Error description associated with the group. |\n\n**CSS custom properties**\n\n| Name | Description |\n| --- | --- |\n| `--cosm-radio-group-gap` | Space between option rows. |\n| `--cosm-radio-group-option-gap` | Space between the radio control and option content. |\n| `--cosm-radio-group-control-size` | Diameter of the visible radio control. |\n| `--cosm-radio-group-border` | Unchecked radio boundary color. |\n| `--cosm-radio-group-selected-border` | Selected radio boundary color. |\n| `--cosm-radio-group-indicator` | Selected radio dot color. |\n| `--cosm-radio-group-focus` | Visible keyboard focus indicator color. |\n\n**Keyboard**\n\n| Keys | Action |\n| --- | --- |\n| `Tab`, `Shift+Tab` | Enters or leaves the group as one tab stop. |\n| `Space` | Selects the focused enabled option. |\n| `ArrowRight`, `ArrowDown`, `ArrowLeft`, `ArrowUp` | Moves focus and selection through enabled options with wrapping. |\n\n## Events by platform\n\n| DOM | React | Angular | React Native | Detail | Description |\n| --- | --- | --- | --- | --- | --- |\n| `cosm-change` | `onChange` | `(valueChange)` | `onValueChange` | `RadioGroupChangeDetail` | Proposes a selection after enabled user activation; autonomous state commits and controlled state waits for the owner. |\n"},{"slug":"components/select","title":"Select","markdown":"# Select\n\n> Choose one option from a compact, labeled collection.\n\nStatus: **stable** (web, react, angular, native).\n\nSelect lets a person choose one value from a compact collection without keeping every option\nvisible. Use Listbox when choices should remain on the page, or wait for the planned Combobox when\npeople need to search or filter a long collection.\n\n## Playground\n\n**HTML / Web Component**\n\n```html\n<cosm-select label=\"Select\" placeholder=\"Select\"></cosm-select>\n\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/select';\n const flat = [{\"value\":\"apple\",\"label\":\"Apple\"},{\"value\":\"cherry\",\"label\":\"Cherry\"},{\"value\":\"lime\",\"label\":\"Lime\",\"disabled\":true}];\n const none = null;\n\n const element = document.querySelector('cosm-select');\n element.items = flat;\n element.defaultValue = none;\n element.addEventListener('cosm-change', event => console.log(event.detail));\n</script>\n```\n\n**React**\n\n```tsx\nimport { Select } from '@joralvmel/cosmos-react';\nconst flat = [{\"value\":\"apple\",\"label\":\"Apple\"},{\"value\":\"cherry\",\"label\":\"Cherry\"},{\"value\":\"lime\",\"label\":\"Lime\",\"disabled\":true}] as const;\nconst none = null as const;\n\nexport function Example() {\n return (\n <Select\n label=\"Select\"\n items={flat}\n defaultValue={none}\n placeholder=\"Select\"\n onChange={event => console.log(event.detail)}\n >\n </Select>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmSelectComponent } from '@joralvmel/cosmos-angular';\nconst flat = [{\"value\":\"apple\",\"label\":\"Apple\"},{\"value\":\"cherry\",\"label\":\"Cherry\"},{\"value\":\"lime\",\"label\":\"Lime\",\"disabled\":true}] as const;\nconst none = null as const;\nimport type { SelectChangeDetail } from '@joralvmel/cosmos-core';\n\n@Component({\n selector: 'app-example',\n imports: [CosmSelectComponent],\n template: `<cosm-select label=\"Select\" [items]=\"flat\" [defaultValue]=\"none\" placeholder=\"Select\" (valueChange)=\"onValueChange($event.detail)\"></cosm-select>`,\n})\nexport class ExampleComponent {\n readonly flat = flat;\n readonly none = none;\n onValueChange(detail: SelectChangeDetail) {\n console.log(detail);\n }\n}\n```\n\n**React Native**\n\n```tsx\nimport { Select } from '@joralvmel/cosmos-native';\nconst flat = [{\"value\":\"apple\",\"label\":\"Apple\"},{\"value\":\"cherry\",\"label\":\"Cherry\"},{\"value\":\"lime\",\"label\":\"Lime\",\"disabled\":true}] as const;\nconst none = null as const;\n\nexport function Example() {\n return (\n <Select\n label=\"Select\"\n items={flat}\n defaultValue={none}\n placeholder=\"Select\"\n onValueChange={detail => console.log(detail)}\n >\n </Select>\n );\n}\n```\n\nThe playground demonstrates flat options, autonomous and controlled values, variants, sizes, and a\ncustom trigger height. Each option has a stable value and visible label; disabled options remain\nvisible but cannot be selected.\n\n## Variants\n\nSelect supports outlined (default) and filled variants, plus `sm`, `md` (default), and `lg` sizes.\nSet `--cosm-select-trigger-min-height` to customize the Web trigger's minimum height. Use Cosmos\ntheme tokens and the documented `--cosm-select-*` hooks or CSS parts for other Web appearance\ncustomization.\n\n<SelectExamples kind=\"variants\" />\n\n## States\n\n`defaultValue` initializes an autonomous selection. Supplying `value`, including `null`, makes the\nselection controlled: the component emits a proposal and waits for its owner to update the value.\n`disabled` prevents opening and selection; disabled options remain visible but cannot be selected.\nTriggers highlight on pointer hover and while expanded; the chevron rotates as the popup opens.\n\nWeb, React, and Angular use the same form-associated Web Component. It supports `name`, required\nvalidity, disabled fieldsets, and form reset. React Native has no HTML form lifecycle; provide\nlocalized help or error text directly. A nonempty `errorText` also marks the control invalid;\nwhitespace-only `errorText` is ignored, and `invalid` stays available for errors shown elsewhere.\n\n<SelectExamples kind=\"states\" />\n\n### Web\n\n```html\n<cosm-select\n id=\"fruit\"\n label=\"Fruit\"\n placeholder=\"Choose a fruit\"\n name=\"fruit\"\n variant=\"filled\"\n required\n></cosm-select>\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/select';\n\n document.querySelector('#fruit').items = [\n { value: 'apple', label: 'Apple' },\n { value: 'cherry', label: 'Cherry' },\n { value: 'lime', label: 'Lime', disabled: true },\n ];\n</script>\n```\n\n### React\n\n```tsx\n\n<Select\n label=\"Fruit\"\n items={fruitItems}\n placeholder=\"Choose a fruit\"\n variant=\"filled\"\n value={fruit}\n onChange={event => setFruit(event.detail.value)}\n/>;\n```\n\n### Angular\n\n```html\n<cosm-select\n label=\"Fruit\"\n [items]=\"fruitItems\"\n placeholder=\"Choose a fruit\"\n variant=\"filled\"\n [(ngModel)]=\"fruit\"\n name=\"fruit\"\n></cosm-select>\n```\n\nAngular Forms integrates through `ControlValueAccessor`. Without Forms, listen to `valueChange`;\nit forwards the original DOM `CustomEvent`, so read the proposed value from `$event.detail.value`.\n\n### React Native\n\n```tsx\n\n<Select\n label=\"Fruit\"\n items={fruitItems}\n placeholder=\"Choose a fruit\"\n variant=\"filled\"\n value={fruit}\n onValueChange={({ value }) => setFruit(value)}\n triggerStyle={{ minHeight: 56 }}\n/>;\n```\n\nThe native app must mount Select under the app-level `PopoverProvider`. Its popup uses Cosmos\nPopover and Listbox behavior, with platform-appropriate placement and dismissal. The `style` prop\nstyles the field wrapper, `labelStyle` styles its label, and `triggerStyle` customizes the trigger;\nthe trigger's minimum height remains at least 44 logical points.\n\n## Accessibility\n\n- Provide a visible, nonempty label. Placeholder text indicates an empty value; it does not name\n the control. Localize the label, placeholder, option text, and help/error text.\n- On Web, Tab reaches the combobox trigger; Enter, Space, or an arrow key opens the listbox.\n The combobox keeps DOM focus while `aria-activedescendant` identifies the active option. Arrow\n keys and Home/End move the active option without committing it; printable characters use\n type-ahead, Enter/Space selects, and Escape closes without changing the value.\n- The Web popup exposes combobox, listbox, option, expanded, selected, disabled, required, and\n invalid semantics. Focus remains distinct from selection, and disabled options cannot be\n selected. The keyboard interaction follows the\n [WAI-ARIA select-only combobox pattern](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/).\n- React and Angular forward the Web component's events and accessibility behavior. React Native\n exposes platform-supported combobox/listbox semantics and touch-sized controls. React Native Web\n supports keyboard type-ahead through Listbox; native iOS/Android use touch and platform\n accessibility navigation because React Native core does not expose hardware key events on this\n control. Native `required` is descriptive; validation and error timing belong to the consumer.\n- Keep focus, selected, invalid, and disabled states distinguishable when customizing colors.\n- Web, React, and Angular use native form association and browser constraint validation. React\n Native does not provide HTML form submission or browser constraint validation.\n- Search/filtering, multiselect, asynchronous loading, virtualization, groups, option descriptions\n and icons, clear action, tree options, arbitrary interactive option content, and platform-native\n picker UI are deferred.\n\n## API\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `label` | string | Required | Required visible accessible name for the control. |\n| `items` | SelectItems | Required | Readonly flat options with unique nonempty values, nonempty labels, and optional disabled state. |\n| `value` | SelectValue | — | Controlled selected value; null means no selection, and a supplied null remains controlled. |\n| `defaultValue` | SelectValue | — | Initial autonomous selection; null by default. |\n| `placeholder` | string | Required | Consumer-localized text shown when no value is selected. |\n| `variant` | 'outlined' \\| 'filled' | `outlined` | Outlined or filled trigger appearance. |\n| `size` | 'sm' \\| 'md' \\| 'lg' | `md` | Small, medium, or large control size. |\n| `disabled` | boolean | `false` | Prevents interaction and excludes the value from Web form submission. |\n| `required` | boolean | `false` | Requires a selection in Web form validation; Native exposes descriptive semantics. |\n| `invalid` | boolean | `false` | Externally supplied invalid presentation state when the visible error is supplied elsewhere. |\n| `helperText` | string | — | Optional supporting text associated with the control. |\n| `errorText` | string | — | Optional consumer-localized error text; a nonempty trimmed value also exposes invalid state. |\n| `name` | string | — | Web form field name; React Native has no HTML form association. |\n\n**CSS parts**\n\n| Name | Description |\n| --- | --- |\n| `base` | Field wrapper. |\n| `label` | Visible accessible label. |\n| `trigger` | Select-only combobox trigger. |\n| `value` | Selected option text. |\n| `placeholder` | Text displayed when no option is selected. |\n| `popup` | Anchored popup surface. |\n| `listbox` | Single-selection option collection. |\n| `option` | Selectable row with selected, active, and disabled states. |\n| `content` | Option text wrapper. |\n| `option-label` | Primary option text. |\n| `help` | Supporting text associated with the control. |\n| `error` | Error description associated with the control. |\n\n**CSS custom properties**\n\n| Name | Description |\n| --- | --- |\n| `--cosm-select-background` | Control background. |\n| `--cosm-select-color` | Control and value text color. |\n| `--cosm-select-placeholder` | Placeholder text color. |\n| `--cosm-select-border` | Control boundary color. |\n| `--cosm-select-focus` | Visible keyboard focus indicator color. |\n| `--cosm-select-radius` | Control corner radius. |\n| `--cosm-select-trigger-min-height` | Custom minimum trigger height. |\n| `--cosm-select-option-selected-background` | Selected option background. |\n| `--cosm-select-option-selected-color` | Selected option text color. |\n\n**Keyboard**\n\n| Keys | Action |\n| --- | --- |\n| `Tab`, `Shift+Tab` | Moves focus to or from the enabled combobox trigger. |\n| `Enter`, `Space`, `ArrowDown`, `ArrowUp` | On Web, opens the popup; arrows move the active option without changing selection. |\n| `ArrowDown`, `ArrowUp`, `Home`, `End` | On Web, moves the active option without changing the selected value. |\n| `Printable characters` | On Web and React Native Web, moves to a matching option using locale-aware typeahead. Native iOS/Android use touch and platform accessibility navigation; React Native core does not expose hardware key events on this control. |\n| `Enter`, `Space` | On Web, selects the active enabled option. |\n| `Escape` | On Web, closes the popup without changing the selected value. |\n\n## Events by platform\n\n| DOM | React | Angular | React Native | Detail | Description |\n| --- | --- | --- | --- | --- | --- |\n| `cosm-change` | `onChange` | `(valueChange)` | `onValueChange` | `SelectChangeDetail` | Proposes a selected value after user activation; autonomous state commits and controlled state waits for the owner. |\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\n15 stable · 0 in progress · 23 planned (38 total)\n\nNext: `avatar`, `divider`, `combobox`, `multi-select`, `tooltip`\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 | stable | 1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | icon |\n| spinner | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| avatar | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| divider | planned | 1 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | — |\n| listbox | stable | 1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | icon |\n| calendar | stable | 1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | button, icon |\n| text-field | stable | 1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | icon, icon-button |\n| textarea | stable | 1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | — |\n| checkbox | stable | 1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | icon |\n| radio-group | stable | 1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | — |\n| switch | stable | 1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | — |\n| number-field | planned | 2 | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | text-field, icon-button |\n| select | stable | 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 | stable | 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 | stable | 1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | button, icon-button, icon |\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/switch","title":"Switch","markdown":"# Switch\n\n> An immediate binary setting with an accessible stable name and form behavior.\n\nStatus: **stable** (web, react, angular, native).\n\n`<cosm-switch>` immediately turns a binary preference on or off, for example enabling notifications.\nIt is not a submit action or a checkbox for confirming a separate decision. Its required plain-text\n`label` remains the accessible name in either state. Optional `helperText` stays alongside the label\nwhen the switch changes.\n\n## Playground\n\n**HTML / Web Component**\n\n```html\n<cosm-switch label=\"Switch\"></cosm-switch>\n\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/switch';\n\n const element = document.querySelector('cosm-switch');\n element.addEventListener('cosm-checked-change', event => console.log(event.detail));\n</script>\n```\n\n**React**\n\n```tsx\nimport { Switch } from '@joralvmel/cosmos-react';\n\nexport function Example() {\n return (\n <Switch\n label=\"Switch\"\n onCheckedChange={event => console.log(event.detail)}\n >\n </Switch>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmSwitchComponent } from '@joralvmel/cosmos-angular';\nimport type { SwitchCheckedChangeDetail } from '@joralvmel/cosmos-core';\n\n@Component({\n selector: 'app-example',\n imports: [CosmSwitchComponent],\n template: `<cosm-switch label=\"Switch\" (checkedChange)=\"onCheckedChange($event.detail)\"></cosm-switch>`,\n})\nexport class ExampleComponent {\n onCheckedChange(detail: SwitchCheckedChangeDetail) {\n console.log(detail);\n }\n}\n```\n\n**React Native**\n\n```tsx\nimport { Switch } from '@joralvmel/cosmos-native';\n\nexport function Example() {\n return (\n <Switch\n label=\"Switch\"\n onCheckedChange={detail => console.log(detail)}\n >\n </Switch>\n );\n}\n```\n\nUse the Playground to exercise autonomous state, controlled `checked` proposals (including `false`),\nand owners that accept or refuse updates. It supplies the required label and keeps the element\nchild-free in the server-rendered preview and generated snippets.\nBinary configuration controls use independent Switch instances; changing `disabled` or `invalid`\naffects the preview, not its editor. The `checked` dropdown retains Autonomous / false / true:\na binary switch cannot represent all three ownership choices.\n\n## Variants\n\nSwitch has one standard track-and-thumb appearance, without icons or on/off text. Web, React and\nAngular support the `sm`, `md` and `lg` sizes:\n\n```html\n<cosm-switch label=\"Small\" size=\"sm\"></cosm-switch>\n<cosm-switch label=\"Medium\" size=\"md\"></cosm-switch>\n<cosm-switch label=\"Large\" size=\"lg\"></cosm-switch>\n```\n\nUse `--cosm-switch-width`, `--cosm-switch-height` and `--cosm-switch-thumb-size` for other web\ndimensions. React Native intentionally exposes no `size` prop and keeps the built-in system-sized\nswitch.\n\n## States\n\n```html\n<cosm-switch label=\"Off by default\"></cosm-switch>\n<cosm-switch label=\"On by default\" default-checked></cosm-switch>\n<cosm-switch label=\"Unavailable\" disabled></cosm-switch>\n<cosm-switch\n label=\"Invalid, off\"\n invalid\n helper-text=\"This preference is not available for your account.\"\n></cosm-switch>\n<cosm-switch\n label=\"Invalid, on\"\n invalid\n default-checked\n helper-text=\"Choose another notification preference.\"\n></cosm-switch>\n<cosm-switch\n label=\"Hidden visual label\"\n label-hidden\n helper-text=\"The accessible name is still available.\"\n></cosm-switch>\n```\n\nUnbound `checked` is autonomous and starts from `defaultChecked`. A bound `checked`, even `false`,\nis controlled: activation proposes `{ checked }` and the component waits for its owner to update\nthe prop. Keep the accessible name unchanged while toggling. Disabled switches do not propose\nchanges.\n\n`invalid` is an externally supplied presentation state: the track uses danger colors in both\npositions and web exposes `aria-invalid`. It does not change `checked`, form validity or submission.\nExplain the problem with localized `helperText`. React Native keeps its built-in Switch and uses\ndanger track colors; there is no equivalent system invalid accessibility trait.\n\nWeb form submission includes `name=value` only when checked and enabled. Reset restores the\nautonomous default, and disabled fieldsets disable the switch. Angular Forms uses a boolean through\n`ControlValueAccessor`; React Native has no HTML form lifecycle.\n\nFor web customization, the `--cosm-switch-*` properties tune track, thumb, radius, spacing and focus:\n\n```html\n<cosm-switch\n label=\"Customized track\"\n default-checked\n style=\"--cosm-switch-checked-track-background: var(--cosm-success); --cosm-switch-thumb-background: var(--cosm-bg);\"\n></cosm-switch>\n```\n\n## Accessibility\n\n- Supply a nonempty plain-text `label`; `labelHidden` hides it visually but preserves the name.\n- The web control uses a native checkbox input with `role=\"switch\"`. `Tab` moves focus and `Space`\n toggles it. A visible focus ring is shown for keyboard focus.\n- `helperText` is associated with the control and remains present as checked state changes.\n- Checked and disabled states use native platform semantics. Native uses React Native's built-in\n `Switch` with its system size and a surrounding target of at least 44pt.\n- Do not add a label slot or interactive children. Switch exposes only on/off states.\n- Motion is removed when reduced motion is requested; colors use Cosmos tokens and customization\n hooks.\n\n## API\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `label` | string | Required | Required nonempty accessible name; remains stable in both states. |\n| `labelHidden` | boolean | `false` | Visually hides the label while retaining its accessible name. |\n| `checked` | boolean | `false` | Controlled checked value when supplied, including false; activation proposes changes without self-committing. |\n| `defaultChecked` | boolean | `false` | Initial autonomous checked value; later changes do not reset it. |\n| `size` | 'sm' \\| 'md' \\| 'lg' | `md` | Small, medium or large web switch. Native uses system Switch sizing. |\n| `disabled` | boolean | `false` | Prevents user interaction and excludes the value from web form submission. |\n| `invalid` | boolean | `false` | Externally supplied invalid presentation. Does not change checked state or form validity; native uses danger colors without an equivalent system invalid trait. |\n| `helperText` | string | — | Optional consumer-localized supporting text associated with the switch. |\n| `name` | string | — | Web form field name; React Native has no HTML form association. |\n| `value` | string | `on` | Web form value submitted when checked and enabled; defaults to on. Angular Forms uses checked as its boolean value. |\n\n**CSS parts**\n\n| Name | Description |\n| --- | --- |\n| `base` | Label, control and supporting text layout. |\n| `input` | Native checkbox input and web focus target. |\n| `track` | Visible switch track. |\n| `thumb` | Visible switch thumb. |\n| `label` | Visible or visually hidden label text. |\n| `help-text` | Supporting text associated with the switch. |\n\n**CSS custom properties**\n\n| Name | Description |\n| --- | --- |\n| `--cosm-switch-width` | Track width. |\n| `--cosm-switch-height` | Track height. |\n| `--cosm-switch-thumb-size` | Thumb diameter. |\n| `--cosm-switch-track-background` | Unchecked track background. |\n| `--cosm-switch-checked-track-background` | Checked track background. |\n| `--cosm-switch-thumb-background` | Thumb background. |\n| `--cosm-switch-border` | Unchecked track boundary color. |\n| `--cosm-switch-radius` | Track corner radius. |\n| `--cosm-switch-gap` | Space between the switch and label. |\n| `--cosm-switch-focus` | Visible keyboard focus indicator color. |\n\n**Keyboard**\n\n| Keys | Action |\n| --- | --- |\n| `Tab`, `Shift+Tab` | Moves focus to or from the enabled switch. |\n| `Space` | Toggles checked state and emits a checkedChange proposal. |\n\n## Events by platform\n\n| DOM | React | Angular | React Native | Detail | Description |\n| --- | --- | --- | --- | --- | --- |\n| `cosm-checked-change` | `onCheckedChange` | `(checkedChange)` | `onCheckedChange` | `SwitchCheckedChangeDetail` | Proposes the next checked value after enabled user activation; controlled state waits for the owner. |\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 Switch controls\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.\nControls follow the Playground theme and mode, or the site settings when **Site** is selected.\nNumeric inputs and dropdowns remain native until stable equivalents cover their behavior.\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. Sizes are `sm`, `md` and\n`lg`; label and supporting text remain outside the control height.\n\nHover changes the enabled field's border to the theme color without changing its surface. Focusing\nthe input or a clear/reveal action adds a subtle themed background and the existing focus boundary.\nInvalid borders remain danger-colored on hover; disabled fields do not react. Read-only fields\nremain focusable on web. An explicit background customization still takes precedence.\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```\n\n## States\n\n`helperText` and `errorText` are associated with the input. A nonempty `errorText` also marks the\nfield invalid (whitespace-only text is ignored); use `invalid` alone only when the visible error is shown elsewhere. `required`,\n`type`, `pattern`, `minLength` and `maxLength` use browser-native validity on web. Custom errors\nare consumer-owned and are not inferred from business rules.\n\n```html\n<cosm-text-field label=\"Email\" type=\"email\" required helper-text=\"Use your work email.\"></cosm-text-field>\n<cosm-text-field label=\"Invalid account\" value=\"taken\" error-text=\"That name is unavailable.\"></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.\nIcon colors stay the same while the field has focus; the focus boundary shows the focused state.\n\n<TextFieldIconColorsDemo />\n\nUse the Cosmos Select controls to try each color token. They follow the active docs theme and mode\nwhile you explore the field.\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-end-icon-color: var(--cosm-danger-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\"></cosm-text-field>\n```\n\n```tsx\n<TextField className=\"colored-icons\" label=\"Search\"\n startIcon={search} endIcon={heart} />\n```\n\n```html\n<cosm-text-field class=\"colored-icons\" label=\"Search\"\n [startIcon]=\"search\" [endIcon]=\"heart\"></cosm-text-field>\n```\n\nReact Native uses the same two hooks in `appearance`, with native theme colors rather than CSS:\n\n```tsx\n<TextField label=\"Search\" startIcon={search} endIcon={heart}\n appearance={{\n startIconColor: theme.colors['success-text'],\n endIconColor: theme.colors['danger-text'],\n }} />\n```\n\nCustom colors remain the consumer's contrast responsibility; forced-colors mode may replace them\nwith system colors.\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. `helperText` and `errorText` use\n `aria-describedby`, and 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 its\n size 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 helper text and provide `errorText`\n 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' | `md` | Small, medium or large editable control. |\n| `placeholder` | string | — | Short input hint; it never replaces the accessible label. |\n| `helperText` | string | — | Optional supporting text associated with the editable control. |\n| `errorText` | string | — | Optional consumer-localized error text associated with the editable control; a nonempty trimmed value also exposes invalid state. |\n| `invalid` | boolean | `false` | External invalid state when the visible error is supplied elsewhere, 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| `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-end-icon-color` | End icon color, independent of text and affixes. |\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":"components/textarea","title":"Textarea","markdown":"# Textarea\n\n> A labeled multiline plain-text control with native web form behavior.\n\nStatus: **stable** (web, react, angular, native).\n\n`<cosm-textarea>` accepts plain text across multiple lines. Use it for longer messages or notes;\nuse [Text field](/components/text-field/) for single-line input. A non-empty `label` is required.\nEnter inserts a newline, and the control does not add submit-on-enter behavior.\n\nOn the web it uses a native `<textarea>` inside a form-associated custom element. The `name` and\ncurrent value participate in form submission, required and maximum-length constraints remain\nnative, and reset restores `defaultValue` for autonomous use. Controlled reset dispatches a value\nproposal and waits for the owner to update `value`.\n\n## Playground\n\n**HTML / Web Component**\n\n```html\n<cosm-textarea label=\"Textarea\"></cosm-textarea>\n\n<script type=\"module\">\n import '@joralvmel/cosmos-elements/textarea';\n\n const element = document.querySelector('cosm-textarea');\n element.addEventListener('cosm-change', event => console.log(event.detail));\n</script>\n```\n\n**React**\n\n```tsx\nimport { Textarea } from '@joralvmel/cosmos-react';\n\nexport function Example() {\n return (\n <Textarea\n label=\"Textarea\"\n onChange={event => console.log(event.detail)}\n >\n </Textarea>\n );\n}\n```\n\n**Angular**\n\n```ts\nimport { Component } from '@angular/core';\nimport { CosmTextareaComponent } from '@joralvmel/cosmos-angular';\nimport type { TextareaChangeDetail } from '@joralvmel/cosmos-core';\n\n@Component({\n selector: 'app-example',\n imports: [CosmTextareaComponent],\n template: `<cosm-textarea label=\"Textarea\" (valueChange)=\"onValueChange($event.detail)\"></cosm-textarea>`,\n})\nexport class ExampleComponent {\n onValueChange(detail: TextareaChangeDetail) {\n console.log(detail);\n }\n}\n```\n\n**React Native**\n\n```tsx\nimport { Textarea } from '@joralvmel/cosmos-native';\n\nexport function Example() {\n return (\n <Textarea\n label=\"Textarea\"\n onValueChange={detail => console.log(detail)}\n >\n </Textarea>\n );\n}\n```\n\n## Variants\n\n`variant` changes the control surface; `size` changes its visual typography and padding. `rows`\nsets the number of visible lines independently of visual size.\n\n```html\n<cosm-textarea label=\"Outlined\" default-value=\"A message with multiple lines.\" rows=\"4\" />\n```\n\n```html\n<cosm-textarea label=\"Filled\" variant=\"filled\" size=\"lg\" default-value=\"A larger filled control.\" rows=\"3\" />\n```\n\n## States\n\n`helperText` and `errorText` stay associated with the editor. A nonempty `errorText` both presents\nthe message and marks the control invalid (whitespace-only text is ignored); set `invalid` alone only when the visible error is shown\nelsewhere.\n\nOn Web, hovering an enabled valid control changes its border color. Focusing it also applies a\nsubtle themed background and visible focus ring; disabled and invalid controls do not receive the\nhover treatment.\n\n```html\n<cosm-textarea label=\"Project notes\" helper-text=\"Keep the message concise.\" rows=\"3\" />\n```\n\n```html\n<cosm-textarea label=\"Required message\" required error-text=\"Add a message before continuing.\" />\n```\n\n```html\n<cosm-textarea label=\"Read-only message\" read-only default-value=\"This text can be selected but not edited.\" />\n```\n\n```html\n<cosm-textarea label=\"Unavailable\" disabled default-value=\"This control is disabled.\" />\n```\n\n## Accessibility\n\n- Supply a non-empty `label`; `labelHidden` hides it visually without removing its accessible\n name. A placeholder is never a substitute for the label.\n- `helperText` and `errorText` are connected to the native editor with `aria-describedby`. Invalid state\n is exposed with `aria-invalid`.\n- The editor retains native textarea keyboard behavior, including newline insertion with Enter,\n native focus, required validation and disabled/read-only semantics.\n- Cosmos tokens support light and dark modes and the built-in themes. Reduced-motion preferences\n are respected; the control has no required animation.\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| `rows` | number | `4` | Visible line count of the multiline editor. It is independent of the visual size. |\n| `variant` | 'outlined' \\| 'filled' | `outlined` | Visual treatment of the editable control. |\n| `size` | 'sm' \\| 'md' \\| 'lg' | `md` | Visual size of the editable control, independent of rows. |\n| `placeholder` | string | — | Short input hint; it never replaces the accessible label. |\n| `helperText` | string | — | Optional supporting text associated with the editable control. |\n| `errorText` | string | — | Optional consumer-localized error text associated with the editable control; a nonempty trimmed value also exposes invalid state. |\n| `invalid` | boolean | `false` | External invalid state when the visible error is supplied elsewhere, 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| `maxLength` | number | — | Maximum number of characters. Web uses native HTML length constraints and native applies supported input limits. |\n| `name` | string | — | Form field name on web. React Native has no HTML form association or name-based submission. |\n\n**CSS parts**\n\n| Name | Description |\n| --- | --- |\n| `label` | Accessible label above the control. |\n| `control` | Visual control containing the editable textarea. |\n| `textarea` | The native multiline editable textarea. |\n| `help` | Supporting text associated with the editable textarea. |\n| `error` | External or native-constraint error text associated with the editable textarea. |\n\n**CSS custom properties**\n\n| Name | Description |\n| --- | --- |\n| `--cosm-textarea-background` | Editable control background. |\n| `--cosm-textarea-color` | Editable text color. |\n| `--cosm-textarea-placeholder` | Placeholder text color. |\n| `--cosm-textarea-border` | Editable control boundary color. |\n| `--cosm-textarea-focus` | Visible focus indicator color. |\n| `--cosm-textarea-radius` | Editable control corner radius. |\n\n**Keyboard**\n\n| Keys | Action |\n| --- | --- |\n| `Tab`, `Shift+Tab` | Moves focus to or from the enabled editable control. |\n| `Enter` | Inserts a newline in the editable text. |\n\nThe web component exposes `label`, `control`, `textarea`, `help`, and `error` CSS parts. Its custom\nproperties are `--cosm-textarea-background`, `--cosm-textarea-color`,\n`--cosm-textarea-placeholder`, `--cosm-textarea-border`, `--cosm-textarea-focus`, and\n`--cosm-textarea-radius`.\n\nReact Native follows the active Cosmos theme and accepts `style`, `inputStyle`, `labelStyle`,\n`helpStyle`, `errorStyle`, and an `appearance` object (`background`, `text`, `placeholder`,\n`border`, `focus`, and `radius`) for platform-appropriate customization.\n\n## Events by platform\n\n| DOM | React | Angular | React Native | Detail | Description |\n| --- | --- | --- | --- | --- | --- |\n| `cosm-change` | `onChange` | `(valueChange)` | `onValueChange` | `TextareaChangeDetail` | Proposes the current text after each user edit; this is not a blur/commit event. |\n\n`onChange` in React and `valueChange` in Angular receive the original DOM `CustomEvent`; read the\nproposed string from `event.detail.value`. The React Native `onValueChange` callback receives the\ndetail object `{ value }`.\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 (every package at `0.2.0`, changelogs).\nMerging it publishes to npm with provenance and creates the GitHub Release `cosmos-ui@v0.2.0`:\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; every public package must move to the same version. Check CI and identify\nmissing/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, package Git tags, the single\nGitHub Release `cosmos-ui@v<version>` and the docs deployment. Separate published, pending and\nfailed packages; green CI alone is not proof 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. Every public package shares one version (Changesets `fixed`\n group): a release moves all of them to the same version, also the packages without changes.\n4. Merging **Version Packages** runs `changeset publish`: new versions go to npm with provenance and\n the package Git tags are pushed. After a successful publication the workflow creates **one**\n GitHub Release for the version, tagged `cosmos-ui@v<version>` (for example `cosmos-ui@v0.4.0`),\n with notes combined from the package changelogs. Rerunning the workflow never duplicates it.\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 of every package such as `0.2.0-next-20261110120000` with the dist-tag `next`\n(no GitHub Release):\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| GitHub Release `cosmos-ui@v<version>` missing | The `GitHub Release` job creates it only when every public package is on npm at that version. Check its log; rerunning the workflow, or the next push to `main`, creates it without duplicates. Never republish to recover 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 and always share one version; while\nversions are `0.x`, a **minor** release may contain breaking changes. Read the release notes (one\nGitHub Release per version, such as `cosmos-ui@v0.4.0`) before updating, follow their migration\nnotes and install every Cosmos package at the same version. To get update pull requests in your app,\ngroup the Cosmos 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`, `terra`, `supernova`, `aurora` or `solstice`)\nand `mode` (`light`, `dark` or `system`, which follows the device appearance). These are the same\npalettes as on the web; see the [theme gallery](../../theming/themes/).\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## Choose a built-in theme\n\n| Theme | Primary color | Character |\n| --- | --- | --- |\n| Cosmos | Sapphire blue | The default, balanced foundation |\n| Nebula | Amethyst purple | Expressive and cool |\n| Terra | Forest green | Grounded and fresh |\n| Supernova | Coral red | Warm and energetic |\n| Aurora | Cyan/turquoise | Clear and luminous |\n| Solstice | Amber/gold | Warm and balanced |\n\nEvery palette includes light and dark modes on web and React Native. All built-in themes share the\n`rounded` radius preset; typography, spacing and motion also stay unchanged. Cosmos remains the default.\nSuccess, warning, danger and info keep their semantic meaning: a green or red primary is a brand\nchoice, not a validation result. Always pair status color with meaningful text or icons.\n\nChoose a theme in the site header to apply it to the previews and shared Playground controls.\nThe Playground can override theme and mode independently; choose the site options to follow the\nheader again. The gallery below deliberately shows each palette in both modes.\n\nFor an application, use the existing runtime:\n\n```ts\n\nsetTheme('terra');\nsetMode('system');\n```\n\nIn React Native, set `<CosmosThemeProvider theme=\"terra\" mode=\"system\">`; the native demo\nlists the same themes on its home screen. Tailwind includes a `theme-<name>:` variant for each\npalette, such as `theme-terra:bg-primary-subtle`.\n\n- **Cosmos** (`data-theme=\"cosmos\"`), light and dark.\n- **Nebula** (`data-theme=\"nebula\"`), light and dark.\n- **Terra** (`data-theme=\"terra\"`), light and dark.\n- **Supernova** (`data-theme=\"supernova\"`), light and dark.\n- **Aurora** (`data-theme=\"aurora\"`), light and dark.\n- **Solstice** (`data-theme=\"solstice\"`), light and dark.\n\n## Create a theme\n\n```ts\n\nconst studio = defineTheme({\n name: 'studio',\n seeds: { primary: 'oklch(0.56 0.15 165)' },\n harmony: 'triadic',\n radius: 'pill',\n});\n\nconst resolved = resolveTheme(studio);\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"}]