meta / astryx
本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。
meta / astryx
Astryx An open source design system that’s fully customizable and built for how we build now: by people and the agents working alongside them. Currently in Beta · Built on React 19+ and StyleX Docs · Storybook · Sandbox · Contributing · Discord
Astryx 是一个开源设计系统,它完全可定制,专为我们当下的构建方式而设计:由人类及其协作的智能体共同构建。目前处于测试阶段 · 基于 React 19+ 和 StyleX 构建 · 文档 · Storybook · 沙盒 · 贡献指南 · Discord
Overview Astryx is an open source design system that grew inside Meta over the last eight years, where it became the most-used and largest design system in the company — powering 13,000+ apps and shaped by the engineers, designers, and product teams who depend on it every day. It ships 150+ accessible components, brand-level theming, dark mode, ready-to-ship templates, and a CLI as one cohesive system. You import pre-built CSS and use typed React components — no build plugin, no styling library to adopt — and both people and AI assistants build with the same tooling.
概述:Astryx 是一个在 Meta 内部成长了八年的开源设计系统,它已成为公司内部使用最广泛、规模最大的设计系统,为 13,000 多个应用程序提供支持,并由每天依赖它的工程师、设计师和产品团队共同塑造。它作为一个统一的系统,提供了 150 多个无障碍组件、品牌级主题、深色模式、即用型模板以及 CLI。你只需导入预构建的 CSS 并使用类型化的 React 组件,无需采用构建插件或样式库,人类和 AI 助手可以使用相同的工具进行构建。
What makes Astryx different: Open internals. Components are built to be composed at any level, not locked behind a closed top-level API. The building blocks you’d reach for are exported directly, and when you need to go deeper, swizzle ejects a component’s full source into your project to own. No styling lock-in. Astryx authors its styles with StyleX, but that’s invisible to consumers. Override with className using Tailwind, CSS modules, or plain CSS — whatever your project already uses. Customize without wrapping. A theme is a set of CSS custom property overrides, so a designer can make Astryx unmistakably theirs without forking or wrapping component source. Built for people and agents. The API, docs, and CLI are designed together so a person and an AI assistant build the same way, from the same reference.
Astryx 的独特之处:开放的内部结构。组件被设计为可在任何层级进行组合,而不是被锁定在封闭的顶层 API 之后。你所需要的构建块是直接导出的,当你需要深入了解时,swizzle 功能可以将组件的完整源代码提取到你的项目中以供掌控。没有样式锁定。Astryx 使用 StyleX 编写样式,但这对使用者是不可见的。你可以使用 Tailwind、CSS 模块或普通 CSS 通过 className 进行覆盖,无论你的项目当前使用什么。无需包装即可自定义。主题是一组 CSS 自定义属性覆盖,因此设计师无需分叉或包装组件源代码,即可打造出具有鲜明个人风格的 Astryx。为人类和智能体而生。API、文档和 CLI 是协同设计的,确保人类和 AI 助手能够以相同的方式、参考相同的标准进行构建。
Getting Started Astryx requires React 19 or later (react and react-dom are peer dependencies of @astryxdesign/core). Install Astryx, a theme, and its peer dependencies:
入门:Astryx 需要 React 19 或更高版本(react 和 react-dom 是 @astryxdesign/core 的对等依赖项)。安装 Astryx、一个主题及其对等依赖项:
npm npm install @astryxdesign/core @astryxdesign/theme-neutral @stylexjs/stylex npm install -D @astryxdesign/cli # pnpm pnpm add @astryxdesign/core @astryxdesign/theme-neutral @stylexjs/stylex pnpm add -D @astryxdesign/cli # yarn yarn add @astryxdesign/core @astryxdesign/theme-neutral @stylexjs/stylex yarn add -D @astryxdesign/cli
(代码安装命令同上)
You can also install the CLI once for your computer, so astryx works in any folder and every coding agent knows Astryx; in a project, it still runs that project’s own version: npm i -g @astryxdesign/cli Project install, global install, or both? astryx docs global/project-global-or-both compares them (both is recommended), and astryx docs global explains how global mode works. The simplest setup is a few CSS imports plus a theme provider — no build plugin, no PostCSS or Babel config. See the @astryxdesign/core README for the full guide (Next.js, Tailwind, Vite, and CDN).
你也可以在电脑上安装一次 CLI,这样 astryx 就能在任何文件夹中工作,且每个编码智能体都能识别 Astryx;在项目中,它仍会运行该项目自身的版本:npm i -g @astryxdesign/cli。项目安装、全局安装还是两者兼有?astryx docs global/project-global-or-both 对它们进行了比较(建议两者兼有),astryx docs global 解释了全局模式的工作原理。最简单的设置是进行几次 CSS 导入加上一个主题提供程序,无需构建插件、PostCSS 或 Babel 配置。请参阅 @astryxdesign/core 的 README 获取完整指南(Next.js、Tailwind、Vite 和 CDN)。
For reliable CLI access, add a script to your package.json: “scripts”: { “astryx”: “node node_modules/@astryxdesign/cli/clients/cli/bin/astryx.mjs” } Then use it as npm run astryx — component —list. This avoids path errors when AI assistants or new developers invoke the CLI directly.
为了确保可靠的 CLI 访问,请在 package.json 中添加一个脚本:“scripts”: { “astryx”: “node node_modules/@astryxdesign/cli/clients/cli/bin/astryx.mjs” }。然后使用 npm run astryx — component —list 来调用它。这可以避免 AI 助手或新开发人员直接调用 CLI 时出现路径错误。
Packages Package Description README @astryxdesign/core Components, theme system, and utilities README @astryxdesign/cli CLI tooling: component docs, templates, scaffolding, themes, and codemods README @astryxdesign/build Build plugins for StyleX source builds README @astryxdesign/theme-* Seven ready-made, fully customizable themes (neutral, butter, chocolate, matcha, stone, gothic, y2k) README @astryxdesign/lab (experimental components) is used internally for Storybook and the sandbox and is not published to npm. @astryxdesign/vega (Vega/Vega-Lite chart wrapper) and @astryxdesign/charts (chart components) are published to npm only under the @canary dist-tag — there is no stable release yet.
软件包: @astryxdesign/core:组件、主题系统和实用工具 @astryxdesign/cli:CLI 工具:组件文档、模板、脚手架、主题和代码转换 @astryxdesign/build:用于 StyleX 源码构建的构建插件 @astryxdesign/theme-*:七种现成的、完全可定制的主题(neutral, butter, chocolate, matcha, stone, gothic, y2k) @astryxdesign/lab:(实验性组件)在内部用于 Storybook 和沙盒,未发布到 npm。 @astryxdesign/vega(Vega/Vega-Lite 图表包装器)和 @astryxdesign/charts(图表组件)仅在 @canary 发行标签下发布到 npm,目前尚无稳定版本。
Principles These are the promises Astryx makes to the people building on it. Guidance over enforcement. Components give you capability rather than guardrails that fight you. Design opinions live in docs and examples — if you pass a value, the component renders it. Strong, documented conventions. Every component follows the same naming, prop, and composition rules, and every one is thoroughly documented — so once you’ve learned a few, the rest feel familiar, and both people and AI can predict how an unfamiliar component behaves. One system for humans and AI. The API, conventions, docs, and CLI are designed together so people and AI assistants build the same way. Every change that made Astryx easier for AI made it easier for people too. Earned by measurement. We test conventions rather than assert them, hold the results loosely, and revisit them when a new situation proves them wrong.
原则:这些是 Astryx 对其构建者的承诺。引导而非强制。组件为你提供能力,而不是与你作对的护栏。设计观点存在于文档和示例中,如果你传递一个值,组件就会渲染它。强大且有据可查的约定。每个组件都遵循相同的命名、属性和组合规则,并且每个组件都有详尽的文档记录,因此一旦你学会了几个,其余的就会感到熟悉,人类和 AI 都能预测不熟悉的组件的行为。人类和 AI 的统一系统。API、约定、文档和 CLI 是协同设计的,因此人类和 AI 助手以相同的方式进行构建。每一个让 Astryx 对 AI 更友好的改进,同时也让它对人类更友好。通过衡量获得。我们测试约定而不是断言它们,对结果保持开放态度,并在新情况证明它们错误时重新审视它们。
Architecture Foundations The building blocks for visually cohesive and accessible interfaces: typography, color, layout, and accessibility. Components A library of 150+ reusable UI building blocks with full TypeScript support. Patterns Battle-tested design solutions for common interactions and workflows: table pages, detail page layouts, form wizards, navigation patterns, data entry flows. Project Structure Directory Purpose apps/ Example apps, the docsite, and Storybook packages/ Published packages: core, cli, build, themes internal/ Internal tooling: test utilities, eslint plugin, vibe tests
架构基础:视觉上连贯且无障碍界面的构建块:排版、颜色、布局和无障碍性。组件:一个包含 150 多个可重用 UI 构建块的库,提供完整的 TypeScript 支持。模式:针对常见交互和工作流的经过实战检验的设计解决方案:表格页面、详情页面布局、表单向导、导航模式、数据输入流。项目结构:apps/(示例应用、文档站点和 Storybook)、packages/(已发布的包:core, cli, build, themes)、internal/(内部工具:测试实用程序、eslint 插件、vibe 测试)。
Contributing We welcome contributions! See CONTRIBUTING.md for the full guide. Questions, or want a hand with a PR? Come find us in Discord. Our conventions and review rubrics live in the Contributing wiki — including API Conventions, Design Conventions, the Component Lifecycle, the Contributing Templates, and the Blog Review Rubric. Read the relevant rubric before opening a PR. Quick start for contributors: this repo uses Node 22+ on an active LTS line and pnpm 11. Install pnpm directly, or enable Corepack once so the pinned pnpm version installs automatically: corepack enable pnpm install If corepack is missing, install pnpm directly or install Corepack manually; see the troubleshooting notes in CONTRIBUTING.md. The Theme Showcase DOM tests use the root ui project for shared DOM and S
贡献:我们欢迎贡献!请参阅 CONTRIBUTING.md 获取完整指南。有问题或需要 PR 方面的帮助?请在 Discord 上找到我们。我们的约定和审查准则位于贡献 Wiki 中,包括 API 约定、设计约定、组件生命周期、贡献模板和博客审查准则。在提交 PR 之前,请阅读相关准则。贡献者快速入门:此存储库使用 Node 22+(处于活跃 LTS 线路)和 pnpm 11。直接安装 pnpm,或启用一次 Corepack,以便自动安装固定的 pnpm 版本:corepack enable pnpm install。如果缺少 corepack,请直接安装 pnpm 或手动安装 Corepack;请参阅 CONTRIBUTING.md 中的故障排除说明。主题展示 DOM 测试使用根 ui 项目进行共享 DOM 和 S