@coralreefventures/theme

中文文档
0.7.0发布于 2026/10/20MITES Module零依赖构建来源已验证近 30 天下载 2304

Builds a product's Mantine theme from its brand tokens, and the stylesheet of CSS variables MantineProvider would inject for it.

原始使用文档

@coralreefventures/theme

Builds a product's Mantine theme from its brand tokens, and generates the stylesheet of CSS variables that MantineProvider would inject for it, so a page that renders as server components only still gets the theme.

Both Coral Reef sites carried the same theme.ts and generate-css.ts, differing only in their scales, primary color and font variable. Each product's packages/theme is now its tokens file plus a call into this package, and the stylesheet it generates is byte-identical to what it generated before: a test here runs the builder over both products' token files and compares the output with their committed theme.css.

// packages/theme/src/theme.ts in a product
import { createBrandTheme } from "@coralreefventures/theme";
import tokens from "@streamlane/brand/tokens";

export const brand = tokens.color;

export const theme = createBrandTheme(tokens, {
  colors: {
    // Ten shades, each a hex or the name of a brand color: ink is shade 8, ink-soft shade 7.
    ink: ["#EEF4F4", "#D8E5E5", "#B3CBCC", "#8BAFB0", "#669496", "#4A7C7E", "#336567", "ink-soft", "ink", "#0B2728"],
    signal: ["#FEF6EA", "#FCEBD0", "#FADAA5", "signal-soft", "#F4B658", "signal", "#DB9425", "#B97A17", "#94610F", "#704908"],
  },
  black: "text",
  primaryColor: "ink",
  primaryShade: { light: 8, dark: 5 },
  fontVariable: "--streamlane-font-sans",
});
// packages/theme/scripts/generate-css.ts in a product
import { themeCss, writeThemeCss } from "@coralreefventures/theme";
import { cssVariablesResolver, theme } from "../src/theme";

await writeThemeCss(
  new URL("../theme.css", import.meta.url),
  themeCss(theme, { generatedBy: "packages/theme (pnpm --filter @streamlane/theme generate)", resolver: cssVariablesResolver }),
);

resolver is a product's own CSSVariablesResolver (Streamlane's tones and ink surface) and stays in the product; Driftline passes none. generatedBy is the first line of the stylesheet, which tells a reader what to run.

What it exports

  • createBrandTheme(tokens, config): the MantineThemeOverride. config.colors are the scales, primaryColor and primaryShade as Mantine takes them, fontVariable the CSS variable an app sets to its web font (Mantine's system stack is the fallback), and black the light-scheme text color, each color a hex or a brand color's name.
  • themeCss(theme, { generatedBy?, resolver? }): the stylesheet.
  • writeThemeCss(file, css): writes it.
  • brandColor(tokens, nameOrHex), brandFontFamily(variable), and the types BrandTokens, BrandThemeConfig, Scale, ThemeCssOptions.

Installing

This package ships TypeScript source and @mantine/core 9.6.3 is a peer. The code that imports it has to be transpiled: a product's theme package runs under tsx and Vitest and is bundled by Next through transpilePackages, all of which handle it. Add @coralreefventures/theme to transpilePackages where the product theme already is.

版本与发布记录

@coralreefventures/theme 共发布 11 个版本,首次发布于 2026/10/05;过去 12 个月发布了 11 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.7.0latest2026/10/2022 天前
0.6.02026/10/1923 天前
0.5.02026/10/1823 天前
0.4.32026/10/1823 天前
0.4.22026/10/1329 天前
0.4.12026/10/1329 天前

关于 @coralreefventures/theme 的常见问题

@coralreefventures/theme 是什么?

Builds a product's Mantine theme from its brand tokens, and the stylesheet of CSS variables MantineProvider would inject for it.

如何安装 @coralreefventures/theme?

在项目目录运行 npm install @coralreefventures/theme,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@mantine/core(9.6.3)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@coralreefventures/theme 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/coralreefventures__theme 是否存在。

@coralreefventures/theme 支持 ESM 还是 CommonJS?

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

@coralreefventures/theme 需要什么版本的 Node.js?

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

@coralreefventures/theme 可以商用吗?

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

@coralreefventures/theme 的下载量有多少?

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

@coralreefventures/theme 还在维护吗?

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