Tailwind CSS 改变了前端开发者编写样式的方式,用”组合优于定制”的理念提升开发效率。
核心理念
- 实用优先:直接在 HTML 中使用类名,如
flex items-center gap-4 - 无需取名:告别 CSS 类名的命名烦恼
- 设计系统:内置统一的颜色、间距、字体等设计标记
- 按需生成:只打包使用到的样式,极小的产出体积
快速上手
<div class="flex items-center gap-4 p-6 bg-white rounded-xl shadow-lg">
<img class="w-12 h-12 rounded-full" src="avatar.jpg" />
<div>
<h3 class="text-lg font-semibold text-gray-900">标题</h3>
<p class="text-sm text-gray-500">描述文字</p>
</div>
</div>
生态工具
| 工具 | 说明 |
|---|---|
| Tailwind UI | 官方付费组件库 |
| Headless UI | 无样式交互组件 |
| Heroicons | 配套图标库 |
| daisyUI | 社区组件库 |