javascript - 如何在blueprintjs v3中的 react 应用程序中为所有子组件切换主题(浅色和深色)?

标签 javascript reactjs blueprintjs

我正在用 React 编写一个应用程序,需要一种在暗模式和亮模式之间切换的方法。我在 blueprintjs docs 中找不到任何文档,其中提到如何使用某些父 prop 配置更改所有子组件的主题。

最佳答案

使用类名 .bp3-暗在您的根容器中,如下所示。

Blueprint provides two UI color themes: light and dark. The light theme is active by default. The dark theme can be applied by adding the class bp3-dark to a container element to theme all nested elements.

import React from 'react';

import {Navigation} from "./Navigation";
import Main from "./Main";

const App = () => (
    <div className="bp3-dark">
      <Navigation />
      <Main />
    </div>
  );

export default App;

关于javascript - 如何在blueprintjs v3中的 react 应用程序中为所有子组件切换主题(浅色和深色)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59782130/

相关文章:

javascript - 我是否必须将 TypeScript 与 Blueprint.js 中的 MultiSelect(实验室)组件结合使用

javascript - 将点击处理程序添加到动态生成的内容。如何?

javascript - ES5 风格的连接数组。将数组合并为一个

javascript - Angular ui-router Controller 范围

javascript - JQuery 事件不适用于生产中的 heroku,但适用于开发中

css - react 动画容器高度

css - 显示 :none is not freeing up the space in firefox

typescript - 安装蓝图时,环境上下文错误中不允许初始化程序

reactjs - 如何在blueprintjs中自定义颜色?

javascript - 如何在 js 脚本中读取 docker 环境变量?