@contentful/experiences-design

中文文档
0.13.12发布于 2026/11/07MITTypeScriptES Module零依赖近 30 天下载 4272

CSS property utilities for Contentful Experiences

原始使用文档
文档目录3 节
  1. What lives here
  2. toCss and the CSS-property whitelist
  3. License

@contentful/experiences-design

⚠️ Internal package. You don't install this directly — the framework adapter (e.g. @contentful/experiences-react) re-exports the utilities you need.

Framework-agnostic helpers for turning resolved design-property records into CSS-shaped values.

What lives here

  • toCssKey(key) — normalize a design-record key to a candidate CSS property name: strip an optional cf prefix and camelCase kebab/snake (cf-font-size → fontSize).
  • isCssProperty(key) / CSS_PROPERTIES — membership test and the underlying Set of CSS property names the adapters' toCss will emit.

toCss and the CSS-property whitelist

toCss is a companion to the design-hook escape hatch, not part of the recommended styling path. Components should style from their auto-filled design props, where they read the keys they declared and there is nothing to filter — see Styling components.

The adapters' toCss helper keeps only keys whose normalized form is in CSS_PROPERTIES and drops everything else — that's how semantic design values (variant, as, ratio, …) stay out of a style object. The trade-off is that a genuine CSS property missing from the set is dropped silently.

If you hit that:

  • Read the value directly. The full resolved record is available from useDesignValues() / getDesignValues(); toCss is only a convenience over it, so a key it drops is still readable by name.
  • Extend the set. CSS_PROPERTIES is exported and mutable (CSS_PROPERTIES.add('containerType')) — a key added there flows through toCss on the next render.

The list is intentionally curated rather than exhaustive (a full CSS-property warning would misfire on the semantic keys toCss is meant to drop). Open a PR to add commonly-needed properties.

See ../../AGENTS.md for the design rationale and multi-framework story.

License

MIT. See the repository LICENSE and NOTICE for full attribution.

版本与发布记录

@contentful/experiences-design 共发布 53 个版本,首次发布于 2026/07/21;过去 12 个月发布了 53 个版本。

版本发布日期距今
0.13.12latest2026/11/074 天前
0.13.112026/11/055 天前
0.13.102026/11/056 天前
0.13.92026/11/046 天前
0.13.82026/10/3111 天前
0.13.72026/10/3011 天前

关于 @contentful/experiences-design 的常见问题

@contentful/experiences-design 是什么?

CSS property utilities for Contentful Experiences

如何安装 @contentful/experiences-design?

在项目目录运行 npm install @contentful/experiences-design,或使用 pnpm add / yarn add / bun add。

@contentful/experiences-design 支持 TypeScript 吗?

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

@contentful/experiences-design 支持 ESM 还是 CommonJS?

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

@contentful/experiences-design 可以商用吗?

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

@contentful/experiences-design 的下载量有多少?

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

@contentful/experiences-design 还在维护吗?

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