@esri/calcite-components-react

中文文档
5.2.1发布于 2026/11/05SEE LICENSE.mdTypeScriptESM + CJS构建来源已验证近 30 天下载 2.2万

A set of React components that wrap calcite components

原始使用文档
文档目录10 节
  1. Deprecation Notice
  2. Installation
  3. Choose a build
  4. Custom Elements build
  5. Dist build
  6. Copy Assets
  7. Why not just use the web components directly?
  8. Contributing
  9. License
  10. Third-party notices

Calcite Components React

This package provides React wrappers for Calcite components. Refer to the React example for a minimal application using this package.

Deprecation Notice

[!WARNING] Calcite Components React is deprecated as of v5.0.

The @esri/calcite-components-react package was originally developed for use with React 18 where wrappers were necessary to use custom elements. With React 19's custom element support, these wrappers are no longer needed.

Consider upgrading to React 19+ and using @esri/calcite-components directly.

Installation

pnpm add @esri/calcite-components-react

This package includes the compatible version of the standard @esri/calcite-components package, so you do not need to install it separately.

Choose a build

There are two builds provided by the standard components package.

Custom Elements build

Custom Elements is the recommended build when using frontend frameworks, such as React. Assets from the CDN are used by default, but you can specify a local asset path with setAssetPath. Additional setup for using local assets will be explained in a subsequent step.

import { setAssetPath } from "@esri/calcite-components";

setAssetPath(window.location.href);

Next, you need to import each component you use from the standard components package's custom elements build. This will automatically define the custom elements on the window. Then, import the same components from @esri/calcite-components-react.

import "@esri/calcite-components/dist/components/calcite-button";
import "@esri/calcite-components/dist/components/calcite-icon";
import "@esri/calcite-components/dist/components/calcite-slider";
import { CalciteButton, CalciteIcon, CalciteSlider } from "@esri/calcite-components-react";

Dist build

When using the Dist build, you'll need to manually define the custom elements on the window:

import { defineCustomElements } from "@esri/calcite-components/dist/loader";

defineCustomElements();

Since you manually defined the custom elements on the window, you only need to import the individual components from @esri/calcite-components-react.

import { CalciteButton, CalciteIcon, CalciteSlider } from "@esri/calcite-components-react";

Copy Assets

Some components (icon, date-picker) rely on assets being available at a particular path. If using assets locally, you'll need to copy these over to your public folder. Something like:

cp -r node_modules/@esri/calcite-components/dist/cdn/assets/* ./public/assets/

Why not just use the web components directly?

With React 19+'s native support for custom elements, you can now use @esri/calcite-components directly. See the Calcite Components React Deprecation Notice for additional information.

React 18 and earlier versions use a synthetic event system, where the custom events emitted from Calcite Components won't function with JSX in React. For example, if using standard web components to update a value when changes occur on the <calcite-slider>, you will need to save a reference to the element and add a listener:

const sliderEl = useRef(null);
const [sliderValue, setSliderValue] = useState(50);

function onUpdate(event) {
  setSliderValue(event.target.value);
}

// need to access the DOM node to set custom event listeners for props that aren't strings or numbers
// lit.dev/docs/frameworks/react#why-are-wrappers-needed
useEffect(
  (_) => {
    sliderEl.current.addEventListener("calciteSliderUpdate", onUpdate);
  },
  [sliderEl],
);

Using @esri/calcite-components-react, these events are connected for you:

const [sliderValue, setSliderValue] = useState(50);
<CalciteSlider onCalciteSliderUpdate={(e) => setSliderValue(e.target.value)} />;

If you're using TypeScript, you'll also get increased type safety for your event listeners, props, etc.

Contributing

We welcome contributions to this project. See the CONTRIBUTING.md for an overview of contribution guidelines.

License

COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt

All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.

This material is licensed for use under the Esri Master License Agreement (MLA), and is bound by the terms of that agreement. You may redistribute and use this code without modification, provided you adhere to the terms of the MLA and include this copyright notice.

See use restrictions at http://www.esri.com/legal/pdfs/mla_e204_e300/english

For additional information, refer to Calcite's licensing and contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, USA 92373 USA

email: [email protected]

Third-party notices

See THIRD-PARTY-NOTICES.md.

版本与发布记录

@esri/calcite-components-react 共发布 1,229 个版本,首次发布于 2021/06/08;过去 12 个月发布了 297 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
5.2.1latest2026/11/059 天前
6.0.0-next.5next2026/10/2718 天前
6.0.0-next.42026/10/2718 天前
6.0.0-next.32026/10/2421 天前
6.0.0-next.22026/10/2321 天前
6.0.0-next.12026/10/2322 天前

其他发布通道:rc → 2.0.0-rc.2,hotfix → 2.8.1-hotfix.0,next → 6.0.0-next.5。

关于 @esri/calcite-components-react 的常见问题

@esri/calcite-components-react 是什么?

A set of React components that wrap calcite components

如何安装 @esri/calcite-components-react?

在项目目录运行 npm install @esri/calcite-components-react,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=18.3)、react-dom(>=18.3)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@esri/calcite-components-react 支持 TypeScript 吗?

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

@esri/calcite-components-react 支持 ESM 还是 CommonJS?

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

@esri/calcite-components-react 可以商用吗?

@esri/calcite-components-react 使用 SEE LICENSE.md 许可。声明的许可为 SEE LICENSE.md,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@esri/calcite-components-react 的下载量有多少?

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

@esri/calcite-components-react 还在维护吗?

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