@coderabbitai/carrot-ui

中文文档
0.31.0发布于 2026/08/11UNLICENSEDTypeScriptES Module近 30 天下载 5649

CodeRabbit design system. React components built on Base UI, styled with Tailwind CSS v4.

原始使用文档
文档目录9 节
  1. Installation
  2. 1. Install
  3. 2. Configure CSS
  4. 3. Set up Vite
  5. 4. Dark mode
  6. Usage
  7. Documentation
  8. Development
  9. Publishing

Carrot UI

React component library for CodeRabbit. Built on Base UI, styled with Tailwind CSS v4, themed with an OKLCH color system.

Installation

1. Install

pnpm add @coderabbitai/carrot-ui

Peer dependencies:

pnpm add react react-dom tailwindcss @tailwindcss/vite

2. Configure CSS

In your CSS entry point (e.g. index.css):

@import "tailwindcss";
@import "@coderabbitai/carrot-ui/css";

This imports the theme tokens, color scales, dark mode variant, and tells Tailwind to scan the library for utility classes.

3. Set up Vite

Add the Tailwind CSS Vite plugin:

import tailwindcss from "@tailwindcss/vite"

export default defineConfig({
    plugins: [tailwindcss(), react()],
})

4. Dark mode

Carrot UI uses data-theme="dark" for dark mode. It must be set on the <html> element so CSS variable overrides resolve correctly at :root:

<html data-theme="dark">
    ...
</html>

In React, set it on document.documentElement:

document.documentElement.setAttribute("data-theme", "dark")

Usage

import { Button, Badge, Avatar } from "@coderabbitai/carrot-ui"

function App() {
    return (
        <div className="bg-cui-base-1 text-cui-primary min-h-screen p-8">
            <Button>Click me</Button>
            <Badge variant="accent">New</Badge>
            <Avatar seed="[email protected]" />
        </div>
    )
}

Provider brand icons are also available from the package root:

import { SlackIcon } from "@coderabbitai/carrot-ui"

function SlackLink() {
    return <SlackIcon className="size-4" title="Slack" />
}

Documentation

Run pnpm dev and visit /reference for the full component playground. Foundations:

  • Colors (/reference/foundations/colors) — OKLCH scales and semantic tokens
  • Spacing (/reference/foundations/spacing) — spacing scale
  • Principles (/reference/foundations/principles) — the cross-cutting design and API conventions every component follows. Source: principles.mdx — readable directly on GitHub.

If you're authoring a new component, start with Principles — it's the source of truth for the visual and API conventions.

Development

pnpm install
pnpm dev          # playground dev server
pnpm build        # library build (dist/)
pnpm typecheck    # type checking
pnpm lint         # linting

Publishing

Release Please opens release PRs from changes on main. Use conventional commit prefixes such as fix: and feat: so Release Please can choose the next version. Merge the Release Please PR to bump package.json, update CHANGELOG.md, create the v* tag, and publish the package.

The publish workflow checks that the v* tag matches package.json, publishes to GitHub Packages and the public npm registry, then uploads the packed tarball to the GitHub release. Manual v* tags still work, but the tag version must match package.json.

Required GitHub Actions secrets:

  • CODERABBIT_NPM_TOKEN: npm publish token for the public npm registry.
  • GITHUB_TOKEN: built-in GitHub Actions token used for GitHub Packages, release PRs, tags, and release assets.
  • RELEASE_PLEASE_TOKEN: optional GitHub token for Release Please. Use this if Release Please PRs need normal CI checks to run.

Configure repository secrets in GitHub under Settings → Secrets and variables → Actions.

版本与发布记录

@coderabbitai/carrot-ui 共发布 35 个版本,首次发布于 2026/05/13;过去 12 个月发布了 35 个版本。

版本发布日期距今
0.31.0latest2026/08/112 个月前
0.30.02026/08/043 个月前
0.29.02026/07/253 个月前
0.28.02026/07/243 个月前
0.27.02026/07/183 个月前
0.26.02026/07/163 个月前

关于 @coderabbitai/carrot-ui 的常见问题

@coderabbitai/carrot-ui 是什么?

CodeRabbit design system. React components built on Base UI, styled with Tailwind CSS v4.

如何安装 @coderabbitai/carrot-ui?

在项目目录运行 npm install @coderabbitai/carrot-ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.3.1 || ^19.0.0)、react-dom(^18.3.1 || ^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@coderabbitai/carrot-ui 支持 TypeScript 吗?

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

@coderabbitai/carrot-ui 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@coderabbitai/carrot-ui 可以商用吗?

@coderabbitai/carrot-ui 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@coderabbitai/carrot-ui 的下载量有多少?

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

@coderabbitai/carrot-ui 还在维护吗?

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