Skip to main content

主流 UI 组件库

现代前端开发中,使用 UI 组件库可以大大加快开发效率并提升界面一致性。本指南将介绍主流的 UI 库,并展示在 React、Vue、Angular 中如何快速引入使用。


🔝 常见主流 UI 库一览

名称适用框架特点
Ant DesignReact企业级后台系统,设计风格统一
Material UIReactGoogle Material Design 实现
Bootstrap所有经典 UI 库,兼容性强
Element PlusVue3简洁易用,适合中后台系统
PrimeNGAngular丰富组件,主题多样
Tailwind CSS所有原子化 CSS,轻便灵活

⚛️ 在 React 中使用 UI 库

npm install antd
import React from 'react';
import { Button } from 'antd';
import 'antd/dist/reset.css';

export default () => <Button type="primary">按钮</Button>;

🔶 在 Vue 中使用 UI 库

npm install element-plus
// main.js
import { createApp } from 'vue';
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import App from './App.vue';

createApp(App).use(ElementPlus).mount('#app');
<template>
<el-button type="primary">按钮</el-button>
</template>

🅰️ 在 Angular 中使用 UI 库

ng add @angular/material
<button mat-raised-button color="primary">按钮</button>

📦 Tips 与建议

tip

使用 UI 库时建议:

  • 按需引入,减小打包体积
  • 配合主题定制化
  • 避免组件样式冲突
如何实现 Ant Design 按需引入

使用 babel-plugin-import:

npm install babel-plugin-import --save-dev

.babelrc:

{
"plugins": [
[
"import",
{
"libraryName": "antd",
"style": "css"
}
]
]
}

✅ 总结

  • 常见 UI 库有 Ant Design、Material UI、Element Plus、PrimeNG、Tailwind 等;
  • 根据项目框架选择适合的库;
  • 注意配置样式、按需加载以及主题定制;
  • UI 库能极大提升开发效率和一致性。

📚 推荐链接