starwind-ui
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseStarwind UI
Starwind UI
Astro components and design-system primitives installed as source code into the user's project via the Starwind CLI. Starwind UI is designed for Astro v6 and Tailwind CSS v4.
IMPORTANT: Run CLI commands from the user's project root using the project's package runner:,npx starwind@latest/pnpx starwind@latest, orpnpm dlx starwind@latest, based onyarn dlx starwind@latest, lockfiles,package.json, or user instruction.starwind.config.json
Examples below use , but substitute the correct runner for the project.
npx starwind@latestAstro组件与设计系统基础元素通过Starwind CLI以源代码形式安装到用户项目中。Starwind UI专为Astro v6和Tailwind CSS v4设计。
重要提示: 请从用户项目根目录使用项目的包运行器执行CLI命令:根据、锁文件、package.json或用户指令,选择starwind.config.json、npx starwind@latest/pnpx starwind@latest或pnpm dlx starwind@latest。yarn dlx starwind@latest
以下示例使用,请根据项目替换为正确的运行器。
npx starwind@latestCurrent Project Context
当前项目上下文
Build project context from local files before editing:
- , lockfiles, and
package.json-> package runner and dependency commands.packageManager - -> Astro project shape and Tailwind/Vite setup.
astro.config.* - ->
starwind.config.json,starwind.css, base color, and installed component list.componentDir - Active Starwind CSS file -> global tokens, ,
@theme inline,:root, and sidebar tokens..dark - Installed component directory, commonly -> available imports and local source.
src/components/starwind - Local component exports -> final authority for component part names when docs and local code differ.
index.ts
在编辑前从本地文件构建项目上下文:
- 、锁文件与
package.json-> 包运行器和依赖命令。packageManager - -> Astro项目结构与Tailwind/Vite配置。
astro.config.* - ->
starwind.config.json、starwind.css、基础颜色及已安装组件列表。componentDir - 活跃的Starwind CSS文件 -> 全局令牌、、
@theme inline、:root及侧边栏令牌。.dark - 已安装组件目录(通常为) -> 可用的导入项与本地源代码。
src/components/starwind - 本地组件导出内容 -> 当文档与本地代码存在差异时,以此作为组件部件名称的最终依据。
index.ts
Principles
原则
- Use existing components first. Check Starwind docs, MCP, search, local components, or registry metadata before writing custom UI.
- Compose, don't reinvent. Settings page = Tabs + Card + form controls. Dashboard = Sidebar + Card + Table + feedback primitives. Searchable select = Select + SelectSearch.
- Use built-in variants before custom styles. ,
variant="outline",size="sm", etc.size="icon" - Use semantic colors and tokens. ,
bg-primary,text-muted-foreground,border-border; avoid raw palette utilities when a semantic token exists.bg-card - Astro syntax first. Use ,
class, browser scripts, andforcomponent imports unless the local project intentionally uses a framework island..astro
- 优先使用现有组件。在编写自定义UI前,先查阅Starwind文档、MCP、搜索结果、本地组件或注册表元数据。
- 组合复用,而非重复造轮子。设置页面 = 标签页(Tabs)+ 卡片(Card)+ 表单控件;仪表盘 = 侧边栏(Sidebar)+ 卡片(Card)+ 表格(Table)+ 反馈基础元素;可搜索选择器 = 选择器(Select)+ 选择器搜索(SelectSearch)。
- 优先使用内置变体而非自定义样式。例如、
variant="outline"、size="sm"等。size="icon" - 使用语义化颜色与令牌。例如、
bg-primary、text-muted-foreground、border-border;当存在语义化令牌时,避免使用原始调色板工具类。bg-card - 优先使用Astro语法。使用、
class、浏览器脚本及for组件导入,除非本地项目特意使用框架孤岛(island)。.astro
Critical Rules
核心规则
These rules are always enforced. Each links to a focused reference file.
这些规则始终强制执行,每条规则均链接至对应的参考文件。
Styling & Tailwind -> styling.md
样式与Tailwind -> styling.md
- is for layout and scoped exceptions. Do not override component colors or typography with long utility strings when variants or tokens exist.
class - No or
space-x-*in new code. Usespace-y-*orflexwithgrid.gap-* - Use when width and height are equal.
size-*, notsize-10.w-10 h-10 - Use shorthand. Do not spell out
truncate.overflow-hidden text-ellipsis whitespace-nowrap - No manual color overrides for global themes. Change
dark:and:rootvariables in the active Starwind CSS file..dark
- 用于布局与作用域例外情况。当存在变体或令牌时,请勿使用冗长的工具类字符串覆盖组件颜色或排版。
class - 新代码中禁止使用或
space-x-*。使用space-y-*或flex搭配grid。gap-* - 当宽高相等时使用。例如
size-*,而非size-10。w-10 h-10 - 使用简写。请勿完整写出
truncate。overflow-hidden text-ellipsis whitespace-nowrap - 全局主题禁止手动添加颜色覆盖。在活跃的Starwind CSS文件中修改
dark:与:root变量。.dark
Forms & Inputs -> forms.md
表单与输入框 -> forms.md
- Astro forms use semantic markup, Label, controls, and ARIA. Starwind does not use shadcn's React /
FieldGroupAPI.Field - Use , not
for. MatchhtmlForto the controlLabel for.id - Preserve on controls that submit.
name - uses
InputGrouporInputGroupInput. Never put rawInputGroupTextareaorInputinsideTextarea.InputGroup - Buttons inside inputs use and
InputGroupAddon.InputGroupButton - Validation pairs with
aria-invalid. Do not rely on color alone.aria-describedby
- Astro表单使用语义化标记、Label、控件及ARIA。Starwind不使用shadcn的React /
FieldGroupAPI。Field - 使用而非
for。将htmlFor与控件的Label for匹配。id - 保留提交控件的属性。
name - 需搭配
InputGroup或InputGroupInput。切勿在InputGroupTextarea中直接放置原生InputGroup或Input。Textarea - 输入框内的按钮需使用与
InputGroupAddon。InputGroupButton - 验证需将与
aria-invalid配对使用。切勿仅依赖颜色提示。aria-describedby
Component Structure -> composition.md
组件结构 -> composition.md
- Items stay inside groups. ->
SelectItem,SelectGroup->Item,ItemGroup->InputOtpSlot,InputOtpGroup->Kbd.KbdGroup - Use only when the Starwind component documents it. Common triggers support it, but verify from current docs or local exports.
asChild - Dialog, Sheet, and AlertDialog need titles. Use ,
DialogTitle, orSheetTitle;AlertDialogTitleis fine when visually hidden.class="sr-only" - Use full Card composition. ,
CardHeader,CardTitle,CardDescription,CardContent, andCardFooterwhen relevant.CardAction - Button has no /
isPending. Compose loading withisLoading,Spinner, anddisabled.aria-busy - belongs inside
TabsTrigger.TabsList - always needs
Avatar.AvatarFallback
- 子项需置于对应组内。例如->
SelectItem、SelectGroup->Item、ItemGroup->InputOtpSlot、InputOtpGroup->Kbd。KbdGroup - 仅当Starwind组件文档明确说明时使用。常见触发器支持该属性,但需从当前文档或本地导出内容中确认。
asChild - Dialog、Sheet与AlertDialog必须包含标题。使用、
DialogTitle或SheetTitle;若需视觉隐藏,可添加AlertDialogTitle。class="sr-only" - 完整使用Card组合结构。相关场景下需使用、
CardHeader、CardTitle、CardDescription、CardContent及CardFooter。CardAction - Button无/
isPending属性。通过isLoading、Spinner与disabled组合实现加载状态。aria-busy - 必须置于
TabsTrigger内。TabsList - 必须搭配
Avatar。AvatarFallback
Use Components, Not Custom Markup -> composition.md
使用组件而非自定义标记 -> composition.md
- Use existing components before custom markup.
- Callouts use .
Alert - Toast uses Starwind + one
toast, not a custom toast stack.Toaster - Use instead of raw
Separatoror border-only dividers.hr - Use for loading placeholders.
Skeleton - Use for active progress.
Spinner - Use for status labels.
Badge - Combobox is the Select pattern. Install , then use
select; do not runSelectSearch.starwind add combobox
- 优先使用现有组件而非自定义标记。
- 提示框使用。
Alert - Toast使用Starwind + 单个
toast,而非自定义Toast栈。Toaster - 使用替代原生
Separator或仅含边框的分隔器。hr - 使用作为加载占位符。
Skeleton - 使用表示活跃进度。
Spinner - 使用作为状态标签。
Badge - Combobox属于Select模式。安装后使用
select;请勿执行SelectSearch。starwind add combobox
Icons -> icons.md
图标 -> icons.md
- Prefer the project's existing icon system. Do not assume Tabler just because Starwind examples often use .
@tabler/icons - Do not import React icon packages in plain Astro components unless the project uses a React island for that component.
- Icon-only buttons need an accessible name. Use or visible text.
aria-label - Let components size common SVG children unless a specific documented override is needed.
- 优先使用项目现有图标系统。请勿因Starwind示例常使用就默认使用Tabler图标。
@tabler/icons - 纯Astro组件中禁止导入React图标包,除非项目为该组件使用React孤岛。
- 仅含图标的按钮需添加可访问名称。使用或可见文本。
aria-label - 除非需要特定的文档化覆盖,否则让组件自动调整常用SVG子元素的尺寸。
Customization -> customization.md
自定义配置 -> customization.md
- Theme globally through CSS variables first.
- Edit the active Starwind CSS file from ; do not create a second theme file.
starwind.config.json - Preserve ,
@theme inline,:root, sidebar tokens, keyframes, and component-specific variables..dark - Starwind dark mode is class-based through . Do not switch to a data-theme system unless the app already bridges that model.
.dark - For shadcn-style theme migration, merge semantic values into Starwind tokens. See shadcn-migration.md.
- 优先通过CSS变量进行全局主题配置。
- 编辑中指定的活跃Starwind CSS文件;请勿创建第二个主题文件。
starwind.config.json - 保留、
@theme inline、:root、侧边栏令牌、关键帧及组件专属变量。.dark - Starwind暗黑模式基于类实现。除非应用已适配该模型,否则请勿切换至data-theme系统。
.dark - 针对shadcn风格主题迁移,需将语义化值合并到Starwind令牌中。详见shadcn-migration.md。
CLI -> cli.md
CLI -> cli.md
- Only use documented Starwind commands and flags.
- Do not invent shadcn CLI features such as ,
info,view, presets, templates,apply,--dry-run,--diff, or--overwrite.--cwd - overwrites local component changes. Only update when the user asks or accepts overwrite risk.
update - After , read the added files and fix alias drift, icon-library drift, missing imports, and rule violations.
add
- 仅使用文档化的Starwind命令与标志。
- 请勿自创shadcn CLI功能,例如、
info、view、预设、模板、apply、--dry-run、--diff或--overwrite。--cwd - 会覆盖本地组件修改。仅当用户要求或接受覆盖风险时执行更新。
update - 执行后需读取新增文件,修复别名偏移、图标库偏移、缺失导入及规则违反问题。
add
Key Patterns
关键模式
These are common patterns that differentiate correct Starwind UI code.
astro
---
import { Button } from "@/components/starwind/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/starwind/card";
import { Input } from "@/components/starwind/input";
import { Label } from "@/components/starwind/label";
import { Spinner } from "@/components/starwind/spinner";
---
<!-- Astro syntax: class + for, not className + htmlFor -->
<div class="grid gap-2">
<Label for="email">Email</Label>
<Input id="email" name="email" type="email" aria-invalid="false" />
</div>
<!-- Loading button: compose with Spinner, not isLoading/isPending -->
<Button disabled aria-busy="true">
<Spinner />
Saving...
</Button>
<!-- Card composition: header/content parts, not one generic bordered div -->
<Card>
<CardHeader>
<CardTitle>Workspace</CardTitle>
</CardHeader>
<CardContent>Project settings</CardContent>
</Card>以下是区分正确Starwind UI代码的常见模式。
astro
---
import { Button } from "@/components/starwind/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/starwind/card";
import { Input } from "@/components/starwind/input";
import { Label } from "@/components/starwind/label";
import { Spinner } from "@/components/starwind/spinner";
---
<!-- Astro语法:使用class + for,而非className + htmlFor -->
<div class="grid gap-2">
<Label for="email">邮箱</Label>
<Input id="email" name="email" type="email" aria-invalid="false" />
</div>
<!-- 加载按钮:搭配Spinner实现,而非isLoading/isPending属性 -->
<Button disabled aria-busy="true">
<Spinner />
保存中...
</Button>
<!-- Card组合结构:使用头部/内容部件,而非单一通用边框容器 -->
<Card>
<CardHeader>
<CardTitle>工作区</CardTitle>
</CardHeader>
<CardContent>项目设置</CardContent>
</Card>Component Selection
组件选择
| Need | Use |
|---|---|
| Button/action | |
| Form inputs | |
| Searchable select / combobox | |
| Option toggle | |
| Data display | |
| Navigation | |
| Overlays | |
| Menus | |
| Feedback | |
| Media | |
| Layout/disclosure | |
| Theme toggle | |
| 需求 | 使用组件 |
|---|---|
| 按钮/操作 | |
| 表单输入框 | |
| 可搜索选择器/Combobox | |
| 选项切换器 | |
| 数据展示 | |
| 导航 | |
| 浮层 | |
| 菜单 | |
| 反馈 | |
| 媒体 | |
| 布局/折叠面板 | |
| 主题切换器 | |
Key Fields
关键字段
- -> source of
starwind.config.json,starwind.css, base color, and installed component list.componentDir - -> active Starwind CSS file for theme variables. Always edit this file for global theme work.
starwind.css - -> component install root. The Starwind subdirectory is commonly
componentDir.src/components/starwind - -> installed component names when present in config.
components - / lockfiles -> use this for the Starwind runner and dependency installs.
packageManager - -> confirms Astro/Vite/Tailwind setup.
astro.config.* - Local exports -> exact import names for installed component parts.
index.ts - Icon imports in nearby files -> preferred icon package and import style.
- ->
starwind.config.json、starwind.css、基础颜色及已安装组件列表的来源。componentDir - -> 用于主题变量的活跃Starwind CSS文件。全局主题修改需始终编辑此文件。
starwind.css - -> 组件安装根目录。Starwind子目录通常为
componentDir。src/components/starwind - -> 配置中存在的已安装组件名称。
components - / 锁文件 -> 用于Starwind运行器与依赖安装。
packageManager - -> 确认Astro/Vite/Tailwind配置。
astro.config.* - 本地导出内容 -> 已安装组件部件的准确导入名称。
index.ts - 附近文件中的图标导入 -> 首选图标包与导入风格。
Component Docs, Examples, And Usage
组件文档、示例与用法
Use the freshest Starwind context available:
bash
npx starwind@latest docs button dialog select --jsonThen fetch and read the returned docs or Markdown URLs before implementing. When tools are available, prefer Starwind MCP for live docs and for install command generation. Local project source remains the final authority for already-installed components.
starwind_docsstarwind_addWhen creating, fixing, debugging, or using a component, always read the relevant docs or local component source first. Do not guess props, events, or composition from memory.
使用最新的Starwind上下文:
bash
npx starwind@latest docs button dialog select --json在实现前获取并阅读返回的文档或Markdown链接。当工具可用时,优先使用Starwind MCP的获取实时文档,使用生成安装命令。本地项目源代码始终是已安装组件的最终权威依据。
starwind_docsstarwind_add在创建、修复、调试或使用组件时,务必先阅读相关文档或本地组件源代码。请勿凭记忆猜测属性、事件或组合方式。
Workflow
工作流程
- Get project context -> read , lockfiles, Astro config,
package.json, active Starwind CSS, installed component directory, and local exports.starwind.config.json - Check installed components first -> do not import components that have not been added, and do not re-add ones already installed unless the user asked to update.
- Find components -> use Starwind MCP, , docs,
npx starwind@latest search,llms.txt,llms-full.txt, or installed registry metadata.ai-manifest.json - Get docs and examples -> use Starwind MCP or , then fetch the docs content.
npx starwind@latest docs <component> --json - Install missing components -> use with the correct package runner and documented flags.
npx starwind@latest add <component> - Review added files -> read new component/block files before wiring them in. Fix import aliases, icon imports, missing subcomponents, Astro syntax, and Critical Rules violations.
- Compose before editing internals -> use documented props, variants, , semantic tokens, and wrappers before changing installed component source.
class - Keep changes scoped -> preserve project patterns and avoid unrelated refactors.
- 获取项目上下文 -> 读取、锁文件、Astro配置、
package.json、活跃Starwind CSS文件、已安装组件目录及本地导出内容。starwind.config.json - 优先检查已安装组件 -> 请勿导入未添加的组件,除非用户要求更新,否则请勿重新添加已安装的组件。
- 查找组件 -> 使用Starwind MCP、、文档、
npx starwind@latest search、llms.txt、llms-full.txt或已安装的注册表元数据。ai-manifest.json - 获取文档与示例 -> 使用Starwind MCP或,然后获取文档内容。
npx starwind@latest docs <component> --json - 安装缺失组件 -> 使用搭配正确的包运行器与文档化标志。
npx starwind@latest add <component> - 审核新增文件 -> 在接入前阅读新组件/区块文件。修复导入别名、图标导入、缺失子组件、Astro语法及核心规则违反问题。
- 先组合再编辑内部 -> 在修改已安装组件源代码前,优先使用文档化的属性、变体、、语义化令牌及包装器。
class - 保持变更范围可控 -> 保留项目模式,避免无关重构。
Updating Components
更新组件
Starwind components are local source files after installation.
CAUTION:overwrites local component changes.npx starwind@latest update
When the user asks to update a component while preserving local changes:
- Read the local component files and where they are imported.
- Read current docs or source for the target component.
- Decide whether to manually merge the needed upstream changes or ask approval to run .
update - Use only when the user asks for it or accepts overwrite risk.
npx starwind@latest update <component> - Use only when the user explicitly wants every installed component updated.
update --all
Starwind组件安装后为本地源文件。
注意:会覆盖本地组件修改。npx starwind@latest update
当用户要求更新组件同时保留本地修改时:
- 读取本地组件文件及其导入位置。
- 读取目标组件的当前文档或源代码。
- 决定是手动合并所需的上游变更,还是请求用户批准执行。
update - 仅当用户要求或接受覆盖风险时,使用。
npx starwind@latest update <component> - 仅当用户明确要求更新所有已安装组件时,使用。
update --all
Quick Reference
快速参考
bash
undefinedbash
undefinedInitialize Starwind UI
初始化Starwind UI
npx starwind@latest init
npx starwind@latest init --defaults
npx starwind@latest init --pro
npx starwind@latest init
npx starwind@latest init --defaults
npx starwind@latest init --pro
Add components
添加组件
npx starwind@latest add button card dialog
npx starwind@latest add select
npx starwind@latest add theme-toggle
npx starwind@latest add button card dialog
npx starwind@latest add select
npx starwind@latest add theme-toggle
Add all components
添加所有组件
npx starwind@latest add --all
npx starwind@latest add --all
Search components and Pro blocks
搜索组件与Pro区块
npx starwind@latest search select
npx starwind@latest search hero --json
npx starwind@latest search pricing --plan free --category pricing --limit 10 --json
npx starwind@latest search select
npx starwind@latest search hero --json
npx starwind@latest search pricing --plan free --category pricing --limit 10 --json
Get docs references
获取文档参考
npx starwind@latest docs button dialog select --json
npx starwind@latest docs button dialog select --json
Configure Starwind Pro in an existing project
在现有项目中配置Starwind Pro
npx starwind@latest setup
npx starwind@latest setup --yes
npx starwind@latest setup
npx starwind@latest setup --yes
Update or remove components
更新或移除组件
npx starwind@latest update button
npx starwind@latest remove button
undefinednpx starwind@latest update button
npx starwind@latest remove button
undefinedDetailed References
详细参考
- rules/forms.md -> labels, controls, InputGroup, Select, validation
- rules/composition.md -> groups, overlays, Card, Tabs, Avatar, Toast, Separator, Skeleton, Spinner, Badge, Button loading
- rules/icons.md -> Astro icon imports, icon buttons, icon-library drift
- rules/styling.md -> semantic colors, variants, class, spacing, size, truncate, dark mode, z-index
- cli.md -> Starwind commands, flags, Pro setup, and missing shadcn CLI features
- customization.md -> theming, CSS variables, dark mode, extending components
- shadcn-migration.md -> mapping shadcn-style theme tokens to Starwind
- mcp.md -> MCP and AI docs source priority
Load only the references needed for the current task.
- rules/forms.md -> 标签、控件、InputGroup、Select、验证
- rules/composition.md -> 组、浮层、Card、Tabs、Avatar、Toast、Separator、Skeleton、Spinner、Badge、按钮加载状态
- rules/icons.md -> Astro图标导入、图标按钮、图标库偏移
- rules/styling.md -> 语义化颜色、变体、class、间距、尺寸、截断、暗黑模式、z-index
- cli.md -> Starwind命令、标志、Pro配置、缺失的shadcn CLI功能
- customization.md -> 主题配置、CSS变量、暗黑模式、组件扩展
- shadcn-migration.md -> shadcn风格主题令牌到Starwind的映射
- mcp.md -> MCP与AI文档源优先级
仅加载当前任务所需的参考内容。