@carbon/grid

中文文档
11.66.0发布于 2026/11/04Apache-2.0构建来源已验证近 30 天下载 86.6万

Grid for digital and software products using the Carbon Design System

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

@carbon/grid

Grid for digital and software products using the Carbon Design System

Getting started

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

npm install -S @carbon/grid

If you prefer Yarn, use the following command instead:

yarn add @carbon/grid

You can then include the grid by doing the following in your Sass files:

@use '@carbon/grid';

// Emit the flex-grid styles
@include grid.flex-grid();

Usage

More examples and documentation can be found on this live demo website.

@carbon/grid has three primitive class types to use in order to structure your application. They include:

  • cds--grid, defines the overall grid context and sets some useful attributes like width and margin
  • cds--row, defines a row of items in a grid
  • cds--col, used to define individual columns

You can use a combination of these classes to build a layout. For example, if we wanted a 4 column layout for a small breakpoint we could use the following markup:

<div class="cds--grid">
  <div class="cds--row">
    <div class="cds--col">1/4</div>
    <div class="cds--col">1/4</div>
    <div class="cds--col">1/4</div>
    <div class="cds--col">1/4</div>
  </div>
</div>

While this layout can work for some grid usage scenarios, we probably will want more control over how many columns our layout will span at each given breakpoint.

By default, @carbon/grid uses the breakpoints defined in @carbon/layout. There are five breakpoints: sm, md, lg, xlg, and max. You can use each one in combination with a column to specify the number of columns to span at a given breakpoint. For example, we could rewrite the above example to be:

<div class="cds--grid">
  <div class="cds--row">
    <div class="cds--col-sm-1">1/4</div>
    <div class="cds--col-sm-1">1/4</div>
    <div class="cds--col-sm-1">1/4</div>
    <div class="cds--col-sm-1">1/4</div>
  </div>
</div>

The .cds--col-sm-1 class names tells us that this <div> should only span one column at our sm breakpoint. By default, as we scale beyond the breakpoint the layout will still take up a percentage of the overall width.

📚 Examples

If you're looking for more examples on how to use @carbon/grid, we have some examples that you can check out:

🙌 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/grid 共发布 321 个版本,首次发布于 2018/10/02;过去 12 个月发布了 44 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

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

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

关于 @carbon/grid 的常见问题

@carbon/grid 是什么?

Grid for digital and software products using the Carbon Design System

如何安装 @carbon/grid?

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

@carbon/grid 支持 TypeScript 吗?

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

@carbon/grid 可以商用吗?

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

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

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

@carbon/grid 还在维护吗?

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