cubix
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCubix
Cubix
Cubix components are source files the project owns. They are copied into the app by the CLI from the registry at , then edited like any other code. Never install Cubix components from npm and never hand-write a component that the registry already provides.
cubix-uihttps://cubixflow.ir/rPublic readiness contract: a component is installable only when it has Base UI, React Aria, and Radix UI sources, docs, and a registry entry. If does not list a name, or returns 404, it is on the roadmap - do not invent a stub and do not paste unfinished source from the monorepo.
cubix-ui searchaddCubix 组件是由项目自主管理的源文件。它们通过 CLI 从 上的注册表复制到应用中,随后可以像其他代码一样编辑。切勿从 npm 安装 Cubix 组件;如果注册表已经提供某个组件,切勿手动编写。
cubix-uihttps://cubixflow.ir/r公开可用性规范:组件只有在具备 Base UI、React Aria 和 Radix UI 源码、文档及注册表条目时,才可安装。如果 未列出某个名称,或 返回 404,则说明该组件仍在路线图中——不要臆造占位实现,也不要粘贴 monorepo 中未完成的源代码。
cubix-ui searchadd1. Read project context first
1. 先读取项目上下文
Before generating UI, resolve the project configuration:
bash
npx cubix-ui@latest info --jsonIf the CLI is unavailable, read at the project root. The fields that matter:
cubix.json| Field | Use it for |
|---|---|
| Primitive backend: |
| Import path for components, usually |
| Import path for |
| The global stylesheet that holds the design tokens. |
| When |
| Icon package to import from, usually |
If there is no , initialize the project before adding anything (see section 2).
cubix.json生成 UI 前,先解析项目配置:
bash
npx cubix-ui@latest info --json如果 CLI 不可用,请读取项目根目录下的 。需要关注的字段如下:
cubix.json| 字段 | 用途 |
|---|---|
| 基础组件后端: |
| 组件的导入路径,通常为 |
| |
| 存放设计令牌的全局样式表。 |
| 为 |
| 要导入的图标包,通常为 |
如果不存在 ,请先初始化项目,然后再添加任何内容(参见第 2 节)。
cubix.json2. Use the CLI, not hand-written copies
2. 使用 CLI,而不是手写副本
bash
undefinedbash
undefinedExisting app: configure tokens, cubix.json, and lib/utils.ts
Existing app: configure tokens, cubix.json, and lib/utils.ts
npx cubix-ui@latest init
npx cubix-ui@latest init
New app: scaffold a framework, then configure Cubix
New app: scaffold a framework, then configure Cubix
npx cubix-ui@latest init -t next # also: vite, start, react-router, astro
npx cubix-ui@latest init -t next --base radix
npx cubix-ui@latest init -t next # also: vite, start, react-router, astro
npx cubix-ui@latest init -t next --base radix
Discover before you build
Discover before you build
npx cubix-ui@latest search -q dialog
npx cubix-ui@latest view dialog
npx cubix-ui@latest search -q dialog
npx cubix-ui@latest view dialog
Add components (dependencies and registry dependencies are resolved)
Add components (dependencies and registry dependencies are resolved)
npx cubix-ui@latest add button dialog select
npx cubix-ui@latest add button --base aria
npx cubix-ui@latest add button --dry-run
npx cubix-ui@latest add button --overwrite
Rules:
- Search the registry before creating a new component. Only add names that search returns.
- Prefer Text Field / Email Field / Phone Field over a generic Input when those are what the registry publishes.
- Respect the package manager already used by the project (`pnpm dlx`, `yarn dlx`, `bunx --bun`, or `npx`).
- Use `--base` only when the user explicitly wants a different base than `cubix.json`.
- Use `--dry-run` to preview when files may already exist, and `--overwrite` only with the user's consent, because it replaces local edits.npx cubix-ui@latest add button dialog select
npx cubix-ui@latest add button --base aria
npx cubix-ui@latest add button --dry-run
npx cubix-ui@latest add button --overwrite
规则:
- 创建新组件前,先搜索注册表。只添加搜索结果中返回的名称。
- 如果注册表提供 Text Field / Email Field / Phone Field,应优先使用它们,而不是通用 Input。
- 尊重项目已在使用的包管理器(`pnpm dlx`、`yarn dlx`、`bunx --bun` 或 `npx`)。
- 仅当用户明确希望使用与 `cubix.json` 不同的 base 时,才使用 `--base`。
- 当文件可能已存在时,使用 `--dry-run` 预览;只有在用户同意时才使用 `--overwrite`,因为它会替换本地编辑。3. Compose components correctly
3. 正确组合组件
Import from the alias with named exports:
uitsx
import { Button } from "@/components/cubix/button"
import { Field, FieldLabel, FieldDescription } from "@/components/cubix/field"
import { Input } from "@/components/cubix/input"Every base exposes the same visual API. To render a component as another element, pass and set when the target is not a :
rendernativeButton={false}<button>tsx
import Link from "next/link"
<Button nativeButton={false} render={<Link href="/docs" />}>
Read the docs
</Button>On the Radix base, is also accepted. Prefer so code stays portable across bases.
asChildrenderConventions every Cubix part follows, and that new code must follow too:
- A attribute on every part, for example
data-slot.data-slot="card-header" - merged through
classNamefrom thecn()alias.utils - Visual variants defined with and exported next to the component.
cva - Accessible states: keyboard operation, a visible ring,
focus-visiblefor errors, andaria-invalidhandling.disabled
从 别名使用具名导出进行导入:
uitsx
import { Button } from "@/components/cubix/button"
import { Field, FieldLabel, FieldDescription } from "@/components/cubix/field"
import { Input } from "@/components/cubix/input"每种 base 都提供相同的视觉 API。若要将组件渲染为另一个元素,请传入 ;当目标元素不是 时,设置 :
render<button>nativeButton={false}tsx
import Link from "next/link"
<Button nativeButton={false} render={<Link href="/docs" />}>
Read the docs
</Button>在 Radix base 上,也支持 。优先使用 ,这样代码在不同 base 之间保持可移植性。
asChildrender每个 Cubix 组成部分都遵循以下约定,新代码也必须遵循:
- 每个部分都需要一个 属性,例如
data-slot。data-slot="card-header" - 通过 别名中的
utils合并cn()。className - 使用 定义视觉变体,并与组件一同导出。
cva - 无障碍状态:支持键盘操作、可见的 焦点环、错误状态使用
focus-visible,并处理aria-invalid状态。disabled
4. Style with tokens only
4. 仅使用令牌进行样式设计
Use the semantic Tailwind tokens defined in the stylesheet from . They switch automatically in dark mode.
tailwind.css| Purpose | Tokens |
|---|---|
| Surfaces | |
| Text | |
| Actions | |
| Lines and focus | |
| Charts and sidebar | |
Never use hex, rgb, or palette classes such as or in product UI. To re-brand, change the CSS variables (oklch values) in the stylesheet instead of overriding components.
bg-zinc-900text-[#333]Prefer logical properties (, , , , , , ) so layouts work in right-to-left locales.
ps-*pe-*ms-*me-*start-*end-*text-start使用在 所指向的样式表中定义的语义化 Tailwind 令牌。它们会在深色模式下自动切换。
tailwind.css| 用途 | 令牌 |
|---|---|
| 表面 | |
| 文本 | |
| 操作 | |
| 线条与焦点 | |
| 图表与侧边栏 | |
绝不要在产品 UI 中使用 hex、rgb 或调色板类,例如 或 。若要更换品牌视觉,应修改样式表中的 CSS 变量(oklch 值),而不是覆盖组件。
bg-zinc-900text-[#333]优先使用逻辑属性(、、、、、、),以确保布局适配从右到左的语言环境。
ps-*pe-*ms-*me-*start-*end-*text-start5. Agent and chat interfaces
5. Agent 与聊天界面
Several agent surfaces are still on the roadmap. Before using any of them, confirm the name appears in . Ready building blocks today include things like , , and the standard form/overlay primitives. Do not hand-roll Conversation / Prompt Input / Thinking replacements from memory if search does not list them yet.
cubix-ui searchattachmentbranchWhen an agent surface is public, handle every state: empty conversation, streaming, error, and stopped generation, not only the happy path.
多个 Agent 界面仍在路线图中。使用其中任何一个之前,请确认其名称出现在 的结果中。目前可用的构建块包括 、 和标准表单/浮层原语等。如果搜索结果尚未列出它们,不要凭记忆手动编写 Conversation / Prompt Input / Thinking 的替代实现。
cubix-ui searchattachmentbranch当某个 Agent 界面公开可用时,必须处理所有状态:空对话、流式输出、错误和生成已停止,而不能只处理正常路径。
6. Authoring registry items
6. 编写注册表条目
To publish your own items, describe them in a source , then build the JSON the CLI consumes:
registry.jsonbash
npx cubix-ui@latest build ./registry.json -o ./public/rEach item needs a , a such as or , its , and accurate (npm packages) and (other Cubix items). Validate against and .
nametyperegistry:uiregistry:blockfilesdependenciesregistryDependencieshttps://cubixflow.ir/schema/registry.jsonhttps://cubixflow.ir/schema/registry-item.json要发布自己的条目,请在源文件 中描述这些条目,然后构建供 CLI 使用的 JSON:
registry.jsonbash
npx cubix-ui@latest build ./registry.json -o ./public/r每个条目都需要 、(例如 或 )、,以及准确的 (npm 包)和 (其他 Cubix 条目)。请根据 和 进行校验。
nametyperegistry:uiregistry:blockfilesdependenciesregistryDependencieshttps://cubixflow.ir/schema/registry.jsonhttps://cubixflow.ir/schema/registry-item.json7. Optional: Cubix MCP
7. 可选:Cubix MCP
When the host supports MCP over HTTP, connect any client to the same public URL:
https://cubixflow.ir/api/mcp- Cursor - project or
.cursor/mcp.json:~/.cursor/mcp.json
json
{
"mcpServers": {
"cubix": {
"url": "https://cubixflow.ir/api/mcp"
}
}
}- Codex - (or
codex mcp add cubix --url https://cubixflow.ir/api/mcpwith[mcp_servers.cubix]inurl)~/.codex/config.toml - Claude -
claude mcp add --transport http cubix https://cubixflow.ir/api/mcp
Tools: , , , , . Prefer these for discovery, then still run (or the command from ) so owned source lands correctly. Docs: https://cubixflow.ir/docs/mcp
list_componentssearch_componentsget_componentget_component_demoget_install_commandcubix-ui addget_install_command当宿主支持通过 HTTP 使用 MCP 时,可以将任意客户端连接到同一个公开 URL:
https://cubixflow.ir/api/mcp- Cursor — 项目中的 或用户目录中的
.cursor/mcp.json:~/.cursor/mcp.json
json
{
"mcpServers": {
"cubix": {
"url": "https://cubixflow.ir/api/mcp"
}
}
}- Codex — (或在
codex mcp add cubix --url https://cubixflow.ir/api/mcp中通过~/.codex/config.toml设置[mcp_servers.cubix])url - Claude —
claude mcp add --transport http cubix https://cubixflow.ir/api/mcp
工具:、、、、。优先使用这些工具进行检索,然后仍应运行 (或 返回的命令),以确保项目自有源代码正确落盘。文档:https://cubixflow.ir/docs/mcp
list_componentssearch_componentsget_componentget_component_demoget_install_commandcubix-ui addget_install_commandReference
参考
- Documentation: https://cubixflow.ir/docs
- MCP: https://cubixflow.ir/docs/mcp
- CLI reference: https://cubixflow.ir/docs/cli
- Components: https://cubixflow.ir/docs/components
- Theming: https://cubixflow.ir/docs/theming
- Registry: https://cubixflow.ir/docs/registry