<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Astryx on KnightLi Blog</title>
        <link>https://knightli.com/en/tags/astryx/</link>
        <description>Recent content in Astryx on KnightLi Blog</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en</language>
        <lastBuildDate>Sun, 12 Jul 2026 12:15:00 +0800</lastBuildDate><atom:link href="https://knightli.com/en/tags/astryx/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>How to Connect AI-Generated Frontends to a Design System with Astryx: React Components, Themes, and Acceptance Constraints</title>
        <link>https://knightli.com/en/2026/07/12/astryx-ai-generated-frontend-react-design-system-theme-guide/</link>
        <pubDate>Sun, 12 Jul 2026 12:15:00 +0800</pubDate>
        
        <guid>https://knightli.com/en/2026/07/12/astryx-ai-generated-frontend-react-design-system-theme-guide/</guid>
        <description>&lt;p&gt;Generating one page with AI is easy; making the second and third pages retain the right colors, spacing, component states, accessibility attributes, and interaction boundaries is harder. Astryx is Meta&amp;rsquo;s open-source React design system. The official repository describes it as Beta, with 150+ accessible components, themes, dark mode, templates, and a CLI, and supports theme overrides through CSS custom properties. &lt;a class=&#34;link&#34; href=&#34;https://github.com/facebook/astryx&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Official repository&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The purpose of connecting Astryx to an Agent is not to let the model design freely. It is to make people and agents use the same components and documentation.&lt;/p&gt;
&lt;h2 id=&#34;decide-whether-it-fits-first&#34;&gt;Decide whether it fits first
&lt;/h2&gt;&lt;p&gt;It is usually a fit when:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A React project already has several back-office pages and AI-generated UI is drifting.&lt;/li&gt;
&lt;li&gt;The team needs consistent buttons, forms, dialogs, empty states, and dark mode.&lt;/li&gt;
&lt;li&gt;Agents should compose existing components instead of writing CSS from scratch.&lt;/li&gt;
&lt;li&gt;You can validate and version-lock a Beta dependency in isolation.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If the project is not React or already has a mature internal library, do not refactor just for a trend. Move practices such as component-first work, token-first work, and screenshot acceptance into the existing system instead.&lt;/p&gt;
&lt;h2 id=&#34;installation-and-a-minimal-theme&#34;&gt;Installation and a minimal theme
&lt;/h2&gt;&lt;p&gt;The official example uses:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;npm install @astryxdesign/core @astryxdesign/theme-neutral
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;npm install -D @astryxdesign/cli
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Verify build, style loading, and dark mode in an isolated branch or small page before expanding to the application entry point. Do not let an Agent replace global styles, the route shell, or existing token files.&lt;/p&gt;
&lt;p&gt;A theme should express brand constraints, not let every page override itself. Record the colors, radii, typography, and spacing that may change in project rules so the Agent knows what to reuse rather than merely being told to “make it look premium.”&lt;/p&gt;
&lt;h3 id=&#34;start-with-a-small-page-not-the-application-shell&#34;&gt;Start with a small page, not the application shell
&lt;/h3&gt;&lt;p&gt;Start on one route, such as settings, a filter sidebar, or a data-detail card. List its current typography, spacing, color tokens, interaction states, and components, then have the Agent rebuild one area with Astryx. Keep routing, data requests, permission checks, and the global style entry unchanged; the design system owns components and themes, not business migration.&lt;/p&gt;
&lt;p&gt;Use a fixed local sequence: install dependencies and start the dev server; inspect light and dark modes; use Tab through forms, dialogs, and buttons; narrow the window to mobile width; then run existing tests or the build. Record issues with that component instead of discovering token overrides, CSS precedence, or focus conflicts after many pages have migrated.&lt;/p&gt;
&lt;p&gt;Once the small page is stable, make it a reference implementation: record permitted packages, theme entry, component import style, and global files that must not change. Later Agent tasks should point to this reference rather than rediscovering conventions.&lt;/p&gt;
&lt;h2 id=&#34;project-level-constraints-for-an-agent&#34;&gt;Project-level constraints for an Agent
&lt;/h2&gt;&lt;p&gt;Put rules like these in &lt;code&gt;AGENTS.md&lt;/code&gt;, &lt;code&gt;CLAUDE.md&lt;/code&gt;, or a Skill:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;5
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;- 新页面优先使用 @astryxdesign 现有组件；新增自定义组件前先说明原因。
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;- 不新增全局 CSS reset，不修改既有主题 token。
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;- 所有表单字段必须有可见 label、错误态和禁用态。
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;- 完成后提供桌面和窄屏截图，并列出新增组件与交互状态。
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;- 不以截图相似为唯一验收；保留键盘操作和语义结构。
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;That is more actionable than “build a dashboard with the design system.” It gives the Agent prohibited changes, a reuse path, and deliverables, and lets reviewers spot whether the component library was bypassed.&lt;/p&gt;
&lt;h3 id=&#34;put-inputs-outputs-and-prohibitions-in-the-task&#34;&gt;Put inputs, outputs, and prohibitions in the task
&lt;/h3&gt;&lt;p&gt;A real task should state page scope, usable data, editable files, and required screenshots. For example: change only &lt;code&gt;src/features/orders/FilterPanel.tsx&lt;/code&gt;; reuse existing query parameters; add no dependency, route, or change to &lt;code&gt;theme.ts&lt;/code&gt;; provide desktop and narrow screenshots and list Button, Select, and Dialog states. This prevents an Agent from changing global reset, state management, or the API layer just to reach a visual result.&lt;/p&gt;
&lt;p&gt;For a complex component, ask first for a structural draft: which sections exist, which Astryx component each maps to, and which loading/error/empty states are needed. Approve the structure before code. If the design exceeds the library, adjust the design or name an owner for the new component rather than inserting disposable CSS.&lt;/p&gt;
&lt;h2 id=&#34;use-four-acceptance-layers-to-reduce-ui-drift&#34;&gt;Use four acceptance layers to reduce UI drift
&lt;/h2&gt;&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Layer&lt;/th&gt;
          &lt;th&gt;Check&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;Components&lt;/td&gt;
          &lt;td&gt;Are existing Button, Input, Dialog, and similar components reused, with complete states?&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Theme&lt;/td&gt;
          &lt;td&gt;Are visual changes made only through allowed tokens or CSS variables?&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Interaction&lt;/td&gt;
          &lt;td&gt;Do keyboard focus, loading, error, and empty states work?&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Delivery&lt;/td&gt;
          &lt;td&gt;Does the build pass, do screenshots cover key pages, and is there a component list?&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Visual consistency is not pixel copying. What must stay stable is accessible semantics, state machines, theme source, and maintainable component boundaries.&lt;/p&gt;
&lt;h2 id=&#34;a-repeatable-acceptance-process&#34;&gt;A repeatable acceptance process
&lt;/h2&gt;&lt;p&gt;Before merging, inspect the diff for global styles that bypass the library, hard-coded brand colors, and unrelated files. In the browser verify normal data, loading, empty data, and API failure; for forms also test required, format-error, disabled, and submitting states. Screenshots of only the normal state hide most regressions.&lt;/p&gt;
&lt;p&gt;Finally complete a key flow with the keyboard: Tab order should make sense, focus must enter and leave Dialog, error messages must associate with fields, and color contrast must remain sufficient. Put these checks in the PR template so Agent-generated pages receive the same standard.&lt;/p&gt;
&lt;h2 id=&#34;common-mistakes&#34;&gt;Common mistakes
&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Treating Beta as a reason to rewrite the site&lt;/strong&gt;: lock a version and validate upgrade cost in one domain first.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Letting the Agent edit component internals&lt;/strong&gt;: prefer composition and theme overrides; export or take over source only when necessary.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Writing one-off CSS per page&lt;/strong&gt;: the system becomes only a package name and cannot constrain future Agents.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Accepting screenshots without interaction checks&lt;/strong&gt;: screenshots do not reveal tab order, error feedback, or disabled buttons.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;summary&#34;&gt;Summary
&lt;/h2&gt;&lt;p&gt;Astryx can establish a shared frontend language for people and Agents. Validate components, theme, and acceptance on a few pages first, then record the rules in project files; do not turn a new design system into another unmaintained abstraction.&lt;/p&gt;
</description>
        </item>
        
    </channel>
</rss>
