@carbon/layout

中文文档
11.63.0发布于 2026/11/04Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 97.4万

Layout helpers for digital and software products using the Carbon Design System

原始使用文档
文档目录6 节
  1. Getting started
  2. Usage
  3. Modifying token values
  4. 🙌 Contributing
  5. 📝 License
  6. IBM Telemetry

@carbon/layout

Layout helpers for digital and software products using the Carbon Design System

Getting started

To install @carbon/layout in your project, you will need to run the following command using npm:

npm install -S @carbon/layout

If you prefer Yarn, use the following command instead:

yarn add @carbon/layout

Usage

@carbon/layout provides a couple of useful utilities alongside the specification for the grid system for the IBM Design Language. This package includes:

FeatureDescription
BreakpointsVariables and settings for the IBM Design Grid, including gutter and breakpoints. It also includes helpers for working with breakpoints
Unit conversionHelpers for converting from px to rem or em.
Key heightsHelpers for working with key heights at different breakpoints
Mini unitHelpers for working in multiples of the mini-unit
SpacingProvides a spacing scale and helper for using steps in the scale

One important thing to remember is that @carbon/layout is not responsible for the grid itself. If you are looking for a grid implementation to use, definitely check out the @carbon/grid package.

@carbon/layout provides the above features in both Sass and JavaScript. If you're looking for support in a different language, feel free to file an issue proposing the new addition!

Modifying token values

Token values are defined in tokens/layout.tokens.json using the DTCG token format. This is the single source of truth for the package — do not edit generated files directly.

The following files are generated at build time and should not be hand-edited:

  • js/generated/layout-tokens.js / js/generated/layout-tokens.d.ts — JS exports
  • scss/generated/ — Sass variables and maps, one file per token group

To add or update a token:

  1. Edit tokens/layout.tokens.json
  2. Run yarn build in this package to regenerate all outputs
  3. Run yarn test --testPathPatterns=packages/layout from the repo root to confirm nothing regressed

For a detailed guide to the token format and how to add a new token category, see tokens/README.md.

🙌 Contributing

We're always looking for contributors to help us fix bugs, build new features, or help us improve the project documentation. If you're interested, definitely check out our Contributing Guide! 👀

📝 License

Licensed under the Apache 2.0 License.

IBM Telemetry IBM Telemetry

This package uses IBM Telemetry to collect de-identified and anonymized metrics data. By installing this package as a dependency you are agreeing to telemetry collection. To opt out, see Opting out of IBM Telemetry data collection. For more information on the data being collected, please see the IBM Telemetry documentation.

版本与发布记录

@carbon/layout 共发布 305 个版本,首次发布于 2018/10/02;过去 12 个月发布了 42 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
11.63.0latest2026/11/044 天前
11.63.0-rc.02026/11/035 天前
12.0.0-alpha.4v12-alpha2026/10/2812 天前
12.0.0-alpha.32026/10/2118 天前
11.62.02026/10/2119 天前
11.62.0-rc.02026/10/2020 天前

其他发布通道:alpha → 0.0.1-alpha.32,beta → 0.0.1-beta.5,canary → 10.6.0-alpha.5708,nightly → 10.16.0-alpha.0,v10-next → 10.37.5,v12-alpha → 12.0.0-alpha.4。

关于 @carbon/layout 的常见问题

@carbon/layout 是什么?

Layout helpers for digital and software products using the Carbon Design System

如何安装 @carbon/layout?

在项目目录运行 npm install @carbon/layout,或使用 pnpm add / yarn add / bun add。

@carbon/layout 支持 TypeScript 吗?

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

@carbon/layout 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@carbon/layout 可以商用吗?

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

@carbon/layout 的下载量有多少?

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

@carbon/layout 还在维护吗?

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