bootstrap-vue、foundation-sites、material-ui、react-bootstrap は、Web アプリケーションの UI 構築を加速するための代表的なライブラリです。material-ui と react-bootstrap は React 専用のコンポーネントライブラリであり、それぞれ Material Design と Bootstrap のデザインシステムをコンポーネントとして提供します。bootstrap-vue は Vue.js 向けに Bootstrap を実装していますが、Vue 2 向けが主流であり Vue 3 への移行には注意が必要です。foundation-sites はフレームワークに依存しない CSS フレームワークであり、レスポンシブグリッドと基本的な UI パターンを提供しますが、他の 3 つに比べるとモダンな JS フレームワークとの統合性は低めです。これらはプロジェクトの技術スタック(React か Vue か、あるいはフレームワークフリーか)とデザイン要件によって選択が分かれます。
Web アプリケーションの開発において、UI フレームワークの選定はプロジェクトの長期メンテナンス性と開発速度に直結する重要な決定です。bootstrap-vue、foundation-sites、material-ui、react-bootstrap はいずれも歴史があり広く使われてきましたが、その技術的アプローチと対象とするスタックは大きく異なります。ここでは、実務的な観点からこれらを比較分析します。
ライブラリを選ぶ際、最初に確認すべきは使用している JS フレームワークとの親和性です。
material-ui は React 専用に設計されています。
// material-ui: React 専用コンポーネント
import Button from '@mui/material/Button';
function MyComponent() {
return <Button variant="contained">Hello World</Button>;
}
react-bootstrap も React 専用に設計されています。
// react-bootstrap: React 専用コンポーネント
import Button from 'react-bootstrap/Button';
function MyComponent() {
return <Button variant="primary">Hello World</Button>;
}
bootstrap-vue は Vue.js 専用に設計されています。
bootstrap-vue-next として別プロジェクトになっています。<!-- bootstrap-vue: Vue 専用コンポーネント -->
<template>
<b-button variant="primary">Hello World</b-button>
</template>
foundation-sites はフレームワークに依存しません。
<!-- foundation-sites: 標準 HTML/CSS -->
<button class="button primary">Hello World</button>
デザインの変更やテーマ適用のしやすさは、プロジェクトの見た目を決定づけます。
material-ui は JS 内でテーマを定義します。
ThemeProvider を使用して、色やタイポグラフィを一元管理できます。sx プロップや styled 関数で個別コンポーネントのスタイルを上書き可能です。// material-ui: テーマと sx プロップ
import { ThemeProvider, createTheme } from '@mui/material/styles';
import Box from '@mui/material/Box';
const theme = createTheme({ palette: { primary: { main: '#ff0000' } } });
// 使用例
<Box sx={{ color: 'primary.main' }}>Themed Text</Box>
react-bootstrap は従来の CSS クラスと併用します。
className プロップを渡して追加スタイルを適用します。// react-bootstrap: className での拡張
import Button from 'react-bootstrap/Button';
// 追加の CSS クラスを適用
<Button variant="primary" className="custom-btn">Styled</Button>
bootstrap-vue も CSS クラスベースです。
<!-- bootstrap-vue: クラスバインディング -->
<template>
<b-button :class="{ 'active': isActive }">Toggle</b-button>
</template>
foundation-sites は Sass 変数によるカスタマイズが中心です。
settings.scss ファイルでグローバルなデザイントークンを定義します。// foundation-sites: Sass 設定
$primary-color: #ff0000;
@import 'foundation';
長期プロジェクトでは、ライブラリのメンテナンス状況が死活問題になります。
material-ui は非常に活発にメンテナンスされています。
react-bootstrap も安定してメンテナンスされています。
bootstrap-vue は注意が必要です。
bootstrap-vue は Vue 2 向けであり、Vue 2 のサポート終了に伴い実質的に開発が停滞しています。bootstrap-vue-next を使う必要がありますが、エコシステムが分断されています。foundation-sites はメンテナンスが続いていますが、勢いは緩やかです。
異なるアプローチを取っていますが、共通する目的と機能もあります。
// material-ui: Grid コンポーネント
<Grid container spacing={2}>
<Grid item xs={6}>Left</Grid>
<Grid item xs={6}>Right</Grid>
</Grid>
// react-bootstrap: Row/Col コンポーネント
<Row>
<Col xs={6}>Left</Col>
<Col xs={6}>Right</Col>
</Row>
<!-- bootstrap-vue: b-container/b-row/b-col -->
<b-container fluid>
<b-row>
<b-col cols="6">Left</b-col>
<b-col cols="6">Right</b-col>
</b-row>
</b-container>
<!-- foundation-sites: grid-x/grid-cell -->
<div class="grid-x grid-padding-x">
<div class="cell small-6">Left</div>
<div class="cell small-6">Right</div>
</div>
material-ui は特にこの点を重視しています。| 特徴 | material-ui | react-bootstrap | bootstrap-vue | foundation-sites |
|---|---|---|---|---|
| 主要フレームワーク | React | React | Vue (2/3) | フレームワークフリー |
| スタイリング | CSS-in-JS (Emotion) | Bootstrap CSS (Sass) | Bootstrap CSS (Sass) | Foundation CSS (Sass) |
| デザイン体系 | Material Design | Bootstrap | Bootstrap | Foundation |
| カスタマイズ | テーマオブジェクト | Sass 変数 | Sass 変数 | Sass 設定ファイル |
| メンテナンス | 活発 | 安定 | 要注意 (Vue 2) | 安定 (緩やか) |
material-ui は、React を使っており、モダンで統一されたデザインシステムを必要とする場合に最適です。特に大規模なエンタープライズアプリケーションや、カスタマイズされたテーマを扱うプロジェクトに適しています。
react-bootstrap は、React を使っており、Bootstrap の見た目や既存の資産を活かしたい場合に最適です。CSS クラスでの制御を好むチームや、Bootstrap のエコシステム(テンプレートなど)を利用したい場合に選ばれます。
bootstrap-vue は、Vue 2 のレガシープロジェクトを維持する場合に限ります。新規で Vue を使う場合は、bootstrap-vue-next や他の Vue 専用ライブラリ(Vuetify など)を検討すべきです。
foundation-sites は、特定の JS フレームワークに依存したくない場合や、CSS 設計に深い関与が必要な場合に適しています。ただし、モダンな SPA 開発においては、React や Vue 用のコンポーネントライブラリを使う方が生産性が高いことが多いです。
最終的なアドバイス:技術スタック(React か Vue か)が最初の決定要因です。その上で、デザイン要件(Material か Bootstrap か)と、カスタマイズの自由度(CSS-in-JS か 伝統的 CSS か)で選択を確定させましょう。
React プロジェクトで、Google の Material Design に準拠した一貫性のある UI を迅速に構築したい場合に最適です。テーマカスタマイズ機能が強く、エンタープライズ向けのダッシュボードや複雑なフォームを持つアプリケーションに適しています。コンポーネントの品質とアクセシビリティが高く、大規模なエコシステムを必要とする場合に選択されます。
Vue 2 で構築された既存プロジェクトを維持する場合に選択します。ただし、Vue 2 はサポートが終了しているため、新規プロジェクトでの採用は避けるべきです。Vue 3 を使用したい場合は、後継である bootstrap-vue-next の検討を強く推奨します。Bootstrap のデザイン体系を Vue で使いたい場合の伝統的な選択肢ですが、将来性の観点でリスクがあります。
特定の JS フレームワークに縛られず、CSS レベルで設計をコントロールしたい場合に選択します。jQuery や Vanilla JS との相性が良く、独自のデザインシステムを構築するベースとして適しています。React や Vue のコンポーネントライブラリのような豊富な機能は期待できませんが、軽量で柔軟なレイアウト構築には向いています。
React プロジェクトで、既存の Bootstrap デザインやカスタム CSS をそのまま活用したい場合に選択します。Bootstrap のクラス体系を理解しているチームにとって学習コストが低く、CSS 側での制御を維持しつつ React のコンポーネント機能を使いたい時に適しています。Material Design ではなく、伝統的な Web サイトのルックアンドフィールを維持したい時に選ばれます。
For how-to questions and other non-issues, please use StackOverflow instead of Github issues. There is a StackOverflow tag called "material-ui" that you can use to tag your questions.
Material-UI is a set of React components that implement Google's Material Design specification.
Check out our documentation site for live examples. It's still a work in progress, but hopefully you can see where we're headed.
Recently Updated? Please read the changelog, this README and the documentation before posting an issue.
We recommend that you get to know React before diving into material-ui. Material-UI is a set of React components, so understanding how React fits into web development is important.
(If you're not familiar with Node, or with the concept of Single Page Applications (SPAs), head over to the documentation website for a quick introduction before you read on.)
Material-UI is available as an npm package.
Stable channel
npm install material-ui
Pre-release channel
npm install material-ui@next
Please note that @next will only point to pre-releases; to get the latest stable release use @latest instead.
(not needed for versions 0.19.0 and higher)
Some components use react-tap-event-plugin to listen for touch events because onClick is not fast enough This dependency is temporary and will eventually go away. Until then, be sure to inject this plugin at the start of your app.
import injectTapEventPlugin from 'react-tap-event-plugin';
// Needed for onTouchTap
// http://stackoverflow.com/a/34015469/988941
injectTapEventPlugin();
Material-UI was designed with the Roboto font in mind. So be sure to include it in your project. Here are some instructions on how to do so.
Beginning with v0.15.0, Material-UI components require a theme to be provided. The quickest way to get up and running is by using the MuiThemeProvider to inject the theme into your application context. Following that, you can use any of the components as demonstrated in the documentation.
Here is a quick example to get you started:
./App.js
import React from 'react';
import ReactDOM from 'react-dom';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import MyAwesomeReactComponent from './MyAwesomeReactComponent';
const App = () => (
<MuiThemeProvider>
<MyAwesomeReactComponent />
</MuiThemeProvider>
);
ReactDOM.render(
<App />,
document.getElementById('app')
);
./MyAwesomeReactComponent.js
import React from 'react';
import RaisedButton from 'material-ui/RaisedButton';
const MyAwesomeReactComponent = () => (
<RaisedButton label="Default" />
);
export default MyAwesomeReactComponent;
Please refer to each component's documentation page to see how they should be imported.
We have implemented a default theme to render all Material-UI components. Styling components to your liking is simple and hassle-free. This can be achieved in the following two ways:
There are 2 projects that you can look at to get started. They can be found in the examples folder. These projects are basic examples that show how to consume material-ui components in your own project. The first project uses browserify for module bundling and gulp for JS task automation, while the second project uses webpack for module bundling and building.
The source code for this documentation site is also included in the repository. This is a slightly more complex project that also uses webpack, and contains examples of every material-ui component. Check out the docs folder for build instructions.
The future plans and high priority features and enhancements can be found in the ROADMAP.md file.
Material-UI came about from our love of React and Google's Material Design. We're currently using it on a project at Call-Em-All and plan on adding to it and making it better. If you'd like to help, check out the docs folder. We'd greatly appreciate any contribution you make. :)
Thank you to BrowserStack for providing the infrastructure that allows us to test material-ui in real browsers.
This project is licensed under the terms of the MIT license