daisyUI 将组件类名添加到 Tailwind CSS 中,
因此您可以制作美丽的网站 比以往更快。
在Tailwind CSS项目中,您需要为每个元素编写实用程序类名。数千个类名仅用于为最基本的元素定义样式。
对每个元素,每个页面,每个项目,
一遍又一遍…
更清晰,更快速,更干净,更容易维护
// 样式化一个简单的按钮
<button class="">
Tailwind Button
</button>
写更少的类名
使用组件类名
使用 Tailwind CSS 工具类修改它们。
<div class="w-80 rounded-2xl bg-gray-100">
<div class="flex flex-col gap-2 p-8">
<input placeholder="Email" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 focus:outline-none focus:ring-2 focus:ring-gray-700 focus:ring-offset-2 focus:ring-offset-gray-100" />
<label class="flex cursor-pointer items-center justify-between p-1">
接受使用条款
<div class="relative inline-block">
<input type="checkbox" class="peer h-6 w-12 cursor-pointer appearance-none rounded-full border border-gray-300 bg-white checked:border-gray-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2" />
<span class="pointer-events-none absolute start-1 top-1 block h-4 w-4 rounded-full bg-gray-400 transition-all duration-200 peer-checked:start-7 peer-checked:bg-gray-900"></span>
</div>
</label>
<label class="flex cursor-pointer items-center justify-between p-1">
提交到新闻通讯
<div class="relative inline-block">
<input type="checkbox" class="peer h-6 w-12 cursor-pointer appearance-none rounded-full border border-gray-300 bg-white checked:border-gray-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2" />
<span class="pointer-events-none absolute start-1 top-1 block h-4 w-4 rounded-full bg-gray-400 transition-all duration-200 peer-checked:start-7 peer-checked:bg-gray-900"></span>
</div>
</label>
<button class="inline-block cursor-pointer rounded-md bg-gray-700 px-4 py-3.5 text-center text-sm font-semibold uppercase text-white transition duration-200 ease-in-out hover:bg-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-700 focus-visible:ring-offset-2 active:scale-95">保存</button>
</div>
</div>
<a class="btn btn-primary">Button</a>
<a class="btn btn-primary rounded-full">Button</a>
daisyUI 是 Tailwind CSS 的插件。它适用于所有 JS 框架,不需要 JS 捆绑文件。
将 daisyUI 作为 dev 依赖项安装,并像任何其他 Tailwind CSS 类名一样使用类名。