@chakra-ui/panda-preset

中文文档
3.38.0发布于 2026/11/03MITTypeScriptESM + CJS近 30 天下载 2573

Panda preset for Chakra UI

原始使用文档
文档目录5 节
  1. Installation
  2. Configure Panda
  3. Color mode (light / dark)
  4. Next.js and next-themes
  5. Related

@chakra-ui/panda-preset

Panda CSS preset that mirrors the Chakra UI default theme (tokens, semantic colors, recipes, slot recipes, and global styles) so you can build with Panda while keeping Chakra-aligned design tokens.

Installation

pnpm add @chakra-ui/panda-preset
# or
npm install @chakra-ui/panda-preset

Peer expectations: @pandacss/dev (and your app’s React/Vite/Next setup as usual for Panda).

Configure Panda

panda.config.ts (or .js):

import { defineConfig } from "@pandacss/dev"

export default defineConfig({
  presets: ["@chakra-ui/panda-preset"],
  preflight: true,
  include: ["./src/**/*.{js,jsx,ts,tsx}"],
  outdir: "styled-system", // default; change if you prefer another folder
})

Then generate the runtime:

pnpm exec panda codegen

In your app, import the CSS layers Panda emits (for example the generated styled-system/styles.css or your own entry that matches Panda’s layer setup) and use css(), recipes, and patterns from your outdir like any other Panda project.

Color mode (light / dark)

Semantic tokens in this preset use _light and _dark (e.g. colors, shadows). For those values to apply correctly, the document root should carry a class that selects the active color mode:

  • Set class="light" or class="dark" on <html> (or another wrapping element your setup uses).

Example:

<html class="light">
  <!-- ... -->
</html>

Without one of these classes, light/dark–dependent tokens may not resolve the way you expect.

Next.js and next-themes

With next-themes, use attribute="class" so the active theme is reflected as light / dark on <html>, matching Panda’s _light / _dark semantic tokens. defaultTheme / enableSystem are up to your product defaults.

// e.g. app/providers.tsx — mark as a Client Component in the App Router
"use client"

import { ThemeProvider } from "next-themes"

export function Providers({ children }: { children: React.ReactNode }) {
  return (
    <ThemeProvider attribute="class" defaultTheme="system" enableSystem>
      {children}
    </ThemeProvider>
  )
}
// e.g. app/layout.tsx — wrap the app; suppressHydrationWarning avoids a class mismatch warning on <html>
import { Providers } from "./providers"

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html lang="en" suppressHydrationWarning>
      <body>
        <Providers>{children}</Providers>
      </body>
    </html>
  )
}

Install: pnpm add next-themes.

版本与发布记录

@chakra-ui/panda-preset 共发布 54 个版本,首次发布于 2025/01/10;过去 12 个月发布了 10 个版本。

版本发布日期距今
3.38.0latest2026/11/035 天前
3.37.02026/08/282 个月前
3.36.12026/07/193 个月前
3.36.02026/06/104 个月前
3.35.02026/04/236 个月前
3.34.02026/03/038 个月前

关于 @chakra-ui/panda-preset 的常见问题

@chakra-ui/panda-preset 是什么?

Panda preset for Chakra UI

如何安装 @chakra-ui/panda-preset?

在项目目录运行 npm install @chakra-ui/panda-preset,或使用 pnpm add / yarn add / bun add。

@chakra-ui/panda-preset 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@chakra-ui/panda-preset 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@chakra-ui/panda-preset 可以商用吗?

@chakra-ui/panda-preset 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@chakra-ui/panda-preset 的下载量有多少?

根据 npm 官方下载统计,@chakra-ui/panda-preset 在 2026/10/10 – 2026/11/08 这 30 天内被下载 2,573 次,日均约 86 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@chakra-ui/panda-preset 还在维护吗?

最新版本 3.38.0 发布于 2026/11/03(5 天前);至今共发布 54 个版本,其中过去 12 个月发布了 10 个;首次发布于 2025/01/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。