@canonical/maas-react-components

中文文档
3.0.7发布于 2026/11/09AGPL-3.0TypeScriptESM + CJS零依赖近 30 天下载 4273

React components for use in MAAS UI projects.

原始使用文档
文档目录4 节
  1. Getting started
  2. Installation
  3. Development with maas-react-components
  4. Creating a new component

MAAS React Components


Canonical MAAS

Library of React components for use in MAAS UI projects.

It contains components that are either specific to, or only used in MAAS.
General purpose components should be added to @canonical/react-components instead.

Storybook | Philosophy and guidelines


Getting started

Installation

npm install @canonical/maas-react-components

or using yarn:

yarn add @canonical/maas-react-components

Add styles import to your app:

@import "@canonical/maas-react-components/dist/style.css";

Development with maas-react-components

To see the changes you make to maas-react-components reflected in a consuming app immediately, follow these steps:

  1. In the maas-react-components directory, run the following command to create a symlink:

    yarn link
    
  2. In the consuming repository (e.g., maas-ui), run the following command to use the local version of maas-react-components:

    yarn link "@canonical/maas-react-components"
    
  3. Go back to maas-react-components directory and run the following command to start the build process with the watch flag:

    npm run build:watch
    
  4. As you make changes to maas-react-components they will be automatically built and reflected in the consuming app.

Creating a new component

Make sure to read our React Components Guidelines before you proceed.

Run the following command from the root of the project:

npm run create-component

The script will prompt you to enter details of the new component.

It will create a new directory and files based on the details you provided. New files will contain a basic setup for your new component, including a basic test and a storybook story.

版本与发布记录

@canonical/maas-react-components 共发布 102 个版本,首次发布于 2023/10/03;过去 12 个月发布了 42 个版本。

版本发布日期距今
3.0.7latest2026/11/09今天
3.0.62026/11/09今天
3.0.52026/11/09今天
3.0.42026/11/09今天
3.0.32026/11/09今天
3.0.22026/11/09今天

关于 @canonical/maas-react-components 的常见问题

@canonical/maas-react-components 是什么?

React components for use in MAAS UI projects.

如何安装 @canonical/maas-react-components?

在项目目录运行 npm install @canonical/maas-react-components,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.1.0)、react-dom(^19.1.0)、classnames(^2.3.2)、@types/react(^19.1.2)、react-router(>=6.0.0)、react-dropzone(^14.3.8)、@types/react-dom(^19.1.3)、@canonical/styles(^0.37.0 || ^0.45.0)、@canonical/ds-assets(^0.37.0 || ^0.45.0)、@tanstack/react-query(^5.100.11)、@tanstack/react-table(^8.15.3)、@canonical/react-ds-global(^0.37.0 || ^0.45.0)、@canonical/react-components(^4.5.0)、@canonical/react-ds-global-form(^0.37.0 || ^0.45.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@canonical/maas-react-components 支持 TypeScript 吗?

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

@canonical/maas-react-components 支持 ESM 还是 CommonJS?

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

@canonical/maas-react-components 可以商用吗?

@canonical/maas-react-components 使用 AGPL-3.0 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@canonical/maas-react-components 的下载量有多少?

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

@canonical/maas-react-components 还在维护吗?

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