前端 框架
一系列集成 Material 设计风格和 CSS 模块的 React 组件

React Toolbox

npm version Build Status NPM Status react-toolbox channel on discord Donate

React Toolbox is a set of React components that implement Google's Material Design specification. It's powered by CSS Modules and harmoniously integrates with your Webpack workflow. You can take a tour through our documentation website and try the components live!


React Toolbox can be installed as an npm package;

npm install --save react-toolbox


Although there are other ways to use React Toolbox, the recommended way is to create a Webpack workflow with Babel Loader, CSS Loader and SASS Loader. A good starting point is React Hot Webpack Boilerplate.

Once you have the workflow ready, you can just require and use the components:

import React from 'react';
import Button from 'react-toolbox/lib/button';

const CustomButton = () => (
  <Button label="Hello world" raised accent />

export default CustomButton;

The previous code creates a React button component based on React toolbox button. It's important to notice that requiring a module from the exposed root of the package will import the SASS of the component.

Roboto Font and Material Design Icons

React Toolbox assumes that you are importing Roboto Font and Material Design Icons.

In order to import the fonts for you, we'd need to include them in the CSS which is considered a bad practice. If you are not including them in your app yo to the linked sites and follow the instructions.

App component

There are some components in React Toolbox that requires special positioning. For example, Dialog and Drawer components block the scroll showing a fixed positioned overlay. To handle these cases, React Toolbox needs some styling in your root node. This can be achieved wrapping your app with a non intrusive App wrapper component:

import React from 'react';
import ReactDOM from 'react-dom';
import ToolboxApp from 'react-toolbox/lib/app';
import App from './my-app';

    <App />
, document.getElementById('app'));


Since React Toolbox styles are written in CSS it's pretty easy to customize your components. We have several ways:

Via React Toolbox Loader

Thanks to the power of SASS, all components in React Toolbox are configured from a variables file. The best way to customize your build is to create a custom configuration SASS file overriding configuration variables like colors or sizes.

With toolbox-loader you can tell webpack where your configuration file is and it will prepend your config to each SASS build. This will result in your customized CSS for React Toolbox Components. For now you can browse the configuration files and override what you want.

Via className property

Generally each component will have a className prop so you can tell the class name you want to keep in the root node of the resulting markup. All markup is style with the lowest specificity level so you can just nest one level in your CSS and the result will be applied. Consider this example:

const CustomButton = () => (
  <Button className='customized' label='Custom button' />

If you browse the resulting markup you will see data attributes like data-role="label" so you can avoid styling directly tag names. You can now write your CSS:

.customized > [data-role="label"] {
  color: green;
  font-weight: bold;

Authors and Contributors

The project is being initially developed and maintained by Javier Velasco and Javier Jiménez and the contribution scene is just getting warm. We want to create reference components so any contribution is very welcome.

To work in the project you'd need a node version supporting ES6 syntax. Although the project is built using Babel we use some ES6 features in the development server. Also, the packages has been tested with node 4.2.1. Consider using nvm or n to handle different node versions!

To start documentation site locally you'd need to install dependencies from the main package and also dependencies from the docs subproject:

git clone
npm install
cd docs/
npm install 
npm start

Local documentation will be available at http://localhost:8081/


This project is licensed under the terms of the MIT license.

react-toolbox 相关推荐