heroui-react by heroui-inc/heroui
npx skills add https://github.com/heroui-inc/heroui --skill heroui-reactHeroUI v3 是一个基于 Tailwind CSS v4 和 React Aria Components 构建的组件库,为 React 应用程序提供无障碍、可定制的 UI 组件。
curl -fsSL https://heroui.com/install | bash -s heroui-react
本指南仅适用于 HeroUI v3。 请勿应用 v2 的模式——提供者、样式和组件 API 均已更改:
| 功能 | v2 (请勿使用) | v3 (请使用此版本) |
|---|---|---|
| 提供者 | 需要 <HeroUIProvider> | 无需提供者 |
| 动画 | framer-motion 包 | 基于 CSS,无需额外依赖 |
| 组件 API |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
扁平属性:<Card title="x"> |
复合式:<Card><Card.Header> |
| 样式 | Tailwind v3 + @heroui/theme | Tailwind v4 + @heroui/styles |
| 包 | @heroui/system, @heroui/theme | @heroui/react, @heroui/styles |
// 请勿这样做 - v2 模式
import { HeroUIProvider } from "@heroui/react";
import { motion } from "framer-motion";
<HeroUIProvider>
<Card title="Product" description="A great product" />
</HeroUIProvider>;
// 请这样做 - v3 模式 (无需提供者,复合组件)
import { Card } from "@heroui/react";
<Card>
<Card.Header>
<Card.Title>Product</Card.Title>
<Card.Description>A great product</Card.Description>
</Card.Header>
</Card>;
在实现之前,请务必获取 v3 的文档。
primary, secondary, tertiary) 优先于视觉描述oklch 色彩空间关于组件详情、示例、属性和实现模式,请务必获取文档:
# 列出所有可用组件
node scripts/list_components.mjs
# 获取组件文档 (MDX)
node scripts/get_component_docs.mjs Button
node scripts/get_component_docs.mjs Button Card TextField
# 获取组件源代码
node scripts/get_source.mjs Button
# 获取组件 CSS 样式 (BEM 类)
node scripts/get_styles.mjs Button
# 获取主题变量
node scripts/get_theme.mjs
# 获取非组件文档 (指南、发布说明)
node scripts/get_docs.mjs /docs/react/getting-started/theming
组件文档:https://heroui.com/docs/react/components/{component-name}.mdx
示例:
https://heroui.com/docs/react/components/button.mdxhttps://heroui.com/docs/react/components/modal.mdxhttps://heroui.com/docs/react/components/form.mdx入门指南:https://heroui.com/docs/react/getting-started/{topic}.mdx
重要提示: 在实现之前,请务必获取组件文档。MDX 文档包含完整的示例、属性、结构剖析和 API 参考。
npm i @heroui/styles @heroui/react tailwind-variants
npm i @heroui/styles @heroui/react tailwind-variants tailwindcss @tailwindcss/postcss postcss
app/globals.css:/* Tailwind CSS v4 - 必须放在首位 */
@import "tailwindcss";
/* HeroUI v3 样式 - 必须在 Tailwind 之后 */
@import "@heroui/styles";
3. 在 app/layout.tsx 中导入:
import "./globals.css";
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en" suppressHydrationWarning>
<body>
{/* HeroUI v3 无需提供者! */}
{children}
</body>
</html>
);
}
4. 配置 PostCSS (postcss.config.mjs):
export default {
plugins: {
"@tailwindcss/postcss": {},
},
};
Card.Header, Card.Content)onPress 事件处理器所有组件都使用上述的复合模式(点符号子组件,如 Card.Header, Card.Content)。不要扁平化为属性——始终使用子组件进行组合。请获取组件文档以了解完整的结构剖析和示例。
HeroUI 使用语义化命名来传达功能意图:
| 变体 | 目的 | 用法 |
|---|---|---|
primary | 向前推进的主要操作 | 每个上下文 1 个 |
secondary | 替代操作 | 多个 |
tertiary | 取消性操作 (取消、跳过) | 谨慎使用 |
danger | 破坏性操作 | 需要时使用 |
ghost | 低强调度操作 | 最小权重 |
outline | 次要操作 | 边框样式 |
不要使用原始颜色 - 语义化变体会根据主题和无障碍性进行适配。
HeroUI v3 使用 CSS 变量和 oklch 色彩空间:
:root {
--accent: oklch(0.6204 0.195 253.83);
--accent-foreground: var(--snow);
--background: oklch(0.9702 0 0);
--foreground: var(--eclipse);
}
获取当前主题变量:
node scripts/get_theme.mjs
颜色命名规则:
--accent)-foreground = 文本颜色 (例如,--accent-foreground)主题切换:
<html class="dark" data-theme="dark"></html>
关于详细主题设置,请获取:https://heroui.com/docs/react/getting-started/theming.mdx
每周安装量
2.2K
代码仓库
GitHub 星标数
28.6K
首次出现
2026 年 1 月 27 日
安全审计
已安装于
codex1.9K
opencode1.9K
github-copilot1.9K
gemini-cli1.9K
cursor1.8K
amp1.8K
HeroUI v3 is a component library built on Tailwind CSS v4 and React Aria Components , providing accessible, customizable UI components for React applications.
curl -fsSL https://heroui.com/install | bash -s heroui-react
This guide is for HeroUI v3 ONLY. Do NOT apply v2 patterns — the provider, styling, and component API all changed:
| Feature | v2 (DO NOT USE) | v3 (USE THIS) |
|---|---|---|
| Provider | <HeroUIProvider> required | No Provider needed |
| Animations | framer-motion package | CSS-based, no extra deps |
| Component API | Flat props: <Card title="x"> | Compound: <Card><Card.Header> |
| Styling | Tailwind v3 + @heroui/theme | Tailwind v4 + @heroui/styles |
| Packages | @heroui/system, @heroui/theme | @heroui/react, @heroui/styles |
// DO NOT DO THIS - v2 pattern
import { HeroUIProvider } from "@heroui/react";
import { motion } from "framer-motion";
<HeroUIProvider>
<Card title="Product" description="A great product" />
</HeroUIProvider>;
// DO THIS - v3 pattern (no provider, compound components)
import { Card } from "@heroui/react";
<Card>
<Card.Header>
<Card.Title>Product</Card.Title>
<Card.Description>A great product</Card.Description>
</Card.Header>
</Card>;
Always fetch v3 docs before implementing.
primary, secondary, tertiary) over visual descriptionsoklch color spaceFor component details, examples, props, and implementation patterns, always fetch documentation:
# List all available components
node scripts/list_components.mjs
# Get component documentation (MDX)
node scripts/get_component_docs.mjs Button
node scripts/get_component_docs.mjs Button Card TextField
# Get component source code
node scripts/get_source.mjs Button
# Get component CSS styles (BEM classes)
node scripts/get_styles.mjs Button
# Get theme variables
node scripts/get_theme.mjs
# Get non-component docs (guides, releases)
node scripts/get_docs.mjs /docs/react/getting-started/theming
Component docs: https://heroui.com/docs/react/components/{component-name}.mdx
Examples:
https://heroui.com/docs/react/components/button.mdxhttps://heroui.com/docs/react/components/modal.mdxhttps://heroui.com/docs/react/components/form.mdxGetting started guides: https://heroui.com/docs/react/getting-started/{topic}.mdx
Important: Always fetch component docs before implementing. The MDX docs include complete examples, props, anatomy, and API references.
npm i @heroui/styles @heroui/react tailwind-variants
npm i @heroui/styles @heroui/react tailwind-variants tailwindcss @tailwindcss/postcss postcss
app/globals.css:/* Tailwind CSS v4 - Must be first */
@import "tailwindcss";
/* HeroUI v3 styles - Must be after Tailwind */
@import "@heroui/styles";
3. Import inapp/layout.tsx:
import "./globals.css";
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en" suppressHydrationWarning>
<body>
{/* No Provider needed in HeroUI v3! */}
{children}
</body>
</html>
);
}
4. Configure PostCSS (postcss.config.mjs):
export default {
plugins: {
"@tailwindcss/postcss": {},
},
};
Card.Header, Card.Content)onPress event handlersAll components use the compound pattern shown above (dot-notation subcomponents like Card.Header, Card.Content). Don't flatten to props — always compose with subcomponents. Fetch component docs for complete anatomy and examples.
HeroUI uses semantic naming to communicate functional intent:
| Variant | Purpose | Usage |
|---|---|---|
primary | Main action to move forward | 1 per context |
secondary | Alternative actions | Multiple |
tertiary | Dismissive actions (cancel, skip) | Sparingly |
danger | Destructive actions | When needed |
ghost | Low-emphasis actions | Minimal weight |
Don't use raw colors - semantic variants adapt to themes and accessibility.
HeroUI v3 uses CSS variables with oklch color space:
:root {
--accent: oklch(0.6204 0.195 253.83);
--accent-foreground: var(--snow);
--background: oklch(0.9702 0 0);
--foreground: var(--eclipse);
}
Get current theme variables:
node scripts/get_theme.mjs
Color naming:
--accent)-foreground = text color (e.g., --accent-foreground)Theme switching:
<html class="dark" data-theme="dark"></html>
For detailed theming, fetch: https://heroui.com/docs/react/getting-started/theming.mdx
Weekly Installs
2.2K
Repository
GitHub Stars
28.6K
First Seen
Jan 27, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
codex1.9K
opencode1.9K
github-copilot1.9K
gemini-cli1.9K
cursor1.8K
amp1.8K
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装
outline | Secondary actions | Bordered style |