@brightlayer-ui/react-themes

中文文档
9.1.1发布于 2026/10/16BSD-3-ClauseTypeScriptES Module近 30 天下载 1.8万

React themes for Brightlayer UI applications

原始使用文档
文档目录9 节
  1. Installation
  2. Changing the default mode
  3. Manually toggling the mode
  4. Migration from v8 to v9
  5. Update Material UI
  6. Migration from v7 to v8
  7. Update Material UI
  8. Consolidate themes
  9. Update logic to toggle the theme mode

Brightlayer UI themes for React applications

Build

This package provides theming support for Eaton applications using the Brightlayer UI design system. It includes resources for developers using React w/ Material UI version 6+ (prior versions of this package will work with Material UI version 5 - check the Changelog for details). This package now comes with a single theme option that supports both light mode and dark mode.

For other frameworks, check out our related packages:

Installation

Install with npm

npm install --save @brightlayer-ui/react-themes

or yarn

yarn add @brightlayer-ui/react-themes

Usage

To use these themes in your application, simply wrap the app in a ThemeProvider and pass in the theme:

import { ThemeProvider } from '@mui/material/styles';
import { theme } from '@brightlayer-ui/react-themes';

<ThemeProvider theme={theme}>
    <App />
</ThemeProvider>;

The theme will default to light/dark mode based on the user's system preference. To manually toggle the theme mode (e.g., from settings), you will need to use the useColorScheme hook (see below).

Changing the default mode

If you do not want to use the system setting as the default, you can set the defaultMode on the ThemeProvider:

<ThemeProvider theme={theme} defaultMode={'dark' /* or 'light' */}></ThemeProvider>

Manually toggling the mode

You can manually toggle the theme mode using the useColorScheme hook:

import { useColorScheme } from '@mui/material/styles';
import InvertColors from '@mui/icons-material/InvertColors';
import IconButton from '@mui/material/IconButton';
import Tooltip from '@mui/material/Tooltip';

const ToggleComponent = () => {
    const { mode, setMode } = useColorScheme();

    return (
        <Tooltip title={'Toggle Theme'}>
            <IconButton
                onClick={() => {
                    setMode(mode === 'light' ? 'dark' : 'light');
                }}
            >
                <InvertColors />
            </IconButton>
        </Tooltip>
    );
};

For more information on toggling modes, refer to the MUI docs.

For more detailed information about the BLUI themes, refer to our developer documentation site.

Migration from v8 to v9

In version 9, the theme now follows the standard from MUI v7. In order to use the new version, you will need to:

Update Material UI

Ensure you have updated your Material UI dependencies to version 7 (this includes @mui/material, @mui/icons-material, etc.). Refer to the official MUI migration docs for more details.

Migration from v7 to v8

In version 8, the theme now follows the standard from MUI v6, which combines light and dark theme into a single theme object. In order to use the new version, you will need to:

Update Material UI

Ensure you have updated your Material UI dependencies to version 6 (this includes @mui/material, @mui/icons-material, etc.). Refer to the official MUI migration docs for more details.

Consolidate themes

If you were previously switching between blue and blueDark themes in your ThemeProvider, this should be replaced with the single theme object.

- import { blue, blueDark } from '@brightlayer-ui/react-themes';
+ import { theme } from '@brightlayer-ui/react-themes';

- <ThemeProvider theme={isDark ? blueDark : blue}></ThemeProvider>
+ <ThemeProvider theme={theme}></ThemeProvider>

Update logic to toggle the theme mode

Instead of swapping entire theme objects, you will now make use of the useColorScheme hook to toggle between light and dark mode. Refer to the usage instructions above or the MUI docs for more details.

Note: For few cases some styles may not apply correctly, hence they need to be declared explicitly for specific mode.

    sx={{
    backgroundColor: statusColor || Colors.black[500],
    color: getIconColor(),
    ...theme.applyStyles('dark', {
        color: getIconColor(),
        backgroundColor: statusColor || Colors.black[500],
    }),
}}

版本与发布记录

@brightlayer-ui/react-themes 共发布 32 个版本,首次发布于 2021/11/03;过去 12 个月发布了 9 个版本。

版本发布日期距今
9.1.1latest2026/10/1623 天前
9.1.1-alpha.0alpha2026/09/231 个月前
9.1.02026/07/233 个月前
9.1.0-alpha.52026/06/254 个月前
9.1.0-alpha.42026/05/285 个月前
9.1.0-alpha.32026/05/265 个月前

其他发布通道:beta → 6.1.1-beta.1,alpha → 9.1.1-alpha.0。

关于 @brightlayer-ui/react-themes 的常见问题

@brightlayer-ui/react-themes 是什么?

React themes for Brightlayer UI applications

如何安装 @brightlayer-ui/react-themes?

在项目目录运行 npm install @brightlayer-ui/react-themes,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@mui/material(^7.1.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@brightlayer-ui/react-themes 支持 TypeScript 吗?

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

@brightlayer-ui/react-themes 支持 ESM 还是 CommonJS?

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

@brightlayer-ui/react-themes 可以商用吗?

@brightlayer-ui/react-themes 使用 BSD-3-Clause 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括,不构成法律意见,请以许可原文为准。

@brightlayer-ui/react-themes 的下载量有多少?

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

@brightlayer-ui/react-themes 还在维护吗?

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