bulma vs evergreen-ui vs grommet vs react-bootstrap vs reactstrap vs semantic-ui-react
前端 UI 库架构选型:CSS 框架与组件库的深度对比
bulmaevergreen-uigrommetreact-bootstrapreactstrapsemantic-ui-react类似的npm包:

前端 UI 库架构选型:CSS 框架与组件库的深度对比

bulma 是一个纯 CSS 框架,需要手动在 React 中编写类名;evergreen-uigrommet 是面向企业级应用的全功能 React 组件库,强调设计系统和无障碍访问;react-bootstrapreactstrap 是 Bootstrap 的 React 封装,依赖 Bootstrap CSS;semantic-ui-react 是 Semantic UI 的官方 React 集成,但底层 CSS 库维护状态存疑。这些库代表了从底层样式控制到高度封装组件的不同抽象层级。

npm下载趋势

3 年

GitHub Stars 排名

统计详情

npm包名称
下载量
Stars
大小
Issues
发布时间
License
bulma050,0706.97 MB5211 年前MIT
evergreen-ui012,4366.75 MB803 年前MIT
grommet08,3559.19 MB4161 个月前Apache-2.0
react-bootstrap022,6491.48 MB2091 年前MIT
reactstrap010,5342.22 MB3232 年前MIT
semantic-ui-react013,2422.9 MB2392 年前MIT

前端 UI 库架构选型:CSS 框架与组件库的深度对比

在 React 生态系统中,选择 UI 库不仅仅是选择一套好看的样式,更是选择一种开发模式和架构约束。bulmaevergreen-uigrommetreact-bootstrapreactstrapsemantic-ui-react 代表了三种不同的技术路线:纯 CSS 框架、通用组件库和企业级设计系统。本文将从架构集成、样式定制、组件 API 和维护风险四个维度进行深度剖析。

🏗️ 架构集成模式:类名控制 vs 组件封装

这是最根本的区别。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-bootstrapreactstrap 主要依赖 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-bootstrapreactstrap 提供标准的表单组组件,与 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 仍可使用,但建议避免在新项目中使用,转而考虑 grommetevergreen-ui

📊 核心特性对比表

特性bulmaevergreen-uigrommetreact-bootstrapreactstrapsemantic-ui-react
类型CSS 框架React 组件库React 组件库React 组件库React 组件库React 组件库
依赖ReactReactBootstrap CSSBootstrap CSSSemantic 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-uigrommet 提供了更好的长期可维护性和开发体验;而对于 Bootstrap 生态的忠实用户,react-bootstrap 是唯一推荐的选择。

如何选择: bulma vs evergreen-ui vs grommet vs react-bootstrap vs reactstrap vs semantic-ui-react

  • bulma:

    如果你需要极致的样式控制权,且团队愿意手动管理 className,选择 bulma。它适合需要高度定制设计、不希望被组件库默认样式束缚的项目,但开发效率低于组件库。

  • evergreen-ui:

    如果你正在构建企业级后台或 SaaS 应用,且需要一套开箱即用、设计一致的系统,选择 evergreen-ui。它在主题定制和组件一致性方面表现出色,适合中大型团队。

  • grommet:

    如果你的项目对无障碍访问(a11y)有严格要求,或者需要响应式布局的强大支持,选择 grommet。它由 HPE 维护,适合注重可访问性和模块化架构的应用。

  • react-bootstrap:

    如果你熟悉 Bootstrap 生态,且希望用 React 的方式使用它(避免 jQuery 依赖),选择 react-bootstrap。它是 Bootstrap 5 的首选 React 实现,社区活跃,迁移成本低。

  • reactstrap:

    如果你维护的是旧版 Bootstrap 4 项目,或者偏好更接近原始 Bootstrap 类名的 API 风格,可以选择 reactstrap。但在新项目中,react-bootstrap 通常是更优的 Bootstrap 方案。

  • semantic-ui-react:

    不建议在新项目中使用 semantic-ui-react。虽然 API 设计优雅,但底层 Semantic UI 已停止维护,存在长期风险。建议评估 grommetevergreen-ui 作为替代。

bulma的README

Bulma

Bulma is a modern CSS framework based on Flexbox.

Github npm npm Awesome Join the chat at https://gitter.im/jgthms/bulma Build Status

Bulma: a Flexbox CSS framework

Quick install

Bulma is constantly in development! Try it out now:

NPM

npm install bulma

or

Yarn

yarn add bulma

Bower

bower install bulma

Import

After installation, you can import the CSS file into your project using this snippet:

@import 'bulma/css/bulma.css'

CDN

https://www.jsdelivr.com/package/npm/bulma

Feel free to raise an issue or submit a pull request.

CSS only

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.

Browser Support

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:

  • Chrome
  • Edge
  • Firefox
  • Opera
  • Safari

Internet Explorer (10+) is only partially supported.

Documentation

The documentation resides in the docs directory, and is built with the Ruby-based Jekyll tool.

Browse the online documentation here.

Related projects

ProjectDescription
Bulma with Attribute ModulesAdds support for attribute-based selectors
Bulma with RailsIntegrates Bulma with the rails asset pipeline
BulmaRazorA lightweight component library based on Bulma and Blazor.
Vue Admin (dead)Vue Admin framework powered by Bulma
BulmaswatchFree themes for Bulma
Goldfish (read-only)Vault UI with Bulma, Golang, and Vue Admin
ember-bulmaEmber addon providing a collection of UI components for Bulma
BloomerA set of React components for Bulma
React-bulmaReact.js components for Bulma
BuefyLightweight UI components for Vue.js based on Bulma
vue-bulma-componentsBulma components for Vue.js with straightforward syntax
BulmaJSJavascript integration for Bulma. Written in ES6 with a data-* API
Bulma-modal-fxA set of modal window effects with CSS transitions and animations for Bulma
Bulma StylusUp-to-date 1:1 translation to Stylus
Bulma.styl (read-only)1:1 Stylus translation of Bulma 0.6.11
elm-bulmaBulma + Elm
elm-bulma-classesBulma classes prepared for usage with Elm
Bulma CustomizerBulma Customizer – Create your own bespoke Bulma build
FulmaWrapper around Bulma for fable-react
Laravel EnsoSPA Admin Panel built with Bulma, VueJS and Laravel
Django BulmaIntegrates Bulma with Django
Bulma TemplatesFree Templates for Bulma
React Bulma ComponentsAnother React wrap on React for Bulma.io
purescript-bulmaPureScript bindings for Bulma
Vue DatatableBulma themed datatable based on Vue, Laravel & JSON templates
bulma-fluentFluent Design Theme for Bulma inspired by Microsoft’s Fluent Design System
csskrt-csskrtAutomatically add Bulma classes to HTML files
bulma-pagination-reactBulma pagination as a react component
bulma-helpersFunctional / Atomic CSS classes for Bulma
bulma-swatch-hookBulma swatches as a react hook and a component
BulmaWP (read-only)Starter WordPress theme for Bulma
RalmaStateless Ractive.js Components for Bulma
Django Simple BulmaLightweight integration of Bulma and Bulma-Extensions for your Django app
rbxComprehensive React UI Framework written in TypeScript
Awesome Bulma TemplatesFree real-world Templates built with Bulma
TrunxSuper Saiyan React components, son of awesome Bulma
@aybolit/bulmaWeb Components library inspired by Bulma and Bulma-extensions
DrulmaDrupal theme for Bulma.
BulrushA Bulma-based Python Pelican blog theme
Bulma Variable ExportAccess Bulma Variables in Javascript/Typescript in project using Webpack
BulmilAn agnostic UI components library based on Web Components, made with Bulma & Stencil.
Svelte Bulma ComponentsLibrary of UI components to be used in Svelte.js or standalone.
Bulma Nunjucks StarterkitStarterkit for Nunjucks with Bulma.
Bulma-SocialSocial Buttons and Colors for Bulma
DivjoyReact codebase generator with Bulma templates
BlazoriseBlazor component library with the support for Bulma CSS framework
Oruga-BulmaBulma theme for Oruga UI
@bulvar/bulmaBulma with CSS Variables support
@angular-bulmaAngular directives and components to use in your Bulma projects
Bulma CSS Class CompletionCSS class name completion for the HTML class attribute based on Bulma CSS classes.
Crispy-BulmaBulma template pack for django-crispy-forms
ManifestManifest is a lightweight Backend-as-a-Service with essential features: DB, Admin panel, API, JS SDK
Reactive BulmaA component library based on React, Bulma, Typescript and Rollup

Browser testing via

Copyright and license Github

Code copyright 2023 Jeremy Thomas. Code released under the MIT license.