# astryx-vue — full documentation > Every English page in one file. Index: https://astryx-vue.pages.dev/llms.txt --- # Introduction Source: https://astryx-vue.pages.dev/en/guide/why.md astryx-vue is an open-source Vue 3 reimplementation of Meta's [Astryx](https://github.com/facebook/astryx) design language. The upstream documentation is located at , built on React 19 and StyleX. astryx-vue is an independent community project bringing the aesthetics and engineering precision of Astryx to the Vue ecosystem. ## Core Focus Rather than wrapping React components or introducing runtime adapters, astryx-vue reimagines Astryx natively for Vue. The implementation strictly mirrors four foundations: 1. **Design Tokens**: Structured design tokens across color, spacing, radius, and elevation. 2. **CSS Variables**: Unified light/dark theme variables leveraging native `light-dark()`. 3. **Motion System**: Calibrated durations and easing curves with built-in reduced-motion support. 4. **Component Grain**: Faithful component divisions matching the original design system. All APIs embrace standard Vue 3 idioms: typed props, events, slots, `v-model`, and composables without unnecessary runtime abstractions. ## Architecture and Packages The project separates component structure from visual theming: - `@astryx-vue/core`: Component implementations, composables, and structural CSS. - `@astryx-vue/themes`: Theme tokens, typography, and color definitions (currently providing Neutral). The styles use standard CSS layers (`@layer astryx.*`), requiring no specialized CSS-in-JS toolchains. ## Icons and Patterns To keep bundle footprints minimal, the library does not package a proprietary icon font or heavy component suite. Controls such as `IconButton` and `NavItem` accept CSS icon classes, seamlessly integrating with solutions like UnoCSS `presetIcons`, Iconify, or Lucide. For specialized workflows, the library provides cohesive component patterns including `Chat` layouts, `Citation` elements, and `Markdown` presentations. ## Differences from the Original Most components map one-to-one to the original. The table below lists what this repository adds on top, things the original does not have. Each one is off by default or leaves existing behavior alone. | Feature | Entry | Description | | --- | --- | --- | | Custom scrollbars | [`ScrollbarsProvider`](/en/components/scrollbars-provider) | Wrap your app once and scrolling components swap native scrollbars for thin overlay ones. Without it nothing changes, and no extra code is bundled. | New extras will keep being added to this table. --- The public API strictly reflects current repository exports. Core styles and components follow native Web standards and modern Vue 3 patterns. --- # Principles Source: https://astryx-vue.pages.dev/en/guide/principles.md Every decision in this library follows from four sentences. - **Components before raw HTML.** For anything a component already covers, don't hand-write the markup and restyle it. - **Semantic tokens, not hardcoded values.** Colors, spacing, and radii are named by purpose, not by appearance. The name says "body text primary", not "dark grey". - **App code knows nothing about the theme.** No hex colors and no pixel values in your own styles, so a theme swap or dark mode follows automatically. - **The internals are open.** Every component is exported and composable. Build on top of one instead of fighting it. ## Eight hard rules 1. If a component covers it, don't hand-write it. 2. Lay out from the outside in: pick the frame and the regions before writing content. See [Page layout](/en/guide/layout). 3. Dense data renders as rows: `Table`, or a `List` with dividers, one item per row. `Card` is for self-contained widgets, galleries, and discrete items; groups of settings use `Section`. 4. Custom styles are plain CSS in `@layer astryx.overrides`. To mix in utility classes, see [Theme and styles](/en/guide/styling). 5. Colors, spacing, and radii come from semantic variables: `var(--astryx-color-text-primary)`, `var(--astryx-spacing-4)`. 6. Forms bind with `v-model`. `TextInput` and `CheckboxInput` require a value; there is no uncontrolled mode. 7. Navigation uses `as` to render `RouterLink` as the root element, or a `LinkProvider` at the top of the app. Don't hard-code ``. 8. When a prop is unclear, look it up: `astryx-vue component Button`. Don't guess, and don't invent props. ## How theme independence works A theme file holds variables and no structure. Every color variable reads like this. ```css --astryx-color-text-primary: light-dark(#171717, #fafafa); ``` `light-dark()` picks the light or the dark value from the current `color-scheme`, so writing `var(--astryx-color-text-primary)` is all your code needs; dark mode comes for free and there is no second stylesheet to keep in sync. Component structure uses the same variables. Swap the theme to Gothic and every color in the page changes, with no edit to app code. ## Do and don't | Guidance | Practice | | --- | --- | | Do | Place content with `HStack`, `VStack`, and `Grid`; they carry no color and no border. | | Do | Write colors as `var(--astryx-color-*)` and spacing as `var(--astryx-spacing-*)`. | | Do | When a component's behavior is unclear, run `astryx-vue component ` first. | | Don't | Stack inline styles on raw elements to get around a component. | | Don't | Hardcode colors (`#fff`) or spacing (`16px`). | | Don't | Write `` by hand; in-app navigation then reloads the page. | | Don't | Wrap every list item and every page section in a `Card`. | | Don't | Use `Badge` as decoration. It carries meaning: status, category, count. For a decorative value chip use `Token`; for a single status dot use `StatusDot`. | ## About styling Upstream Astryx supports StyleX; we don't. Our approach is plain CSS plus CSS variables: component styles live in `@layer`, so a rule you write in the `astryx.overrides` layer wins without out-specificity tricks. The full layer order, how to arrange `@layer`, and how to use Tailwind or UnoCSS alongside: [Theme and styles](/en/guide/styling). --- # Quick start Source: https://astryx-vue.pages.dev/en/guide/getting-started.md Install the components and the theme. The peer dependency is Vue `^3.5.0`. ::: code-group ```sh [pnpm] pnpm add @astryx-vue/core @astryx-vue/themes ``` ```sh [npm] npm install @astryx-vue/core @astryx-vue/themes ``` ```sh [yarn] yarn add @astryx-vue/core @astryx-vue/themes ``` ```sh [bun] bun add @astryx-vue/core @astryx-vue/themes ``` ::: Load the theme once from the app entry. Neutral includes Figtree and JetBrains Mono. ```ts import '@astryx-vue/themes/neutral.css' ``` Import each component from its own subpath. That entry loads the matching structural styles. ```vue ``` Import every structural stylesheet at once with: ```ts import '@astryx-vue/core/styles.css' ``` Next, see how package entries work in [Installation](/en/guide/installation), how layers and variables connect in [Theme and styles](/en/guide/styling), or open [Components](/en/components/). To learn more about the background and design decisions, see [Introduction](/en/guide/why). ## For AI agents Every page is also published as plain text, so an agent can read the docs without installing anything: - [/llms.txt](https://astryx-vue.pages.dev/llms.txt) lists every page with a one-line summary. Chinese: [/llms-zh.txt](https://astryx-vue.pages.dev/llms-zh.txt). - [/llms-full.txt](https://astryx-vue.pages.dev/llms-full.txt) puts the whole documentation in one file. Chinese: [/llms-full-zh.txt](https://astryx-vue.pages.dev/llms-full-zh.txt). - Add `.md` to any page address to read that single page as Markdown, for example [/en/components/button.md](https://astryx-vue.pages.dev/en/components/button.md). Chinese pages have no `/zh` prefix: `/components/button.md`. A component's Markdown file pulls its overview, props tables, examples with the demo source, and accessibility checks into one document. Every HTML page links to its Markdown version in the page head, and the command line has the same component text, see [CLI](/en/guide/cli). --- # Installation Source: https://astryx-vue.pages.dev/en/guide/installation.md Install the two public packages together: ::: code-group ```sh [pnpm] pnpm add @astryx-vue/core @astryx-vue/themes ``` ```sh [npm] npm install @astryx-vue/core @astryx-vue/themes ``` ```sh [yarn] yarn add @astryx-vue/core @astryx-vue/themes ``` ```sh [bun] bun add @astryx-vue/core @astryx-vue/themes ``` ::: `@astryx-vue/core` peers on `vue: ^3.5.0`. The theme package depends on `@fontsource/figtree` and `@fontsource/jetbrains-mono` for the body and monospace faces. Both packages publish ESM only. Entries differ by what you need: | You need | Import | | --- | --- | | One component | A subpath such as `@astryx-vue/core/Button` | | Composables, and components re-exported from the root | `@astryx-vue/core` | | `provideAstryxLocale`, `useAstryxMessages` | `@astryx-vue/core/locale`, also on the root | | A theme | `@astryx-vue/themes/neutral.css`. Butter, Chocolate, Gothic, Matcha, Stone, and Y2K use the same path with their own file name. | | Every structural sheet | `@astryx-vue/core/styles.css` | | A global reset | `@astryx-vue/core/reset.css` | `reset.css` is a global reset in the same family as Tailwind Preflight. Once imported, it changes the default look of plain HTML tags on the whole page: - Every element is `box-sizing: border-box`, and borders start as 0-width solid lines. - Headings, paragraphs, lists and similar tags lose their default margin and padding. Lists lose their bullets, and headings inherit their size and weight. - Images, video and `svg` become block-level. `img` and `video` fit their container's width. - Form controls inherit the font and color. Buttons lose the browser's own look. - Disabled elements show the default pointer, not `not-allowed`. - `::before`, `::after`, placeholders and the search field's clear button are reset too. Every rule sits in the lowest layer, `astryx.reset`, with zero specificity, so any other layer and any unlayered style of yours overrides it. The file also declares the layer order itself, so the import order does not matter. The reset is global by design. To keep your own page untouched, do not import `reset.css`. The components still work without it, because each structural sheet styles its own elements. The structural sheets and the theme declare the layer order themselves. Subpaths and the package root export the same components. Docs and examples use subpaths so the import says which component it is, and so only that component's structural sheet loads. Importing `useClipboard` from the package root can pull other component modules along if the bundler does not drop unused re-exports. Prefer a subpath when you only need a component. The two packages version together. See the [changelog](/en/guide/changelog) for what changed, and the [upgrade guide](/en/guide/migration) for what to do when you upgrade. To look these docs up from the terminal, see [CLI](/en/guide/cli). --- # CLI Source: https://astryx-vue.pages.dev/en/guide/cli.md `@astryx-vue/cli` looks up astryx-vue component docs and playground pages from the terminal, for people and for agents. The binary is `astryx-vue`. It is not Meta's `astryx` command, and it does not speak React or StyleX. Install it as a dev dependency: ::: code-group ```sh [pnpm] pnpm add -D @astryx-vue/cli ``` ```sh [npm] npm install -D @astryx-vue/cli ``` ```sh [yarn] yarn add -D @astryx-vue/cli ``` ```sh [bun] bun add -d @astryx-vue/cli ``` ::: The package declares a `bin`, so the command is on `node_modules/.bin` right after installing: ```sh pnpm exec astryx-vue component Button npx astryx-vue search dialog --json ``` Without installing it, run `npx @astryx-vue/cli …`. The scope is required: the bare `astryx-vue` name on npm is not this package. A script alias is optional, and only useful when an agent shell does not have `node_modules/.bin` on `PATH`: ```json { "scripts": { "astryx-vue": "astryx-vue" } } ``` ```sh npm run astryx-vue -- component Button ``` ## Commands `astryx-vue component --list` lists the documented components. `astryx-vue component Button` prints one component's usage, props, slots, events, and examples. `astryx-vue composable --list` lists the composables, and `astryx-vue composable useClipboard` prints one composable's parameters and return values. Vue calls these functions composables, so the CLI never says hook. `component useClipboard` still finds it and points at the `composable` command. `astryx-vue docs` lists the guide and theme topics. `astryx-vue docs guide/dark-mode` prints one page's text, and `astryx-vue docs themes/tokens` works too. `astryx-vue search dialog` ranks components, composables, docs topics, and page templates. `--type` narrows the domain to `component`, `composable`, `doc`, or `template`. Other libraries' names find the matching component (`ScrollArea`, `side sheet`, `toggle group`), and glyph names such as `cog` find `Icon`. `astryx-vue manifest --json` describes the commands, options, response types, error codes, and exit codes. `astryx-vue init --features agents` writes the agent context file. ## Templates `astryx-vue template --list` lists the 57 playground pages, grouped by category. Every template is a page today; `--type block` answers with a note rather than an error. Each line says what the page needs: a ready template names only `vue` and `@astryx-vue/core`, so copying one leaves no install step. `astryx-vue template login-card` prints one template's description, the components it uses, the packages it needs, and its source. `--skeleton` prints only the layout skeleton: component tags with layout attributes such as `gap`, `padding`, and `columns`, without text, handlers, or native HTML wrappers. `astryx-vue template login-card ./src/pages` writes `src/pages/LoginCard.vue`. A path that ends in a file name is the file itself. An existing file is only replaced with `--overwrite` (or `-f`), and a path outside the project is refused. Copying rewrites the playground's demo photo paths to an inline grey placeholder and reports how many it replaced; it does not copy assets and does not install anything, it only names the packages the project is missing. A few templates import something a project cannot install, such as the playground-only `@astryx-vue/playground-charts` alias. They are marked not ready: you can read them, and copying is refused with the reason. ## Build `astryx-vue build ""` turns one sentence into a starting point: the closest page template, two alternatives, and the components to use, each with the command to run next. It also lists composables separately. The ranking is local and deterministic: keyword matching over each template's slug, title, description, keywords, and components, with rare words weighted higher. There is no network call and no model. Chinese is matched by character pairs, so no spaces are needed. `astryx-vue build` with no idea prints the workflow: pick a page, copy it, then look up each component before writing code. ## Themes `astryx-vue theme` lists the built-in themes. `astryx-vue theme butter` prints the four steps that load one: the stylesheet import, the `data-astryx-theme` attribute, how to switch themes or run two side by side, and how to check the result. The steps are this site's own theme pages, so the command and the docs cannot disagree. It writes nothing. ## Upgrading and checking a project `astryx-vue upgrade` reads the `@astryx-vue/core` version in the project's `package.json`, compares it with the version the CLI documents, and prints the sections of the [upgrade guide](/en/guide/migration) — what changed, how it was written before, how it is written now, what to do. It then looks through the project's own sources for the old names that guide replaces and lists file and line. Nothing is changed, and nothing is fetched from the network. `astryx-vue doctor` reports five checks and edits nothing: whether core is installed and how its version compares, whether themes is installed, whether `vue` satisfies 3.5.0, whether a theme stylesheet is imported, and whether `data-astryx-theme` is set. Exit code is 0 when everything passed or only warned, and 1 when a check failed. ## Flags `--json` prints a typed envelope on stdout. `--dense` shortens the text people read; together with `--json` it is ignored, and the envelope stays complete. `--zh` uses Simplified Chinese where this site has a translation. `--cwd` is the project directory `template` and `init` write inside. No command asks a question, so there is nothing to confirm. A `--yes`, `-y`, `--non-interactive`, or `--no-input` is refused with exit code 2, and the error names the same command without it. The template `--json` types are `template.list`, `template.show`, `template.skeleton`, and `template.copy`; `build` returns `build.help` and `build.kit`. Errors carry a code such as `ERR_UNKNOWN_TEMPLATE`, `ERR_TEMPLATE_NOT_READY`, `ERR_FILE_EXISTS`, or `ERR_PATH_TRAVERSAL`. ## Agent file `init` prints the setup guide — which packages to install (a canary package takes `@canary`, once it is on npm), the theme import, the locale snippet, and what to verify — and writes the managed block below. It creates `AGENTS.md` when no agent file exists. Without `--agent`, an agent file the project already has is reused, in the order `AGENTS.md`, `CLAUDE.md`, `.cursorrules`, `.hermes.md`, `HERMES.md`. `--agent claude` writes `CLAUDE.md`, `hermes` writes `.hermes.md` (or `HERMES.md` when the project already has one), `cursor` and `codex` write `AGENTS.md`, and `all` writes every known file that exists. `--agent-docs-path ` writes exactly that file. The command owns only the block between these markers: ```html ... ``` Every run replaces that block with freshly generated text. Text outside the markers stays. If the file exists and the markers are missing, the block is appended. The block names every package the CLI documents, marks the canary ones, and says plainly when a package is not on npm yet — those get no install command, so nobody is sent to a missing package. Then it describes a three-step workflow: run `build` to pick a page, run `template` to copy it, then run `component`, `composable`, or `docs` before writing code. It also says how to invoke the binary. The install command follows the project's package manager: the `packageManager` field first, then a lockfile. When neither says which manager it is, all four forms are printed. The sentences the CLI prints come from this docs site and from the playground pages. After a docs or template change, regenerate the catalog in the CLI package. The maintainer steps are in `packages/cli/CONTRIBUTING.md`. ## From code `runCli` takes the same arguments as the binary and returns `{ exitCode, stdout, stderr }`: ```ts import { assertResponse, runCli } from '@astryx-vue/cli' const result = await runCli(['search', 'dialog', '--json'], { cwd: process.cwd() }) const found = assertResponse(result.stdout, 'search') ``` `assertResponse` narrows the envelope to the type you expect. `parseResponse` returns the envelope without asserting, and `isError` checks one. This version does not include `swizzle`, `discover`, `gap-report`, `integration`, or `blog`, and there is no MCP server. --- # Working with AI Source: https://astryx-vue.pages.dev/en/guide/working-with-ai.md An AI writing component code makes two mistakes more than any other: it guesses props, and it copies React idioms from upstream. One instruction file and one command line tool block both. Two pieces: - A note in the repo that tells the AI where to look and what not to write. - A CLI that hands the AI the real props, slots, and examples on demand. ## Step 1: install the CLI ::: code-group ```sh [pnpm] pnpm add -D @astryx-vue/cli ``` ```sh [npm] npm install -D @astryx-vue/cli ``` ```sh [yarn] yarn add -D @astryx-vue/cli ``` ```sh [bun] bun add -d @astryx-vue/cli ``` ::: The binary lands in `node_modules/.bin` and is called `astryx-vue`. Without installing, run `npx @astryx-vue/cli …`; the scope is required, because the bare `astryx-vue` name on npm is not this package. ## Step 2: write the instruction file ```sh pnpm exec astryx-vue init --features agents ``` This writes a managed note into the project. With no `--agent` it picks the file the project already has, in this order: `AGENTS.md`, `CLAUDE.md`, `.cursorrules`, `.hermes.md`, `HERMES.md`. When none exists it creates `AGENTS.md`. Which file for which tool: | Tool | How to write it | | --- | --- | | Claude Code | `--agent claude`, writes `CLAUDE.md` | | Codex, Cursor | `--agent codex` or `--agent cursor`, writes `AGENTS.md` | | A repo that already has a file | No `--agent`; the existing file is reused | | Anything else | `--agent-docs-path ` names the file | GitHub Copilot reads `.github/copilot-instructions.md`. The CLI does not write that file by default; point it there with `--agent-docs-path .github/copilot-instructions.md`. Relative paths resolve against the project directory, and a path that lands outside it is refused. ## What goes into the file The text sits between two markers. ```html ... ``` Inside the block are four parts. 1. **What the project uses.** astryx-vue is an unofficial Vue 3 community port of Astryx. Components come from `@astryx-vue/core`, themes from `@astryx-vue/themes`. Do not use Meta's React packages, StyleX, or the bare `astryx` command. 2. **A three-step workflow.** Find a template with `build`, copy it with `template`, and look things up with `component`, `composable`, and `docs` before writing code. 3. **How to look things up.** `component --list`, `composable --list`, `docs `, `search`, and `manifest --json`, plus the `--json`, `--zh`, and `--dense` flags. 4. **How to run it, plus a few conventions.** Subpath imports, peer dependencies, and that the styles do not need UnoCSS. Run the same command again to refresh. Only the text between the two markers is replaced; project rules you wrote outside them are left alone. ## Let the AI look things up The instruction file only points the way. The answers live in the CLI. Hand these to the AI, or put them in your project rules. ```sh # Which components exist pnpm exec astryx-vue component --list # One component's usage, props, slots, events, and examples pnpm exec astryx-vue component Button # A composable's parameters and return value pnpm exec astryx-vue composable useClipboard # One guide or theme topic pnpm exec astryx-vue docs guide/dark-mode # Search components, docs, and templates together pnpm exec astryx-vue search "date picker" ``` Add `--json` when a script or agent reads the output: the reply is a typed envelope, and errors use the same shape with a non-zero exit code. `--dense` shortens the text for humans; `--zh` answers in Simplified Chinese. Once the AI looks things up before it writes, invented props mostly stop happening. ## Starting from a template beats starting from nothing ```sh pnpm exec astryx-vue build "order detail page, list on the left, detail on the right" pnpm exec astryx-vue template --list pnpm exec astryx-vue template detail-page ./src/pages ``` `build` scores keywords locally and answers with the closest template, two alternatives, and the components to use. No network, no external model. `template ` writes `.vue`, swaps the demo photos for a grey placeholder, and reports which packages the project is still missing. An existing file is never overwritten; pass `--overwrite` (or `-f`) to replace it. ## Rules worth giving the AI These lines do more than a page of explanation. - Run `astryx-vue component ` before writing a component. Do not write props from memory. - Import from `@astryx-vue/core/` or the package root only. Do not use Meta's `@astryxdesign/*` packages. - Style with a theme plus `var(--astryx-*)` variables. No hex colors and no pixel values. - Write padding once, on `Layout` or `AppShell`. Do not add another `div` with padding at each level. See [Page layout](/en/guide/layout). - When a component's behavior is unclear, find the topic with `astryx-vue docs`. Do not invent an API. ## Next - Every CLI flag and exit code: [CLI](/en/guide/cli). - Which files `init` writes and how the markers work: the "Agent file" section of [CLI](/en/guide/cli). --- # Theme and styles Source: https://astryx-vue.pages.dev/en/guide/styling.md An app imports two things at minimum: a theme, and structural styles for the components it uses. ```ts import { Button } from '@astryx-vue/core/Button' import '@astryx-vue/themes/neutral.css' ``` The `Button` entry loads the structural sheet for `button`. The theme entry loads Neutral's variables, including the `--astryx-button-*` names that button reads. Without the theme, the structure is there and the color and metrics are not. Without the structural sheet, the variables have no rules to feed. To load every structural sheet once, add this at the entry: ```ts import '@astryx-vue/core/styles.css' import '@astryx-vue/themes/neutral.css' ``` `styles.css` gathers the sheets in `packages/core/styles/`, including the shared motion in `motion.css`. `neutral.css` gathers the theme files in `packages/themes/neutral/` and loads Figtree and JetBrains Mono. The layer order is: ```css @layer astryx.reset, astryx.tokens, astryx.base, astryx.components, astryx.overrides; ``` Application overrides belong in `astryx.overrides`. Unlayered global CSS beats these layers, so a bare `button { }` will paint over the component unless that is what you want. ## Using Tailwind or UnoCSS alongside They work together as long as the layer order is fixed. One rule matters: the position of every layer on the page is set by **where it first appears**. The reliable way is to declare all the layers in one statement at the top of your app entry. ```css @layer theme, base, astryx.reset, astryx.tokens, astryx.base, astryx.components, astryx.overrides, components, utilities; @import 'tailwindcss'; @import '@astryx-vue/core/styles.css'; @import '@astryx-vue/themes/neutral.css'; ``` Earlier layers are weaker and later layers win. The utilities layer sits after `astryx.components`, so `class="p-0"` beats the padding a component sets. `astryx.overrides` sits before utilities, so it cannot beat them. When one rule must win over a utility class, do not reach for `overrides`; reorder the layers, or write the rule unlayered. One note on syntax: an `@layer` statement may come before `@import`. That is one of the few orders CSS allows; the other way round the whole block is discarded as invalid. ### Use our variables in utility classes No config needed; arbitrary values work as they are. ```html
...
``` Tailwind v4 can also register the variables as its own tokens, which reads shorter. ```css @theme inline { --color-surface: var(--astryx-color-background-card); --color-body: var(--astryx-color-text-primary); } ``` Then write `bg-surface` and `text-body`. Do not drop `inline`. Tailwind's guidance is that a theme value pointing at another variable needs it; without it the generated utility reads `--color-surface` itself rather than our variable, and colors scoped to a theme stop following. ### UnoCSS UnoCSS emits utilities as ordinary rules with no layer. Unlayered rules beat any `@layer`, so utilities win over component styles with no ordering work. The cost is the mirror image: layered CSS you write cannot beat a UnoCSS class. To override one, write a more specific selector, or write unlayered CSS. If you turn on UnoCSS's CSS layer output (`outputToCssLayers`), treat it like Tailwind and place its layers after `astryx.components`. ## Using CSS Modules or plain CSS Both work. Three things to keep in mind. **Class names do not collide.** ` ``` **Values still come from variables.** Your own class names are fine; colors and spacing are still `var(--astryx-*)`. Slipping a `#171717` in breaks both dark mode and theming. If the project uses no layers at all, write specific selectors. Avoid bare element selectors such as `button { }`, and avoid a global `* { }`. These styles do not require UnoCSS. The docs site uses UnoCSS only so example classes such as `i-carbon-*` can draw icons. That is the icon approach, not a styling dependency. See [Icons](/en/guide/icons). Variable names, `light-dark()`, and what the theme covers today are in [CSS variables](/en/guide/css-variables) and [Neutral](/en/guide/themes/neutral). --- # Icons Source: https://astryx-vue.pages.dev/en/guide/icons.md Draw an icon with `Icon` and an Iconify name. You do not import a component for each glyph. ```vue ``` `carbon:settings` is the Carbon collection's settings icon. `carbon-settings` is the same name once that collection is registered. A collection id that already contains a hyphen keeps the colon, as in `material-symbols:home`. ## Bundle only the icons you name `@astryx-vue/core` does not include a collection. Install the one you want, and add the Vite plugin: ::: code-group ```sh [pnpm] pnpm add -D @iconify-json/carbon ``` ```sh [npm] npm install -D @iconify-json/carbon ``` ```sh [yarn] yarn add -D @iconify-json/carbon ``` ```sh [bun] bun add -d @iconify-json/carbon ``` ::: ```ts import { astryxIcons } from '@astryx-vue/core/icons' import vue from '@vitejs/plugin-vue' import { defineConfig } from 'vite' export default defineConfig({ plugins: [vue(), astryxIcons()], }) ``` The plugin looks at `@iconify-json/*` in the nearest `package.json`. It scans source for static names and emits a module per icon, so the client bundle contains those drawings and not the rest of the JSON. If the Vite root has no `package.json` — VitePress points its root at the docs directory — the plugin walks up until it finds one. A second collection is another package: install `@iconify-json/lucide` and write `name="lucide:settings"`. You do not need UnoCSS for this. Pass `collections: ['carbon']` when you want the plugin to ignore every other installed set. ## Names that are not written in source The plugin cannot see a name built at runtime. Register the collection in the app entry, before anything renders. This includes the whole set in the bundle: ```ts import { addCollection } from '@astryx-vue/core/Icon' import carbon from '@iconify-json/carbon/icons.json' addCollection(carbon) ``` `addIcon('carbon:settings', data)` registers one icon when you already have its Iconify body. ## Slots With no `size`, the icon is `1em` and uses `currentColor`. Button's `icon` and `end` slots, IconButton, and a field's start and end slots already size the box, so the icon fills it: ```vue ``` A decorative icon is hidden from assistive technology. Set `label` only when the icon itself is the message. The component page has the sizes, colors, and slot examples. ## CSS classes `icon` still accepts a CSS class, and so does `iconClass` on navigation and menu items. A class only draws something if your build generates it. UnoCSS is one way to do that. It is what the docs site uses for older examples. An application does not have to use it. The glyphs the components draw themselves (`chevronDown`, `check`, and the rest) are not a general icon set. Use `name` for product icons. ## Semantic names Inside the components, a semantic name is the job: search, close, check. Each one points at the Lucide icon that does the same job. Until that collection is registered, the built-in glyph stays. The set follows the theme. `defineTheme({ icons })` points a semantic name at an Iconify id, and a child theme only lists the names it changes. `Icon`'s `icon` prop resolves those names. `name` is still a direct Iconify id, and it wins. ```vue ``` Read the current id with `useSemanticIcon` from `@astryx-vue/core/Icon`. The name-to-id table is on the Icon props page. An entry can also be a function of the size the icon renders at and a variant the theme lists, and `componentIcons` picks which shared name a component's own icon uses, such as CodeBlock's copy button. Both are described on the Icon props page. --- # Composables Source: https://astryx-vue.pages.dev/en/guide/composables.md Import composables from the package root: ```ts import { useClipboard, useControllableState } from '@astryx-vue/core' ``` There is no `@astryx-vue/core/composables` subpath. The functions exported from `packages/core/src/composables/index.ts` are below. Parameters are the TypeScript types. | Function | What it does | | --- | --- | | `useControllableState` | A `v-model` that is controlled or internal. If the value is missing at setup, it stays internal. | | `useAnnounce` | Announces to screen readers. Matches upstream `useAnnounce`. | | `useClipboard` | Writes to the clipboard and keeps `isCopied` true for a short time. | | `useHotkeys` | Global shortcuts. `mod+k` uses ⌘ on Apple platforms. | | `useMediaQuery` | A media query as a ref, read once during setup. | | `useDismiss` | Outside press and Escape for popups. Escape uses a stack; the innermost layer handles it. | | `useFocusTrap` | Cycles Tab inside a container. | | `useRestoreFocus` | Remembers focus when a popup opens and returns it on close. | | `useScrollLock` | Locks `body` scroll with a reference count. | | `useListFocus` | Arrow keys for a one-dimensional list. The default selector is `[role="menuitem"]`. | | `useClickableContainer` | Makes a region activate on click, and leaves nested buttons, links, and inputs alone. | | `useGridRovingFocus` | Arrow keys for a grid. | | `useTypeahead` | Cycles matches as the same letter is pressed. It does not move focus; `onMatch` does. | | `useCombobox` | A searchable option list and the current value. | | `useNumberField` | A number with min, max, and step. | | `useAsyncSource`, `createStaticSource` | A cancellable search source, and a local static source. | | `useOverflow`, `computeOverflow` | Folds items that do not fit into an indicator. `computeOverflow` is pure. | | `useLongPress` | Fires after a hold. Moving too far cancels it. | | `useStreamingText` | Reveals text that has already arrived, at `natural`, `fast`, or `instant`. | | `snapToGraphemeBoundary` | Snaps an offset to a grapheme boundary for streaming text. | | `useChatStreamScroll` | Pins a transcript to the bottom, or lets it go. Reduced motion jumps instead of springing. | | `useChatNewMessages` | Marks rows that arrived while the reader was not pinned to the bottom. | | `useKeyboardHint` | The first time keyboard focus enters a group of arrow-key controls, shows a short hint beside the current item. | | `useImageMode` | Decides whether a foreground should be dark or light from an image's brightness. Returns `fallback` when sampling fails. | | `useContainerReveal` | Reveals inline actions on hover or keyboard focus. Returns classes for the container and the content. | | `useMenuPress` | After a menu press, swallows the browser's extra click. `resetMenuPress` is for unmount and tests. | `useClipboard` is also exported as `useCopyToClipboard` from `@astryx-vue/core` and from `@astryx-vue/core/Code`. The types are the same. Some functions belong to one component and are not in the table above. Import them from that component's subpath. The package root re-exports them too: | Function | Entry | | --- | --- | | `useToast` | `@astryx-vue/core/Toast` | | `useImperativeDialog` | `@astryx-vue/core/Dialog` | | `useImperativeAlertDialog` | `@astryx-vue/core/AlertDialog` | | `useOverlay` | `@astryx-vue/core/Overlay` | | `useContextMenu`, `useContextMenuSize` | `@astryx-vue/core/ContextMenu` | | `useDropdownMenuContext` | `@astryx-vue/core/DropdownMenu` | | `useSideNavCollapse` | `@astryx-vue/core/SideNav` | | `useListContext`, `useItemDescriptionId` | `@astryx-vue/core/List` | | `useTheme`, `useMediaTheme` | `@astryx-vue/core/Theme` | | `useIndicator` | `@astryx-vue/core/Indicator` | | `useSemanticIcon` | `@astryx-vue/core/Icon` | | `useTruncation` | `@astryx-vue/core/Text` | | `useSyntaxTheme` | `@astryx-vue/core/Code` | | `useChatComposerContext`, `useChatComposerTokens`, `useChatPasteAsToken`, `useChatDictation`, `useSpeechRecognition` | `@astryx-vue/core/Chat` | ## Truncation detection: useTruncation `Text` and `Heading` build their truncation tooltips on `useTruncation`. Use it directly when your own component should show the full text only when it is actually cut off, such as a table cell: ```vue ``` - The argument is the maximum line count (a number, ref or getter). 1 compares widths; above 1 measures the real content height with a Range, bypassing the `scrollHeight` that `-webkit-line-clamp` clips; 0 measures nothing. - Bind `bind` to the measured element; binding another element releases the previous one. `isTruncated` says whether the text is cut off now, and `fullText` is the element's current text, which follows content changes that resize nothing. - Apply the matching clamp yourself: `white-space: nowrap` with an ellipsis for one line, `-webkit-line-clamp` for more, so what people see and what the hook measures have the same shape. - The whole page shares one ResizeObserver and one MutationObserver, so hundreds of cells create one of each, and the first measurement runs after the browser's own layout instead of forcing one during mount. `provideAstryxLocale` and `useAstryxMessages` are in [Internationalization](/en/guide/i18n). --- # Patterns Source: https://astryx-vue.pages.dev/en/guide/patterns.md A conversation is a composition. The transcript, bubbles, reasoning, tool calls, citations, and the composer are separate components, and the page decides how they sit together. Nothing here calls a model. The body is a slot. Long replies are Markdown, and a source becomes a citation. Before any transcript exists, the page is a greeting and one composer. The mode can move among writing, coding, research, and creative work. Sensitive and deep modes insert a chip instead. @ opens people, and / opens commands. Files sit in the drawer, and a long paste becomes a chip too. The microphone appears only when the browser can recognize speech. Choosing a category writes that suggestion into the composer. Once a thread exists, the transcript is a column and the composer stays at the bottom. While the assistant is still writing, send becomes stop and the log is marked as streaming. Reasoning opens first, a tool call moves from running to complete, and the answer carries a citation. A generated document opens from a card. The full playground page keeps that document in a resizable side panel, and below 768px it becomes a full-screen dialog. Both examples below can be used. The full pages are in the playground: [AI Chat Landing](/en/playground/?template=ai-chat-landing) and [AI Chat Conversation](/en/playground/?template=ai-chat). Density, unread rules, and metadata are documented on [Chat](/en/components/chat). ### Landing Greeting, modes, mentions, commands, attachments, and category suggestions share one composer. Choosing a suggestion writes that prompt and switches the mode. ### Conversation One transcript carries reasoning, tool calls, a citation, and a document card. Sending grows the reply in that order, and stop is available while it is still running. The card opens a full-screen dialog. ## Pinned headers and footers In a long region, a header scrolls out of sight and a commit button scrolls out of reach, so people scroll back and forth. `Layout` defaults to `height="fill"`: it fills its container and only the body scrolls, while the header and footer stay put. ```vue ``` A few notes. - Write `padding` once, on `Layout`. The header, body, and footer share one inline padding, so their text lines up on one vertical line. - `defaultHasDividers` draws the line on both the header and the footer, so neither region needs its own `hasDivider`. - A title plus one primary action goes in `LayoutHeader`. When the header carries a row of interactive controls, such as filters, sort, or bulk actions, use `Toolbar` instead; it handles arrow-key movement by the toolbar accessibility rules. - The footer holds only the actions that must stay reachable: Save, Submit, Next. Secondary actions stay in the body. To check it: scroll the body to the bottom. The header and footer have not moved, the dividers still run edge to edge, and the header title still shares a left edge with the first line of the body. ## Side detail panels In a master-detail view, selecting a row usually navigates away, and coming back means finding your place again. A fixed-width panel on the end edge keeps the list in place instead. ```vue ``` - A panel width between 340 and 420 works well. `width` as a number is pixels. - `hasDivider` draws the edge facing the content. Do not draw a line on both sides. - `isScrollable` lets long details scroll inside the panel without moving the list. - Put an `EmptyState` in when nothing is selected. An empty panel collapses to a sliver, then the page jumps wider on the first selection. To let people drag the width, hand `useResizable` to both the panel and a `ResizeHandle`. ```vue ``` On the end edge, turn `isReversed` on so dragging left makes the panel wider. The handle carries `has-divider` and the panel turns `hasDivider` off, so one edge draws one line. On a narrow screen, do not squeeze. Let the panel go and show the details in a `Dialog` or a `BottomSheet` instead. See [Responsive layout](/en/guide/responsive). --- # Templates Source: https://astryx-vue.pages.dev/en/guide/templates.md Each playground page is a starting point you can edit. Choosing one puts its source in the editor, and the preview follows the theme. Add `?template=` to open a page directly, for example the [blank page](/en/playground/?template=blank). The blank page is a title and an empty content area. It has no navigation and no other chrome. Start there when every other template brings more structure than you want. Templates are grouped by job. The name on the right opens that source in the playground. --- # Links and routers Source: https://astryx-vue.pages.dev/en/guide/links.md A jump in the app is one of two things. A normal `href` lets the browser open the address. A route that should stay inside Vue Router, without a full page load, swaps the root for `RouterLink`. Components that can swap their root take the same `as` prop. It accepts a component or a tag name. The swap happens only when `href` is set and the item is not disabled. Otherwise the root stays a button and `as` is ignored. On a custom component the same address is passed as both `href` and `to`. `RouterLink` reads `to`. ```vue ``` `SideNavItem`, `TopNavItem`, `TopNavHeading`, `NavMenuItem`, and `SideNavHeading` work the same way. Top-nav mega-menu items and featured cards take `as` too. On `OverflowList`, `as` belongs to the list and is applied to visible items that have an `href` and are not disabled. A button can swap its root when it has an `href` and is not disabled. While it is loading or disabled it goes back to a `