heroui-react-pro
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHeroUI Pro React Development Guide
HeroUI Pro React开发指南
@heroui-pro/react@heroui/react@heroui-pro/react@heroui/reactSkills Teach, MCP Does
技能教学与MCP工具使用
This skill teaches your agent how to write code correctly. For live data (component docs, CSS files, theme variables), use the HeroUI Pro MCP server ( at ).
@heroui-pro/reactheroui-promcp.heroui.pro| Tool | When to use |
|---|---|
| Discover available |
| Get compound API, anatomy, props, examples before implementing |
| Understand BEM classes, design tokens, theme variants for customization |
| Read installation, theming, styling, composition guides |
Always call first to get the up-to-date component list, then before implementing. The component categories listed in this skill are a reference snapshot — new components are added regularly. The MCP tool always returns the current list. If a component name is not in the MCP response, it does not exist yet. Never guess or hallucinate component names.
list_componentsget_component_docslist_components本内容指导你的Agent如何正确编写 代码。如需获取实时数据(组件文档、CSS文件、主题变量),请使用 HeroUI Pro MCP服务器(地址为 ,标识为 )。
@heroui-pro/reactmcp.heroui.proheroui-pro| 工具名称 | 适用场景 |
|---|---|
| 查看可用的 |
| 在实现前获取复合API、组件结构、属性及示例代码 |
| 了解用于自定义的BEM类、设计令牌和主题变体 |
| 阅读安装、主题配置、样式设计和组件组合指南 |
请始终先调用 获取最新的组件列表,再调用 后进行组件实现。 本内容中列出的组件分类仅为参考快照——新组件会定期添加。MCP的 工具始终返回当前最新列表。如果组件名称未出现在MCP响应中,则表示该组件暂未存在,切勿猜测或虚构组件名称。
list_componentsget_component_docslist_componentsTwo Packages
两个包说明
| Package | What it contains | MCP server |
|---|---|---|
| Base components: Button, Card, Modal, TextField, Tabs, Accordion, etc. | |
| Pro components: charts, forms, navigation, overlays, data display | |
Import from the correct package:
tsx
import {Button, Card, Modal} from "@heroui/react";
import {Sidebar, Command, Sheet, KPI} from "@heroui-pro/react";| 包名称 | 包含内容 | MCP服务器标识 |
|---|---|---|
| 基础组件:Button、Card、Modal、TextField、Tabs、Accordion等 | |
| Pro级组件:图表、表单、导航、浮层、数据展示类组件 | |
请从正确的包中导入组件:
tsx
import {Button, Card, Modal} from "@heroui/react";
import {Sidebar, Command, Sheet, KPI} from "@heroui-pro/react";Critical v3 Rules
v3版本核心规则
- Tailwind CSS v4 required — v3 is NOT supported
- No Provider needed — components work directly without
<HeroUIProvider> - Compound components — use dot notation (,
Sheet.Trigger,Sheet.Content)Card.Header - not
onPress— for accessibilityonClick - Import order matters — Tailwind CSS before HeroUI styles in CSS
css
@import "tailwindcss";
@import "@heroui/styles";- 必须使用Tailwind CSS v4 —— 不支持v3版本
- 无需Provider —— 组件无需 即可直接使用
<HeroUIProvider> - 复合组件 —— 使用点标记法(如 、
Sheet.Trigger、Sheet.Content)Card.Header - 使用而非
onPress—— 为了无障碍访问onClick - 导入顺序重要 —— CSS文件中需先导入Tailwind CSS,再导入HeroUI样式
css
@import "tailwindcss";
@import "@heroui/styles";Component Categories
组件分类
This list is a snapshot for reference. Always callvia the MCP to get the current list — new components and blocks are added regularly.list_components
本列表为参考快照。请始终通过MCP调用获取最新列表——新组件和模块会定期添加。list_components
Charts
图表类
AreaChart, BarChart, LineChart, PieChart, RadarChart, RadialChart, ComposedChart, ChartTooltip
AreaChart、BarChart、LineChart、PieChart、RadarChart、RadialChart、ComposedChart、ChartTooltip
Data Display
数据展示类
KPI, KPIGroup, TrendChip, NumberValue, Rating, EmptyState
KPI、KPIGroup、TrendChip、NumberValue、Rating、EmptyState
Forms
表单类
CellSelect, CellSwitch, CellSlider, CellColorPicker, InlineSelect, NativeSelect, NumberStepper, CheckboxButtonGroup, RadioButtonGroup
CellSelect、CellSwitch、CellSlider、CellColorPicker、InlineSelect、NativeSelect、NumberStepper、CheckboxButtonGroup、RadioButtonGroup
Navigation
导航类
Sidebar, FloatingToc, Stepper, Segment
Sidebar、FloatingToc、Stepper、Segment
Overlays
浮层类
Command, ContextMenu, HoverCard, Sheet
Command、ContextMenu、HoverCard、Sheet
Feedback
反馈类
PressableFeedback, DropZone, EmojiPicker, EmojiReactionButton
PressableFeedback、DropZone、EmojiPicker、EmojiReactionButton
Layout
布局类
FileTree, Kanban, ItemCard, ItemCardGroup
FileTree、Kanban、ItemCard、ItemCardGroup
Key Rules
关键规则
- Import from for base components,
"@heroui/react"for Pro"@heroui-pro/react" - Subcomponents via dot notation: ,
Card.Header,Sheet.ContentSidebar.Header - Use not
onPressfor ButtononClick - does NOT exist — use
DividerSeparator - /
CardHeader/CardContentas direct imports do NOT exist — useCardFooteretc.Card.Header - Icons: with the gravity-ui icon set
import { Icon } from "@iconify/react"
- 基础组件从 导入,Pro级组件从
"@heroui/react"导入"@heroui-pro/react" - 子组件通过点标记法调用:、
Card.Header、Sheet.ContentSidebar.Header - Button组件使用而非
onPressonClick - 不存在组件——请使用
DividerSeparator - 不可直接导入/
CardHeader/CardContent——请使用CardFooter等点标记法形式Card.Header - 图标:通过导入gravity-ui图标集
import { Icon } from "@iconify/react"
Semantic Variants
语义化变体
- Button: (default),
variant="primary","secondary","tertiary","outline","ghost","danger""danger-soft" - Sizes: ,
size="sm"(default),"md""lg" - States: ,
isDisabled,isPending,isIconOnlyfullWidth
- Button:(默认)、
variant="primary"、"secondary"、"tertiary"、"outline"、"ghost"、"danger""danger-soft" - 尺寸:、
size="sm"(默认)、"md""lg" - 状态:、
isDisabled、isPending、isIconOnlyfullWidth
Switch Component (v3 anatomy)
Switch组件(v3结构)
Always use the dot notation anatomy:
tsx
import { Switch, Label } from "@heroui/react";
<Switch defaultSelected aria-label="Auto-Lock Doors">
<Switch.Control>
<Switch.Thumb />
</Switch.Control>
</Switch>
<Switch>
<Switch.Control>
<Switch.Thumb />
</Switch.Control>
<Switch.Content>
<Label className="text-sm">Enable notifications</Label>
</Switch.Content>
</Switch>请始终使用点标记法结构:
tsx
import { Switch, Label } from "@heroui/react";
<Switch defaultSelected aria-label="Auto-Lock Doors">
<Switch.Control>
<Switch.Thumb />
</Switch.Control>
</Switch>
<Switch>
<Switch.Control>
<Switch.Thumb />
</Switch.Control>
<Switch.Content>
<Label className="text-sm">Enable notifications</Label>
</Switch.Content>
</Switch>Design Tokens
设计令牌
- Backgrounds: ,
bg-background,bg-surface,bg-surface-secondarybg-overlay - Text: ,
text-foregroundtext-muted - Brand: ,
bg-accenttext-accent-foreground - Status: ,
text-success,text-warning(each withtext-danger)-foreground - Borders: ,
border-borderborder-separator - Shadows: ,
shadow-surfaceshadow-overlay - All colors use oklch color space via CSS variables
- No numbered tokens (,
default-100) — these are v2 and do NOT existprimary-500
- 背景色:、
bg-background、bg-surface、bg-surface-secondarybg-overlay - 文字色:、
text-foregroundtext-muted - 品牌色:、
bg-accenttext-accent-foreground - 状态色:、
text-success、text-warning(均对应text-danger变体)-foreground - 边框色:、
border-borderborder-separator - 阴影:、
shadow-surfaceshadow-overlay - 所有颜色通过CSS变量使用oklch色彩空间
- 无编号令牌(如、
default-100)——这些属于v2版本,已不再使用primary-500
CSS System
CSS系统
The MCP tool exposes the full shipped CSS from :
get_css@heroui-pro/react- Base variables — design tokens for colors, spacing, radius, shadows
- Component styles — BEM classes with state selectors and modifiers
- Theme variants (e.g. brutalism) — variables, fonts, and component overrides
get_css() → overview of tokens + available styles/themes
get_css({ components: ["sheet", "sidebar"] }) → BEM CSS for those components
get_css({ theme: "brutalism" }) → full theme variant CSSMCP工具 可获取的完整内置CSS:
get_css@heroui-pro/react- 基础变量 —— 颜色、间距、圆角、阴影的设计令牌
- 组件样式 —— 包含状态选择器和修饰符的BEM类
- 主题变体(如brutalism)—— 变量、字体和组件重写规则
get_css() → 令牌概述 + 可用样式/主题
get_css({ components: ["sheet", "sidebar"] }) → 指定组件的BEM CSS代码
get_css({ theme: "brutalism" }) → 完整主题变体CSS代码Components That DONT EXIST — NEVER Use
不存在的组件——切勿使用
Divider (use Separator), SelectItem, Progress (use ProgressBar), CardHeader/CardContent/CardFooter as direct imports — use dot notation //
Card.HeaderCard.ContentCard.FooterDivider(请用Separator)、SelectItem、Progress(请用ProgressBar)、直接导入的CardHeader/CardContent/CardFooter——请使用点标记法//
Card.HeaderCard.ContentCard.FooterPast Corrections (ALWAYS follow these)
过往修正规则(请严格遵守)
- Switch must use dot notation anatomy (); never the old
Switch.Control > Switch.Thumb<Switch>Label</Switch> - Never apply to Card — Card already includes
shadow-overlayby defaultshadow-surface - Wrap Dropdown triggers in a ghost-variant Button ()
variant='ghost' - Use (not
variant='outline') for outlined button styles'outlined' - Use as a single prop for destructive buttons (not
variant='danger-soft')color='danger' variant='soft' - Use HeroUI's built-in components (ColorSwatchPicker, DatePicker, Calendar, CircularProgress) over custom implementations
- Use with
ScrollShadowandoverflow-y-autofor scrollable listsmax-h - Apply to match HeroUI's default border-radius convention
rounded-2xl - Use class on breadcrumb links
no-underline
- Switch组件必须使用点标记法结构();切勿使用旧版
Switch.Control > Switch.Thumb写法<Switch>Label</Switch> - 切勿为Card组件添加——Card默认已包含
shadow-overlayshadow-surface - 请将Dropdown触发器包裹在ghost变体的Button中()
variant='ghost' - 按钮轮廓样式使用(而非
variant='outline')'outlined' - 破坏性按钮使用单一属性(而非
variant='danger-soft')color='danger' variant='soft' - 使用HeroUI内置组件(ColorSwatchPicker、DatePicker、Calendar、CircularProgress)而非自定义实现
- 为可滚动列表添加,并配合
ScrollShadow和overflow-y-auto使用max-h - 应用以匹配HeroUI默认圆角规范
rounded-2xl - 为面包屑链接添加类
no-underline