bootstrap、material-ui(现为 @mui/material)和 semantic-ui-react 都是用于构建 Web 用户界面的流行 UI 库,但它们在设计理念、技术实现和集成方式上有显著差异。bootstrap 是一个基于 CSS 的通用框架,最初为响应式网页设计而生,支持原生 HTML 和多种前端框架;material-ui 是专为 React 设计的组件库,完整实现了 Google 的 Material Design 规范;semantic-ui-react 则是 Semantic UI 的官方 React 封装,强调语义化命名和声明式 API。三者都提供按钮、表单、导航等基础组件,但在主题定制、状态管理、无障碍支持和开发体验上各有侧重。
在构建现代 Web 应用时,UI 库的选择直接影响开发效率、可维护性和用户体验。bootstrap、material-ui(现发布为 @mui/material)和 semantic-ui-react 是三个广为人知的选项,但它们在架构理念、技术栈适配和长期维护性上存在根本差异。本文将从真实工程角度出发,通过代码示例和关键特性对比,帮助你做出明智的技术决策。
bootstrap:CSS 优先,JS 为辅bootstrap 本质上是一个 CSS 框架,其核心是预定义的类名系统(如 .btn, .card)。在 React 项目中,通常只引入 CSS 文件,组件逻辑由开发者自行实现。
// bootstrap in React: 手动管理状态
import 'bootstrap/dist/css/bootstrap.min.css';
function MyModal() {
const [show, setShow] = useState(false);
return (
<>
<button className="btn btn-primary" onClick={() => setShow(true)}>
打开弹窗
</button>
{show && (
<div className="modal show d-block">
<div className="modal-dialog">
<div className="modal-content">
<div className="modal-header">
<h5>标题</h5>
<button type="button" className="btn-close" onClick={() => setShow(false)} />
</div>
</div>
</div>
</div>
)}
</>
);
}
⚠️ 注意:Bootstrap 的原生 JavaScript 插件(如 Modal、Tooltip)依赖 jQuery,不能直接在 React 中使用。若需交互功能,必须用 React 状态重写逻辑,或引入第三方封装(如
react-bootstrap)。
material-ui:React 原生组件material-ui(现为 @mui/material)提供完整的 React 组件,所有交互逻辑内置于组件内部,与 React 生命周期无缝集成。
// @mui/material: 声明式 API
import { Button, Modal, Box } from '@mui/material';
function MyModal() {
const [open, setOpen] = useState(false);
return (
<>
<Button variant="contained" onClick={() => setOpen(true)}>
打开弹窗
</Button>
<Modal open={open} onClose={() => setOpen(false)}>
<Box sx={{ p: 3, bgcolor: 'background.paper' }}>
<h2>标题</h2>
</Box>
</Modal>
</>
);
}
组件通过 props 控制行为(如 open、onClose),无需手动操作 DOM 或管理复杂状态。
semantic-ui-react:语义化 JSX,但已停止维护semantic-ui-react 提供语义化的 React 组件,API 设计直观(如 <Button primary>)。然而,根据其 GitHub 仓库 和 npm 页面,该项目自 2020 年起已归档,不再接受新功能或重大更新。
// semantic-ui-react: 语义化写法(仅作参考,不推荐新项目使用)
import { Button, Modal } from 'semantic-ui-react';
function MyModal() {
const [open, setOpen] = useState(false);
return (
<>
<Button primary onClick={() => setOpen(true)}>
打开弹窗
</Button>
<Modal open={open} onClose={() => setOpen(false)}>
<Modal.Header>标题</Modal.Header>
</Modal>
</>
);
}
❗ 重要提示:由于
semantic-ui-react已停止维护,不应在新项目中采用。现有项目应制定迁移计划。
bootstrap:Sass 变量覆盖通过覆盖 Sass 变量自定义主题:
// custom.scss
$primary: #ff6b6b;
@import '~bootstrap/scss/bootstrap';
但深度定制(如修改组件结构)需重写 CSS,容易与未来版本冲突。
material-ui:基于 CSS-in-JS 的主题系统提供强大的 createTheme API,支持全局或局部主题覆盖:
import { ThemeProvider, createTheme } from '@mui/material/styles';
const theme = createTheme({
palette: {
primary: { main: '#ff6b6b' }
},
components: {
MuiButton: {
styleOverrides: {
root: { borderRadius: 8 }
}
}
}
});
function App() {
return (
<ThemeProvider theme={theme}>
{/* 子组件自动继承主题 */}
</ThemeProvider>
);
}
主题配置集中、类型安全,且支持动态切换(如暗色模式)。
semantic-ui-react:静态主题文件需通过 Gulp 编译自定义主题文件,流程繁琐且与现代构建工具(如 Vite、Webpack 5)集成困难。由于项目已停止维护,主题工具链可能无法兼容新环境。
bootstrap:基础组件满足 WCAG 2.1 AA 标准,但需开发者手动添加 ARIA 属性(如 Modal 的 aria-labelledby)。material-ui:所有组件内置完整 ARIA 支持,并通过自动化测试验证。同时提供 @mui/material/locale 包支持多语言日期、数字格式。semantic-ui-react:早期版本存在无障碍缺陷,且因停止维护,未跟进最新标准。bootstrap:无官方 TypeScript 类型定义(社区维护的 @types/bootstrap 仅覆盖 CSS 类名,不包含 JS 插件)。material-ui:完整 TypeScript 支持,所有 props 和主题配置均有精确类型提示。semantic-ui-react:提供 TypeScript 定义,但因停止更新,可能与新版 React 或 TypeScript 不兼容。| 特性 | bootstrap | material-ui (@mui/material) | semantic-ui-react |
|---|---|---|---|
| 维护状态 | ✅ 活跃维护 | ✅ 活跃维护 | ❌ 已停止维护(2020 年起) |
| React 集成 | ❌ 仅 CSS,需手动实现交互 | ✅ 原生 React 组件 | ✅ React 组件(但已过时) |
| 主题定制 | ⚠️ Sass 变量覆盖 | ✅ 强大的 CSS-in-JS 主题系统 | ⚠️ 静态主题文件(难维护) |
| 无障碍支持 | ⚠️ 基础支持,需手动增强 | ✅ 内置完整 ARIA | ⚠️ 早期版本有缺陷 |
| TypeScript | ⚠️ 社区类型(不完整) | ✅ 官方完整支持 | ⚠️ 类型定义可能过时 |
| 适用场景 | 跨框架项目、静态页面、快速原型 | React 企业应用、高 UX 要求产品 | 不推荐新项目使用 |
material-ui(@mui/material),它提供现代化的开发体验、完善的无障碍支持和可持续的维护。bootstrap 仍是可靠选择,但避免使用其原生 JS 插件。semantic-ui-react 项目:尽快评估迁移到 material-ui 或其他活跃库(如 Chakra UI)。UI 库不仅是样式工具,更是应用架构的一部分。选择一个活跃维护、与技术栈深度集成的方案,能显著降低长期维护成本。
选择 bootstrap 如果你的项目需要快速搭建跨框架(甚至无框架)的响应式页面,或团队中包含非 React 开发者。它适合内容型网站、营销落地页或对设计一致性要求不高但需快速交付的场景。注意:在 React 项目中使用时,需额外处理 JavaScript 插件的交互逻辑(如 Modal、Dropdown),因为其原生 JS 依赖 jQuery,与 React 的状态管理模型不兼容。
选择 material-ui(即 @mui/material)如果你的项目基于 React 且希望遵循 Material Design 规范,或需要深度主题定制、完善的 TypeScript 支持和活跃的社区生态。它内置了强大的主题系统、无障碍支持和性能优化(如虚拟滚动、懒加载),适合构建复杂的企业级应用、管理后台或对用户体验有较高要求的产品。
选择 semantic-ui-react 如果你偏好语义化的 JSX 写法(如 <Button primary> 而非 <button className='ui primary button'>)且希望保留 Semantic UI 的视觉风格。但需注意:该库自 2020 年起已停止积极维护,GitHub 仓库归档,npm 包标记为只读。因此,不建议在新项目中使用,应优先考虑仍在维护的替代方案。
Sleek, intuitive, and powerful front-end framework for faster and easier web development.
Explore Bootstrap docs »
Report bug
·
Request feature
·
Blog
Our default branch is for development of our Bootstrap 5 release. Head to the v4-dev branch to view the readme, documentation, and source code for Bootstrap 4.
Several quick start options are available:
git clone https://github.com/twbs/bootstrap.gitnpm install bootstrap@v5.3.8yarn add bootstrap@v5.3.8bun add bootstrap@v5.3.8composer require twbs/bootstrap:5.3.8Install-Package bootstrap Sass: Install-Package bootstrap.sassRead the Getting started page for information on the framework contents, templates, examples, and more.
Within the download you’ll find the following directories and files, logically grouping common assets and providing both compiled and minified variations.
bootstrap/
├── css/
│ ├── bootstrap-grid.css
│ ├── bootstrap-grid.css.map
│ ├── bootstrap-grid.min.css
│ ├── bootstrap-grid.min.css.map
│ ├── bootstrap-grid.rtl.css
│ ├── bootstrap-grid.rtl.css.map
│ ├── bootstrap-grid.rtl.min.css
│ ├── bootstrap-grid.rtl.min.css.map
│ ├── bootstrap-reboot.css
│ ├── bootstrap-reboot.css.map
│ ├── bootstrap-reboot.min.css
│ ├── bootstrap-reboot.min.css.map
│ ├── bootstrap-reboot.rtl.css
│ ├── bootstrap-reboot.rtl.css.map
│ ├── bootstrap-reboot.rtl.min.css
│ ├── bootstrap-reboot.rtl.min.css.map
│ ├── bootstrap-utilities.css
│ ├── bootstrap-utilities.css.map
│ ├── bootstrap-utilities.min.css
│ ├── bootstrap-utilities.min.css.map
│ ├── bootstrap-utilities.rtl.css
│ ├── bootstrap-utilities.rtl.css.map
│ ├── bootstrap-utilities.rtl.min.css
│ ├── bootstrap-utilities.rtl.min.css.map
│ ├── bootstrap.css
│ ├── bootstrap.css.map
│ ├── bootstrap.min.css
│ ├── bootstrap.min.css.map
│ ├── bootstrap.rtl.css
│ ├── bootstrap.rtl.css.map
│ ├── bootstrap.rtl.min.css
│ └── bootstrap.rtl.min.css.map
└── js/
├── bootstrap.bundle.js
├── bootstrap.bundle.js.map
├── bootstrap.bundle.min.js
├── bootstrap.bundle.min.js.map
├── bootstrap.esm.js
├── bootstrap.esm.js.map
├── bootstrap.esm.min.js
├── bootstrap.esm.min.js.map
├── bootstrap.js
├── bootstrap.js.map
├── bootstrap.min.js
└── bootstrap.min.js.map
We provide compiled CSS and JS (bootstrap.*), as well as compiled and minified CSS and JS (bootstrap.min.*). Source maps (bootstrap.*.map) are available for use with certain browsers’ developer tools. Bundled JS files (bootstrap.bundle.js and minified bootstrap.bundle.min.js) include Popper.
Have a bug or a feature request? Please first read the issue guidelines and search for existing and closed issues. If your problem or idea is not addressed yet, please open a new issue.
Bootstrap’s documentation, included in this repo in the root directory, is built with Astro and publicly hosted on GitHub Pages at https://getbootstrap.com/. The docs may also be run locally.
Documentation search is powered by Algolia's DocSearch.
npm install to install the Node.js dependencies, including Astro (the site builder).npm run test (or a specific npm script) to rebuild distributed CSS and JavaScript files, as well as our docs assets./bootstrap directory, run npm run docs-serve in the command line.Learn more about using Astro by reading its documentation.
You can find all our previous releases docs on https://getbootstrap.com/docs/versions/.
Previous releases and their documentation are also available for download.
Please read through our contributing guidelines. Included are directions for opening issues, coding standards, and notes on development.
Moreover, if your pull request contains JavaScript patches or features, you must include relevant unit tests. All HTML and CSS should conform to the Code Guide, maintained by Mark Otto.
Editor preferences are available in the editor config for easy use in common text editors. Read more and download plugins at https://editorconfig.org/.
Get updates on Bootstrap’s development and chat with the project maintainers and community members.
irc.libera.chat server, in the #bootstrap channel.bootstrap-5).bootstrap on packages which modify or add to the functionality of Bootstrap when distributing through npm or similar delivery mechanisms for maximum discoverability.For transparency into our release cycle and in striving to maintain backward compatibility, Bootstrap is maintained under the Semantic Versioning guidelines. Sometimes we screw up, but we adhere to those rules whenever possible.
See the Releases section of our GitHub project for changelogs for each release version of Bootstrap. Release announcement posts on the official Bootstrap blog contain summaries of the most noteworthy changes made in each release.
Mark Otto
Jacob Thornton
Thanks to BrowserStack for providing the infrastructure that allows us to test in real browsers!
Thanks to Netlify for providing us with Deploy Previews!
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]
Thank you to all our backers! 🙏 [Become a backer]
Code and documentation copyright 2011-2025 the Bootstrap Authors. Code released under the MIT License. Docs released under Creative Commons.