bulma 是一个纯 CSS 框架,需要手动在 React 中编写类名;evergreen-ui 和 grommet 是面向企业级应用的全功能 React 组件库,强调设计系统和无障碍访问;react-bootstrap 和 reactstrap 是 Bootstrap 的 React 封装,依赖 Bootstrap CSS;semantic-ui-react 是 Semantic UI 的官方 React 集成,但底层 CSS 库维护状态存疑。这些库代表了从底层样式控制到高度封装组件的不同抽象层级。
在 React 生态系统中,选择 UI 库不仅仅是选择一套好看的样式,更是选择一种开发模式和架构约束。bulma、evergreen-ui、grommet、react-bootstrap、reactstrap 和 semantic-ui-react 代表了三种不同的技术路线:纯 CSS 框架、通用组件库和企业级设计系统。本文将从架构集成、样式定制、组件 API 和维护风险四个维度进行深度剖析。
这是最根本的区别。bulma 仅提供 CSS 类,你需要自己在 JSX 中组合类名。其他五个库提供封装好的 React 组件,将样式逻辑隐藏在组件内部。
bulma 要求你手动管理类名字符串。这意味着更灵活,但也更容易出错(比如拼写错误)。
// bulma: 手动组合 CSS 类
<button className="button is-primary is-large">
点击我
</button>
evergreen-ui 提供高度封装的组件,通过 Props 控制样式变体。
// evergreen-ui: 组件化 API
import { Button } from 'evergreen-ui';
<Button appearance="primary" size="large">
点击我
</Button>
grommet 同样使用组件,但强调语义化和无障碍属性。
// grommet: 语义化组件
import { Button } from 'grommet';
<Button primary size="large" label="点击我" />
react-bootstrap 将 Bootstrap 的类名映射为组件 Props,去除了对 jQuery 的依赖。
// react-bootstrap: Bootstrap 的 React 实现
import { Button } from 'react-bootstrap';
<Button variant="primary" size="lg">
点击我
</Button>
reactstrap 的 API 与 react-bootstrap 非常相似,但实现细节略有不同。
// reactstrap: 另一种 Bootstrap 实现
import { Button } from 'reactstrap';
<Button color="primary" size="lg">
点击我
</Button>
semantic-ui-react 提供声明式 API,但底层依赖已停止更新的 CSS。
// semantic-ui-react: 声明式组件
import { Button } from 'semantic-ui-react';
<Button primary size="huge">
点击我
</Button>
当业务需求要求独特的品牌视觉时,主题系统的灵活性至关重要。
bulma 使用 Sass 变量进行定制。你需要在构建管道中覆盖默认变量。
// bulma: Sass 变量覆盖
$primary: #ff3860;
$family-primary: 'Helvetica Neue';
@import 'bulma';
evergreen-ui 拥有强大的主题引擎,支持运行时主题切换和细粒度配置。
// evergreen-ui: 主题配置对象
import { ThemeProvider, defaultTheme } from 'evergreen-ui';
const customTheme = {
...defaultTheme,
colors: { primary: '#ff3860' }
};
<ThemeProvider value={customTheme}>...</ThemeProvider>
grommet 使用 JSON 对象定义主题,支持嵌套和扩展。
// grommet: 主题对象
import { Grommet, ThemeType } from 'grommet';
const theme: ThemeType = {
button: { primary: { color: '#ff3860' } }
};
<Grommet theme={theme}>...</Grommet>
react-bootstrap 和 reactstrap 主要依赖 Bootstrap 的 Sass 变量或 CSS 覆盖,运行时主题能力较弱。
// react-bootstrap / reactstrap: Sass 定制
$primary: #ff3860;
@import 'bootstrap/scss/bootstrap';
semantic-ui-react 允许通过 LESS 变量定制,但配置过程较为繁琐。
// semantic-ui-react: LESS 变量
@primaryColor: #ff3860;
表单是 Web 应用的核心。组件库如何处理输入状态、验证和布局反映了其设计哲学。
bulma 没有表单组件,你需要自己编写结构。
// bulma: 纯 HTML 结构
<div className="field">
<label className="label">用户名</label>
<div className="control">
<input className="input" type="text" placeholder="输入用户名" />
</div>
</div>
evergreen-ui 提供带内置标签和验证样式的输入组件。
// evergreen-ui: 封装的 Input
import { TextInputField } from 'evergreen-ui';
<TextInputField label="用户名" placeholder="输入用户名" required />
grommet 将表单视为一组可组合的对象,支持复杂的验证逻辑。
// grommet: 组合式表单
import { Form, FormField, TextInput } from 'grommet';
<Form>
<FormField label="用户名" required>
<TextInput name="username" placeholder="输入用户名" />
</FormField>
</Form>
react-bootstrap 和 reactstrap 提供标准的表单组组件,与 Bootstrap 文档保持一致。
// react-bootstrap: 表单组
import { Form } from 'react-bootstrap';
<Form.Group controlId="username">
<Form.Label>用户名</Form.Label>
<Form.Control type="text" placeholder="输入用户名" />
</Form.Group>
// reactstrap: 表单组
import { FormGroup, Label, Input } from 'reactstrap';
<FormGroup>
<Label for="username">用户名</Label>
<Input id="username" placeholder="输入用户名" />
</FormGroup>
semantic-ui-react 使用简洁的声明式语法,但灵活性受限于底层 CSS。
// semantic-ui-react: 声明式表单
import { Form } from 'semantic-ui-react';
<Form>
<Form.Field label="用户名" control="input" placeholder="输入用户名" />
</Form>
这是架构决策中最关键的一环。使用一个停止维护的库会导致未来的安全漏洞和技术债务。
bulma: 维护良好,最近发布了 1.0 版本,专注于 CSS 稳定性。evergreen-ui: 由 Segment 维护,更新频繁,适合长期项目。grommet: 由 HPE 支持,企业级稳定性高,无障碍功能持续更新。react-bootstrap: 社区驱动,紧跟 Bootstrap 5 更新,是目前 Bootstrap 生态的首选。reactstrap: 更新频率低于 react-bootstrap,社区活跃度稍弱。semantic-ui-react: 高风险。底层 Semantic UI 仓库已归档,不再接受新功能。虽然 semantic-ui-react 仍可使用,但建议避免在新项目中使用,转而考虑 grommet 或 evergreen-ui。| 特性 | bulma | evergreen-ui | grommet | react-bootstrap | reactstrap | semantic-ui-react |
|---|---|---|---|---|---|---|
| 类型 | CSS 框架 | React 组件库 | React 组件库 | React 组件库 | React 组件库 | React 组件库 |
| 依赖 | 无 | React | React | Bootstrap CSS | Bootstrap CSS | Semantic CSS |
| 定制方式 | Sass 变量 | JS 主题对象 | JS 主题对象 | Sass/CSS 覆盖 | Sass/CSS 覆盖 | LESS 变量 |
| 无障碍支持 | 手动实现 | 内置支持 | 强内置支持 | 基础支持 | 基础支持 | 基础支持 |
| 维护状态 | ✅ 活跃 | ✅ 活跃 | ✅ 活跃 | ✅ 活跃 | ⚠️ 缓慢 | ❌ 底层已停止 |
选择 bulma:如果你想要一个轻量级的起点,并且希望完全控制 HTML 结构和 CSS 类名,不介意多写一些样板代码。适合设计驱动型项目。
选择 evergreen-ui:如果你需要快速构建功能丰富的企业级应用,且希望有一套统一的设计语言。它的主题系统非常适合需要多租户或白标化的 SaaS 产品。
选择 grommet:如果你的项目对无障碍访问(WCAG 标准)有严格要求,或者你需要一个模块化、可组合性极强的组件系统。适合政府、教育或大型企业内部系统。
选择 react-bootstrap:如果你团队熟悉 Bootstrap,或者需要利用现有的 Bootstrap 资源。它是迁移旧 jQuery/Bootstrap 项目到 React 的最佳路径。
避免 semantic-ui-react:尽管它的 API 很优雅,但底层技术的停滞是架构上的定时炸弹。对于新项目,请选择维护更积极的替代方案。
总结:没有最好的库,只有最适合的架构。对于大多数现代 React 应用,evergreen-ui 或 grommet 提供了更好的长期可维护性和开发体验;而对于 Bootstrap 生态的忠实用户,react-bootstrap 是唯一推荐的选择。
如果你需要极致的样式控制权,且团队愿意手动管理 className,选择 bulma。它适合需要高度定制设计、不希望被组件库默认样式束缚的项目,但开发效率低于组件库。
如果你正在构建企业级后台或 SaaS 应用,且需要一套开箱即用、设计一致的系统,选择 evergreen-ui。它在主题定制和组件一致性方面表现出色,适合中大型团队。
如果你的项目对无障碍访问(a11y)有严格要求,或者需要响应式布局的强大支持,选择 grommet。它由 HPE 维护,适合注重可访问性和模块化架构的应用。
如果你熟悉 Bootstrap 生态,且希望用 React 的方式使用它(避免 jQuery 依赖),选择 react-bootstrap。它是 Bootstrap 5 的首选 React 实现,社区活跃,迁移成本低。
如果你维护的是旧版 Bootstrap 4 项目,或者偏好更接近原始 Bootstrap 类名的 API 风格,可以选择 reactstrap。但在新项目中,react-bootstrap 通常是更优的 Bootstrap 方案。
不建议在新项目中使用 semantic-ui-react。虽然 API 设计优雅,但底层 Semantic UI 已停止维护,存在长期风险。建议评估 grommet 或 evergreen-ui 作为替代。
Bulma is a modern CSS framework based on Flexbox.
Bulma is constantly in development! Try it out now:
npm install bulma
or
yarn add bulma
bower install bulma
After installation, you can import the CSS file into your project using this snippet:
@import 'bulma/css/bulma.css'
https://www.jsdelivr.com/package/npm/bulma
Feel free to raise an issue or submit a pull request.
Bulma is a CSS framework. As such, the sole output is a single CSS file: bulma.css
You can either use that file, "out of the box", or download the Sass source files to customize the variables.
There is no JavaScript included. People generally want to use their own JS implementation (and usually already have one). Bulma can be considered "environment agnostic": it's just the style layer on top of the logic.
Bulma uses autoprefixer to make (most) Flexbox features compatible with earlier browser versions. According to Can I use, Bulma is compatible with recent versions of:
Internet Explorer (10+) is only partially supported.
The documentation resides in the docs directory, and is built with the Ruby-based Jekyll tool.
Browse the online documentation here.
| Project | Description |
|---|---|
| Bulma with Attribute Modules | Adds support for attribute-based selectors |
| Bulma with Rails | Integrates Bulma with the rails asset pipeline |
| BulmaRazor | A lightweight component library based on Bulma and Blazor. |
| Vue Admin (dead) | Vue Admin framework powered by Bulma |
| Bulmaswatch | Free themes for Bulma |
| Goldfish (read-only) | Vault UI with Bulma, Golang, and Vue Admin |
| ember-bulma | Ember addon providing a collection of UI components for Bulma |
| Bloomer | A set of React components for Bulma |
| React-bulma | React.js components for Bulma |
| Buefy | Lightweight UI components for Vue.js based on Bulma |
| vue-bulma-components | Bulma components for Vue.js with straightforward syntax |
| BulmaJS | Javascript integration for Bulma. Written in ES6 with a data-* API |
| Bulma-modal-fx | A set of modal window effects with CSS transitions and animations for Bulma |
| Bulma Stylus | Up-to-date 1:1 translation to Stylus |
| Bulma.styl (read-only) | 1:1 Stylus translation of Bulma 0.6.11 |
| elm-bulma | Bulma + Elm |
| elm-bulma-classes | Bulma classes prepared for usage with Elm |
| Bulma Customizer | Bulma Customizer – Create your own bespoke Bulma build |
| Fulma | Wrapper around Bulma for fable-react |
| Laravel Enso | SPA Admin Panel built with Bulma, VueJS and Laravel |
| Django Bulma | Integrates Bulma with Django |
| Bulma Templates | Free Templates for Bulma |
| React Bulma Components | Another React wrap on React for Bulma.io |
| purescript-bulma | PureScript bindings for Bulma |
| Vue Datatable | Bulma themed datatable based on Vue, Laravel & JSON templates |
| bulma-fluent | Fluent Design Theme for Bulma inspired by Microsoft’s Fluent Design System |
| csskrt-csskrt | Automatically add Bulma classes to HTML files |
| bulma-pagination-react | Bulma pagination as a react component |
| bulma-helpers | Functional / Atomic CSS classes for Bulma |
| bulma-swatch-hook | Bulma swatches as a react hook and a component |
| BulmaWP (read-only) | Starter WordPress theme for Bulma |
| Ralma | Stateless Ractive.js Components for Bulma |
| Django Simple Bulma | Lightweight integration of Bulma and Bulma-Extensions for your Django app |
| rbx | Comprehensive React UI Framework written in TypeScript |
| Awesome Bulma Templates | Free real-world Templates built with Bulma |
| Trunx | Super Saiyan React components, son of awesome Bulma |
| @aybolit/bulma | Web Components library inspired by Bulma and Bulma-extensions |
| Drulma | Drupal theme for Bulma. |
| Bulrush | A Bulma-based Python Pelican blog theme |
| Bulma Variable Export | Access Bulma Variables in Javascript/Typescript in project using Webpack |
| Bulmil | An agnostic UI components library based on Web Components, made with Bulma & Stencil. |
| Svelte Bulma Components | Library of UI components to be used in Svelte.js or standalone. |
| Bulma Nunjucks Starterkit | Starterkit for Nunjucks with Bulma. |
| Bulma-Social | Social Buttons and Colors for Bulma |
| Divjoy | React codebase generator with Bulma templates |
| Blazorise | Blazor component library with the support for Bulma CSS framework |
| Oruga-Bulma | Bulma theme for Oruga UI |
| @bulvar/bulma | Bulma with CSS Variables support |
| @angular-bulma | Angular directives and components to use in your Bulma projects |
| Bulma CSS Class Completion | CSS class name completion for the HTML class attribute based on Bulma CSS classes. |
| Crispy-Bulma | Bulma template pack for django-crispy-forms |
| Manifest | Manifest is a lightweight Backend-as-a-Service with essential features: DB, Admin panel, API, JS SDK |
| Reactive Bulma | A component library based on React, Bulma, Typescript and Rollup |
Code copyright 2023 Jeremy Thomas. Code released under the MIT license.