@codelitdev/design-system

中文文档
0.8.2发布于 2026/11/09Apache-2.0TypeScriptCommonJS零依赖构建来源已验证近 30 天下载 2942

Shared CodeLit design tokens, Tailwind preset, and React primitives for CourseLit, MediaLit, SendLit, and FrontLit.

原始使用文档
文档目录6 节
  1. Install
  2. Use in a shadcn app
  3. Components (shadcn registry)
  4. Available components
  5. Publishing
  6. License

@codelitdev/design-system

Shared tokens, Tailwind preset, and React primitives for CourseLit, MediaLit, SendLit, and FrontLit.

The tokens + Tailwind preset are the product; the React components are reference/fallback (see step 5). Consuming apps typically use only the CSS and the preset and keep their own shadcn components.

Install

Published to npm as a public package. The current release line is a prerelease under the alpha dist-tag.

[!WARNING] latest currently also points at 0.1.0-alpha.0. npm always sets latest on a package's first-ever publish, regardless of --tag — this is unavoidable until a real stable version is cut, at which point publishing it moves latest forward automatically. Until then, always pin the exact version — do not bun add @codelitdev/design-system bare, and do not use a caret/tilde range (^0.1.0-alpha.0 would still resolve to a prerelease, which is at least explicit — but a bare install with no version silently means "whatever latest is," which right now is this alpha).

bun add @codelitdev/[email protected]

Platform examples consume the package as workspace:*. Product repositories consume an exact published version.

Use in a shadcn app

  1. Import the token layer once, e.g. in app/globals.css:
@import "@codelitdev/design-system/styles.css";

This replaces the default shadcn :root/.dark block — variable names match, so existing shadcn components need no code changes.

  1. Extend your Tailwind config:
// tailwind.config.js
const codelitPreset = require("@codelitdev/design-system/tailwind-preset");
module.exports = {
  presets: [codelitPreset],
  content: [...],
};
  1. Scope the product on the <html> element (not <body>):
<html data-product="sendlit">  {/* courselit | medialit | sendlit | frontlit, omit for CodeLit amber */}

[!IMPORTANT] Put data-product on <html>, not <body>. The product scope only overrides --primary/--ring; any token you alias at :root that references --primary (e.g. shadcn's --sidebar-primary: var(--primary)) resolves that var() at the declaring element. If the override sits on <body> (a child of :root), those :root aliases freeze to the base amber and never pick up the product accent — while direct bg-primary utilities still turn green, producing a confusing split.

  1. Fonts: load Hanken Grotesk + Spline Sans Mono via next/font/google (or your framework's font loader), mapped to --font-sans / --font-mono.

  2. Components — install from the shadcn registry (see Components below). These are real shadcn/Radix components styled to the design system, so your app's buttons/badges/cards are the DS's — no hand-porting. The plain-React src/components/ classes (components.css) remain as visual reference only.

  3. Logos: @codelitdev/design-system/assets/logo-<product>.svg.

  4. Loaders — a drawn-from-the-logo spinner, not a static asset:

import { Loader } from "@codelitdev/design-system";
<Loader product="sendlit" size={32} />

Renders in currentColor, same as an icon component — wrap it (or an ancestor) in whatever sets the color you want, e.g. className="text-primary" for the product accent.

Components (shadcn registry)

The design system ships its components as a shadcn registry so every product installs the same styled components (buttons, badges, cards, …) via the shadcn CLI — keeping all four apps on one component layer instead of each re-styling its own. They're standard shadcn/Radix components; they pull their look from the DS tokens, so make sure @codelitdev/design-system/styles.css is imported (above).

Add the registry namespace to your app's components.json:

{
  "registries": {
    "@codelit": "https://raw.githubusercontent.com/codelitdev/platform/main/packages/design-system/public/r/{name}.json"
  }
}

Then install components like any other shadcn component:

bunx shadcn@latest add @codelit/button @codelit/badge @codelit/card

Or install a single component directly by URL, no config:

bunx shadcn@latest add https://raw.githubusercontent.com/codelitdev/platform/main/packages/design-system/public/r/button.json

Available components

ComponentNotes
buttonprimary / secondary / outline / ghost / soft / destructive; sm md lg (30/36/42px)
icon-buttonSquare icon-only; ghost / outline; sm md
badgedefault / neutral / success / warning / destructive / outline; dot prop
card+ CardHeader CardTitle CardDescription CardContent CardFooter
inputAccent-wash focus ring; aria-invalid → destructive
textareaMultiline form of input
label13px semibold field label
checkbox18px, 5px radius, accent fill when checked
radio-group+ RadioGroupItem
switch36×21 track, accent when on
selectTrigger matches input; token-styled popover
tabsSegmented; active trigger lifts onto a card surface
dialogWarm scrim, 16px radius; full Radix parts
dropdown-menuMatches select's popover treatment; full Radix parts incl. checkbox/radio items and submenus
tooltipDark chip; TooltipProvider included
toastPresentational card (default/success/destructive) — drive with your own queue

Install everything at once:

bunx shadcn@latest add @codelit/button @codelit/icon-button @codelit/badge @codelit/card \
  @codelit/input @codelit/textarea @codelit/label @codelit/checkbox @codelit/radio-group \
  @codelit/switch @codelit/select @codelit/tabs @codelit/dialog @codelit/dropdown-menu \
  @codelit/tooltip @codelit/toast

Maintainers: component sources live in registry/codelit/ui/. After changing one, rebuild the served JSON with bun run registry:build (→ public/r/*.json) and commit it — the raw-URL install serves those committed files.

Publishing

Prereleases go under the alpha dist-tag so a plain bun add never grabs one. Releases are driven from the Platform root through Changesets; do not run bun publish from this package directory:

bun run changeset
bun run release:alpha

Verify: bun info @codelitdev/design-system --json should show the prerelease under alpha and leave latest untouched.

License

Apache-2.0 — see LICENSE.

版本与发布记录

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

版本发布日期距今
0.8.2latest2026/11/09今天
0.8.12026/11/018 天前
0.8.02026/11/018 天前
0.7.02026/11/018 天前
0.6.02026/11/018 天前
0.5.02026/10/3010 天前

其他发布通道:alpha → 0.1.0-alpha.7。

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

@codelitdev/design-system 是什么?

Shared CodeLit design tokens, Tailwind preset, and React primitives for CourseLit, MediaLit, SendLit, and FrontLit.

如何安装 @codelitdev/design-system?

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

@codelitdev/design-system 支持 TypeScript 吗?

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

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

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

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

@codelitdev/design-system 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

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

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

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

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