Loading...
Loading...
Compare original and translation side by side
| Feature | v2 (DO NOT USE) | v3 (USE THIS) |
|---|---|---|
| Provider | | No Provider needed |
| Animations | | CSS-based, no extra deps |
| Component API | Flat props: | Compound: |
| Styling | Tailwind v3 + | Tailwind v4 + |
| Packages | | |
| 特性 | v2(请勿使用) | v3(请使用此版本) |
|---|---|---|
| 提供器 | 需要 | 无需提供器 |
| 动画效果 | | 基于CSS实现,无需额外依赖 |
| 组件API | 扁平属性: | 复合组件: |
| 样式方案 | Tailwind v3 + | Tailwind v4 + |
| 包 | | |
// 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 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@beta";
<Card>
<Card.Header>
<Card.Title>Product</Card.Title>
<Card.Description>A great product</Card.Description>
</Card.Header>
</Card>;// DO THIS - v3 pattern (no provider, compound components)
import { Card } from "@heroui/react@beta";
<Card>
<Card.Header>
<Card.Title>Product</Card.Title>
<Card.Description>A great product</Card.Description>
</Card.Header>
</Card>;primarysecondarytertiaryoklchprimarysecondarytertiaryoklchundefinedundefinedundefinedundefinedhttps://v3.heroui.com/docs/react/components/{component-name}.mdxhttps://v3.heroui.com/docs/react/components/button.mdxhttps://v3.heroui.com/docs/react/components/modal.mdxhttps://v3.heroui.com/docs/react/components/form.mdxhttps://v3.heroui.com/docs/react/getting-started/{topic}.mdxhttps://v3.heroui.com/docs/react/components/{component-name}.mdxhttps://v3.heroui.com/docs/react/components/button.mdxhttps://v3.heroui.com/docs/react/components/modal.mdxhttps://v3.heroui.com/docs/react/components/form.mdxhttps://v3.heroui.com/docs/react/getting-started/{topic}.mdx@beta@betanpm i @heroui/styles@beta @heroui/react@beta tailwind-variantsnpm i @heroui/styles@beta @heroui/react@beta tailwind-variantsnpm i @heroui/styles@beta @heroui/react@beta tailwind-variants tailwindcss @tailwindcss/postcss postcssapp/globals.css/* Tailwind CSS v4 - Must be first */
@import "tailwindcss";
/* HeroUI v3 styles - Must be after Tailwind */
@import "@heroui/styles";app/layout.tsximport "./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>
);
}postcss.config.mjsexport default {
plugins: {
"@tailwindcss/postcss": {},
},
};npm i @heroui/styles@beta @heroui/react@beta tailwind-variants tailwindcss @tailwindcss/postcss postcssapp/globals.css/* Tailwind CSS v4 - Must be first */
@import "tailwindcss";
/* HeroUI v3 styles - Must be after Tailwind */
@import "@heroui/styles";app/layout.tsximport "./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>
);
}postcss.config.mjsexport default {
plugins: {
"@tailwindcss/postcss": {},
},
};Card.HeaderCard.ContentonPressCard.HeaderCard.ContentonPress<Card>
<Card.Header>
<Card.Title>Title</Card.Title>
<Card.Description>Description</Card.Description>
</Card.Header>
<Card.Content>{/* Content */}</Card.Content>
<Card.Footer>{/* Actions */}</Card.Footer>
</Card>Card.Header<Card>
<Card.Header>
<Card.Title>Title</Card.Title>
<Card.Description>Description</Card.Description>
</Card.Header>
<Card.Content>{/* Content */}</Card.Content>
<Card.Footer>{/* Actions */}</Card.Footer>
</Card>Card.Header| Variant | Purpose | Usage |
|---|---|---|
| Main action to move forward | 1 per context |
| Alternative actions | Multiple |
| Dismissive actions (cancel, skip) | Sparingly |
| Destructive actions | When needed |
| Low-emphasis actions | Minimal weight |
| Secondary actions | Bordered style |
| 变体 | 用途 | 使用场景 |
|---|---|---|
| 推进流程的主要操作 | 每个场景1个 |
| 替代操作 | 可多个使用 |
| 取消类操作(取消、跳过) | 谨慎使用 |
| 破坏性操作 | 必要时使用 |
| 低强调操作 | 轻量化样式 |
| 次要操作 | 边框样式 |
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://v3.heroui.com/docs/react/getting-started/theming.mdxoklch: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://v3.heroui.com/docs/react/getting-started/theming.mdx