@coopdigital/foundations

中文文档
1.12.0发布于 2026/10/29MIT零依赖近 30 天下载 2528

Our foundations are the base CSS and variables that we build our products on

原始使用文档
文档目录12 节
  1. Structure and contents
  2. Usage
  3. Installation
  4. Recommended: Importing everything
  5. Importing partials
  6. Icon usage
  7. Using the icons in your project
  8. Using the icons accessibly
  9. CSS
  10. Full list of icons by ID
  11. Contributing
  12. Migration from css-foundations to foundations

Co-op Foundations

Our foundations are the design basics that we build our products on.

We use foundations to help create our elements and components. When we keep our foundations consistent, our products look and feel consistent for customers.

Structure and contents

The foundations are a mix of baseline CSS styles, fonts, custom properties and utility classes. We have split them into the following categories:

  • Base
  • Colors
  • Layout
  • Spacing
  • Typography
  • UI

Usage

Installation

npm install @coopdigital/foundations
@import "@coopdigital/foundations/dist/vars/vars.css";
@import "@coopdigital/foundations/dist/foundations.css";

This is the easiest way to get everything you need.

Importing partials

If you only require partials of the foundations you can use the imports below. Make sure you keep the structure to ensure the cascade works.

/* Variables */
/* Colours */
@import "@coopdigital/foundations/dist/vars/colors.css";
@import "@coopdigital/foundations/dist/vars/colors-cls.css";
@import "@coopdigital/foundations/dist/vars/colors-membership.css";
/* Typography */
@import "@coopdigital/foundations/dist/vars/typography.css";
/* Spacing */
@import "@coopdigital/foundations/dist/vars/spacing.css";
/* UI */
@import "@coopdigital/foundations/dist/vars/ui.css";

/* Base */
@import "@coopdigital/foundations/dist/base/base.css";
/* Typography */
@import "@coopdigital/foundations/dist/typography/typography.css";
/* Layout */
@import "@coopdigital/foundations/dist/layout/grid.pcss";
/* UI */
@import "@coopdigital/foundations/dist/ui/a11y.css";
@import "@coopdigital/foundations/dist/ui/logo.css";
@import "@coopdigital/foundations/dist/ui/icons.css";

/* Utilities */
@import "@coopdigital/foundations/dist/colors/colors-utilities.css";
@import "@coopdigital/foundations/dist/colors/cls/colors-utilities-cls.css";
@import "@coopdigital/foundations/dist/colors/membership/colors-utilities-membership.css";
@import "@coopdigital/foundations/dist/typography/typography-utilities.css";
@import "@coopdigital/foundations/dist/spacing/spacing-utilities.css";
@import "@coopdigital/foundations/dist/layout/layout-utilities.css";

Icon usage

Icons are separated out as separate SVG files in src/ui/icons and combined into an SVG sprite called coop-icon-sprite.svg. The sprite is checked in at src/assets/icons/coop-icon-sprite.svg and copied to dist by the build script.

This sprite can be served into your project from node_nodules from within foundations/dist/assets/icons/coop-icon-sprite.svg, using the build process of your choice.

Go to the design guidelines on using the icons on the Experience Library icons page

Using the icons in your project

Once you have the icons loaded in your front-end you can reference them by using:

<svg>
  <use xlink:href="coop-icon-sprite.svg#[icon-file-name]"></use>
</svg>

For example the shopping basket icon would be used with:

Using the icons accessibly

You should always try to pair an icon with text if possible as suggested in the Experience Library guidelines on icons

If the icon is paired with text it is classed as decorative and can be hidden from screen readers.

<p>
  <svg aria-hidden="“true”">
    <title>Basket</title>
    <use xlink:href="coop-icon-sprite.svg#icon-basket"></use>
  </svg>
  Basket
</p>

If it is not possible to pair the icon with text then the aria-hidden attribute is not needed.

<svg role="img">
  <title>Basket</title>
  <use xlink:href="coop-icon-sprite.svg#icon-basket"></use>
</svg>

CSS

There are some CSS classes to space and size the icons. The scooter being rectangular takes a modifier class to double the width.

.coop-i {
    fill: currentColor;
    margin: 20px;
    width: 32px;
    height: 32px;
}

.coop-i--scooter {
    width: 64px;
}

Full list of icons by ID

#icon-add
#icon-minus
#icon-arrow-up
#icon-arrow-down
#icon-arrow-left
#icon-arrow-right
#icon-chevron-up
#icon-chevron-down
#icon-chevron-left
#icon-chevron-right
#icon-avatar
#icon-avatar-alt
#icon-basket
#icon-clock
#icon-close
#icon-close-alt
#icon-coop
#icon-coop-card
#icon-location
#icon-coop-location
#icon-download
#icon-home
#icon-information
#icon-mail
#icon-menu
#icon-message
#icon-open-new
#icon-phone
#icon-question
#icon-search
#icon-settings
#icon-tick
#icon-tick-alt
#icon-van
#icon-warning
#icon-write
#icon-pencil
#icon-calendar
#icon-scooter

Contributing

Migration from css-foundations to foundations

See our migration guide here

版本与发布记录

@coopdigital/foundations 共发布 23 个版本,首次发布于 2021/12/13;过去 12 个月发布了 4 个版本。

版本发布日期距今
1.12.0latest2026/10/2913 天前
1.11.02026/10/1625 天前
1.10.02026/07/253 个月前
1.9.12026/01/0910 个月前
1.9.02025/01/271.8 年前
1.8.02024/09/052 年前

关于 @coopdigital/foundations 的常见问题

@coopdigital/foundations 是什么?

Our foundations are the base CSS and variables that we build our products on

如何安装 @coopdigital/foundations?

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

@coopdigital/foundations 支持 TypeScript 吗?

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

@coopdigital/foundations 可以商用吗?

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

@coopdigital/foundations 的下载量有多少?

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

@coopdigital/foundations 还在维护吗?

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