@cratis/components.mui

中文文档
4.40.0发布于 2026/11/04MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 3922

Material UI presentation adapter for Cratis Components renderer ABI v1.

原始使用文档
文档目录3 节
  1. Install
  2. Theme integration
  3. Peer policy

@cratis/components.mui

Material UI adapter for the nine stable presentation slots in the Cratis Components renderer ABI v1. The package shares the Components repository release version while the renderer ABI remains versioned separately. It exports one stable CratisPresentationUiLibrary manifest, muiUiLibrary. This certifies nine-slot primitive adaptation, never full-catalog replacement.

Versions: each release of @cratis/components.mui is published at the same version as @cratis/components and declares a peer on exactly that version. Install and upgrade the two packages together at the same version.

Install

npm install @cratis/components.mui@^4 @cratis/components@^4 \
  @mui/material@^9 @emotion/react@^11 @emotion/styled@^11 react@^19 react-dom@^19

Node-based build, test, and server-rendering environments require Node.js 22 or newer.

Select the adapter on the application Components provider:

import { CratisComponentsProvider } from '@cratis/components';
import { muiUiLibrary } from '@cratis/components.mui';

export const Application = () => (
    <CratisComponentsProvider value={{ locale: 'en-US' }} library={muiUiLibrary}>
        <main>Application content</main>
    </CratisComponentsProvider>
);

Components that execute commands or run queries also need Arc's <Arc> provider from @cratis/arc.react around this tree; neither the adapter nor CratisComponentsProvider replaces it.

The adapter covers Button, IconButton, TextInput, TextArea, Checkbox, Radio, Switch, ProgressBar, and Surface. It deliberately excludes MUI X and does not implement the five atomic interaction slots.

Theme integration

The manifest provider mounts the MUI ThemeProvider. An outer CSS-variable MUI theme is reused. An outer non-variable theme is converted to an equivalent CSS-variable theme so its palette and other values remain in force. Without an outer provider, MUI's default theme becomes a sane CSS-variable-enabled theme. The conversion is memoized and deterministic during server rendering.

Put application customization in an MUI ThemeProvider (from @mui/material/styles) outside CratisComponentsProvider. In this excerpt, applicationTheme is the application's createTheme result:

<ThemeProvider theme={applicationTheme}>
    <CratisComponentsProvider value={{ locale: 'en-US' }} library={muiUiLibrary}>
        <Application />
    </CratisComponentsProvider>
</ThemeProvider>

The renderer provider ABI receives only children and non-secret boolean setup attestations; it cannot receive an Emotion cache. SSR hosts must create an Emotion cache per request, mount Emotion's CacheProvider outside the Components provider, and extract critical styles from that same request-local cache. Sharing a cache between requests can leak styles and ordering. RTL additionally requires the host MUI theme direction and an Emotion cache configured with the RTL Stylis plugin. These are application/host integration concerns and do not justify a Core ABI change.

Peer policy

MUI Core is bounded to >=9 <10, @emotion/react to >=11.5 <12, @emotion/styled to >=11.11 <12, and React/ReactDOM to React 19. Vendor packages are peers. The repository's packed-consumer matrix proves both these effective lower boundaries and the current-highest compatible boundary; exact current versions remain dev dependencies only.

The source manifest declares @cratis/components >=4 <5, the Components major whose renderer ABI and stable presentation profile the adapter implements. The release step replaces that range with the exact release version, so a published adapter requires the @cratis/components release it shipped with.

See CONFORMANCE.md for the bounded evidence and THIRD_PARTY_NOTICES.md for upstream licenses.

版本与发布记录

@cratis/components.mui 共发布 83 个版本,首次发布于 2026/08/31;过去 12 个月发布了 83 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
4.40.0latest2026/11/046 天前
4.39.52026/11/046 天前
4.39.42026/11/047 天前
4.39.32026/11/037 天前
4.39.22026/11/037 天前
4.39.12026/11/037 天前

其他发布通道:bootstrap → 0.0.0。

关于 @cratis/components.mui 的常见问题

@cratis/components.mui 是什么?

Material UI presentation adapter for Cratis Components renderer ABI v1.

如何安装 @cratis/components.mui?

在项目目录运行 npm install @cratis/components.mui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.0.0)、react-dom(^19.0.0)、@mui/material(>=9 <10)、@emotion/react(>=11.5 <12)、@emotion/styled(>=11.11 <12)、@cratis/components(4.40.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cratis/components.mui 支持 TypeScript 吗?

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

@cratis/components.mui 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cratis/components.mui 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@cratis/components.mui 可以商用吗?

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

@cratis/components.mui 的下载量有多少?

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

@cratis/components.mui 还在维护吗?

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