@codapet/design-system

中文文档
0.9.2发布于 2026/11/03TypeScriptES Module构建来源已验证近 30 天下载 4399

A comprehensive React component library built with Shadcn UI, Radix UI, Tailwind CSS, and TypeScript.

原始使用文档
文档目录26 节
  1. Features
  2. Installation
  3. As an NPM Package
  4. Peer Dependencies
  5. Quickstart: Next.js 15 + Tailwind v4
  6. Tailwind v3 (legacy)
  7. Usage
  8. Basic Setup
  9. Available Components
  10. Utilities
  11. Hooks
  12. Development
  13. Prerequisites
  14. Setup
  15. Development Commands
  16. Building for Distribution
  17. Publishing
  18. Styling
  19. Tailwind v4 (recommended)
  20. Tailwind v3
  21. Troubleshooting
  22. Dependency Management
  23. Key Points:
  24. Using with AI coding agents
  25. Contributing
  26. License

CodaPet Design System

A comprehensive React component library built with Shadcn UI, Radix UI, Tailwind CSS, and TypeScript.

Features

  • 🎨 50+ accessible UI components
  • 🎯 Built with Radix UI primitives
  • 🎨 Tailwind CSS styling
  • 📱 Mobile-first responsive design
  • 🔧 TypeScript support
  • ⚡️ Optimized for performance
  • 🎭 Dark mode support
  • ♿️ WCAG compliant

Installation

As an NPM Package

npm install @codapet/design-system

Peer Dependencies

The library requires React and React DOM as peer dependencies. Make sure you have them installed:

npm install react react-dom

Note for CI/builders (e.g., Vercel, GitHub Actions): since this package is public on npm, no extra auth or .npmrc is required. Just run your normal install command.

Note: The library supports React 18.0.0 and above. For best compatibility, use React 18.2.0 or later.


Quickstart: Next.js 15 + Tailwind v4

Follow these steps to integrate the design system in a brand-new Next.js app.

  1. Create a Next.js app (TypeScript recommended):
npx create-next-app@latest my-app
cd my-app
  1. Add Tailwind v4 PostCSS plugin (required for Tailwind v4):
npm install -D @tailwindcss/postcss

Create postcss.config.mjs (if you don't have one):

/** @type {import('postcss-load-config').Config} */
const config = {
  plugins: {
    '@tailwindcss/postcss': {},
  },
}
export default config
  1. Install the design system:
npm install @codapet/design-system
  1. Configure global CSS for Tailwind v4 scanning and import the design system styles.

Edit app/globals.css:

@import "tailwindcss";

/* Tell Tailwind where to scan for class usage */
@source "../**/*.{js,ts,jsx,tsx,mdx}";
@source "../../node_modules/@codapet/design-system/dist/**/*.{js,mjs,ts,tsx}";

/* Import the design system tokens and base styles (after Tailwind) */
@import "@codapet/design-system/styles";
  1. Ensure your Next.js root layout includes the globals:
// app/layout.tsx
import type { Metadata } from 'next'
import './globals.css'

export const metadata: Metadata = { title: 'My App' }

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>{children}</body>
    </html>
  )
}
  1. Use components:
// app/page.tsx
import { Button, Card, CardContent, CardHeader, CardTitle } from '@codapet/design-system'

export default function Page() {
  return (
    <main className="p-8">
      <Card>
        <CardHeader>
          <CardTitle>Hello</CardTitle>
        </CardHeader>
        <CardContent>
          <Button>Works!</Button>
        </CardContent>
      </Card>
    </main>
  )
}
  1. Run the app:
npm run dev

Tailwind v3 (legacy)

If you are on Tailwind v3, use a config-based content scan instead of @source (see below in Styling).


Usage

Basic Setup

import { Button, Card, Input } from '@codapet/design-system'

function App() {
  return (
    <div>
      <Card>
        <Input placeholder="Enter your name" />
        <Button>Click me</Button>
      </Card>
    </div>
  )
}

Available Components

The library exports all UI components from the components/ui directory:

import {
  Accordion,
  Alert,
  AlertDialog,
  AspectRatio,
  Avatar,
  Badge,
  Breadcrumb,
  Button,
  Calendar,
  Card,
  Carousel,
  Chart,
  Checkbox,
  Collapsible,
  Command,
  ContextMenu,
  Dialog,
  Drawer,
  DropdownMenu,
  Form,
  HoverCard,
  Input,
  InputOTP,
  Label,
  Menubar,
  NavigationMenu,
  Pagination,
  Popover,
  Progress,
  RadioGroup,
  Resizable,
  ScrollArea,
  Select,
  Separator,
  Sheet,
  Sidebar,
  Skeleton,
  Slider,
  Sonner,
  Switch,
  Table,
  Tabs,
  Textarea,
  Toggle,
  ToggleGroup,
  Tooltip,
} from '@codapet/design-system'

Utilities

import { cn } from '@codapet/design-system'

// Utility function for merging class names
const className = cn('base-class', 'conditional-class')

Hooks

import { useIsMobile } from '@codapet/design-system'

function MyComponent() {
  const isMobile = useIsMobile()
  // ...
}

Development

Prerequisites

  • Node.js 18+
  • npm or yarn

Setup

  1. Clone the repository
  2. Install dependencies:
    npm install
    

Development Commands

  • npm run dev - Start the development server
  • npm run build:lib - Build the library for distribution
  • npm run build:all - Build both the library and the demo app
  • npm run lint - Run ESLint
  • npm run test:lib - Test the library build
  • npm run check:deps - Check dependency tree
  • npm run clean:deps - Clean and reinstall dependencies

Building for Distribution

To build the library as an npm package:

npm run build:lib

This will generate:

  • dist/index.mjs - ES Module bundle
  • dist/index.d.mts - TypeScript declarations

Publishing

Releases are automated via GitHub Actions on semver tags.

Setup once (npm trusted publishing):

  • On npmjs.com → Settings → Trusted publishing → GitHub Actions
  • Repository: codapet/codapet-design-system
  • Workflow filename: release.yml (must match exactly, including extension)
  • Allowed actions: npm publish
  • Optionally restrict token-based publishing under Settings → Publishing access after verifying OIDC works

Release steps:

# update version in package.json
git commit -am "chore(release): v1.2.3"
git tag v1.2.3
git push --follow-tags

The workflow builds, tests, and runs npm publish --access public.

Styling

The design system uses Tailwind CSS for styling. Make sure to include Tailwind CSS in your project and configure Tailwind to scan this package so utilities used inside it are generated.

  1. In your global CSS (e.g. app/globals.css), add @source to include the design system and import its stylesheet after Tailwind:
@import "tailwindcss";

/* Tell Tailwind to scan the design system in node_modules */
@source "../**/*.{js,ts,jsx,tsx,mdx}";
@source "../../node_modules/@codapet/design-system/dist/**/*.{js,mjs,ts,tsx}";

/* Import the design system CSS tokens and base layers */
@import "@codapet/design-system/styles";
  1. Ensure your layout imports your globals (Next.js):
// app/layout.tsx
import "./globals.css";

Tailwind v3

If you are still on Tailwind v3, use the content globs instead of @source:

// tailwind.config.js
/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    './app/**/*.{js,ts,jsx,tsx}',
    './components/**/*.{js,ts,jsx,tsx}',
    './node_modules/@codapet/design-system/dist/**/*.{js,mjs,ts,tsx}',
  ],
  theme: { extend: {} },
  plugins: [],
}

Troubleshooting

  • Components render unstyled:
    • Ensure your globals.css contains @source that points to the design system in node_modules (Tailwind must see class usage to emit utilities).
    • Restart the dev server after changing @source or Tailwind config.
    • Verify @import "@codapet/design-system/styles"; comes after @import "tailwindcss";.
    • If you use Tailwind v3, configure content globs as shown above.
  • PostCSS cannot resolve an import:
    • Ensure @tailwindcss/postcss is installed and present in postcss.config.*.
    • If you see an error resolving tw-animate-css, install it in the app: npm i -D tw-animate-css.
  • Still stuck? Clear caches and rebuild: rm -rf .next then npm run dev.

Dependency Management

For detailed information about how dependencies are organized and managed, see DEPENDENCIES.md.

Key Points:

  • Peer Dependencies: React and React DOM (provided by consuming app)
  • Dependencies: UI libraries and utilities (bundled with library)
  • Dev Dependencies: Build tools and development utilities (not included in package)

Using with AI coding agents

This package ships an AGENTS.md at its root — a guide for AI agents (Claude Code, Cursor, Codex, etc.) explaining how the library differs from stock shadcn/ui (button defaults, custom components, brand tokens, common gotchas). It's published with the npm tarball, so once you've installed the package, the file is at node_modules/@codapet/design-system/AGENTS.md.

To make Claude Code automatically pull it into every session in your consumer repo, add one line to your repo's CLAUDE.md (or AGENTS.md):

@./node_modules/@codapet/design-system/AGENTS.md

The @path syntax inlines the file's content into the agent's context. Because it resolves at session start, the guide always matches the version of @codapet/design-system you have installed — bump the dep, get the updated guide, no copy-paste.

For other agent tools (Cursor, Codex, etc.) the file is still readable at the same path; refer to your tool's docs for how to point it at additional context files.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

版本与发布记录

@codapet/design-system 共发布 75 个版本,首次发布于 2025/08/27;过去 12 个月发布了 54 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.9.2latest2026/11/036 天前
0.9.12026/10/1526 天前
0.9.02026/09/171 个月前
0.8.92026/09/072 个月前
0.8.82026/09/072 个月前
0.8.72026/08/212 个月前

关于 @codapet/design-system 的常见问题

@codapet/design-system 是什么?

A comprehensive React component library built with Shadcn UI, Radix UI, Tailwind CSS, and TypeScript.

如何安装 @codapet/design-system?

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

@codapet/design-system 支持 TypeScript 吗?

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

@codapet/design-system 支持 ESM 还是 CommonJS?

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

@codapet/design-system 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@codapet/design-system 可以商用吗?

@codapet/design-system 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@codapet/design-system 的下载量有多少?

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

@codapet/design-system 还在维护吗?

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