Daisyui Usage

作者 saadeghi9adbeaa25981无许可证42K 个星标收录于 2026年10月8日更新于 2026年10月8日仓库今天更新

Usage rules that you must use with daisyUI 5

AI 生成的概览

使用 daisyUI 5 组件类与 Tailwind CSS 工具类为 HTML 添加样式的规则。

功能
提供一组编号规则,说明如何把 daisyUI 5 类名应用到 HTML 元素上,涵盖组件、部件、修饰符、颜色、尺寸和变体类。它说明何时改用 Tailwind CSS 工具类、如何用 important 修饰符覆盖样式,以及如何通过 Tailwind 的 @utility 指令全局修改组件。文档还列出 daisyUI 工具类、CSS 变量和基础模块,并说明如何在插件配置中 include 或 exclude 模块。
适用场景
在编写或检查使用 daisyUI 5 的前端标记时使用,使类名与 Tailwind 回退方式符合该库的约定。在需要全局调整某个 daisyUI 组件样式,或配置插件加载哪些基础模块时也适用。
运行要求
需要一个使用 daisyUI 5 与 Tailwind CSS 的项目。不包含脚本、依赖包或凭据,仅为说明性指令。

daisyUI 5 usage rules

  1. To style an HTML element, add daisyUI class names to it. Add the necessary component class name. Also add the applicable part and modifier class names.
  2. If the current daisyUI classes cannot make a necessary change, use Tailwind CSS utility classes. For example, btn px-10 sets custom horizontal padding on a btn.
  3. If CSS specificity prevents a change to a daisyUI style, add ! to the end of the Tailwind utility. For example, btn bg-red-500! overrides the background color of a btn. Use this method only if other methods do not work. Do not use it frequently.
  4. If daisyUI does not have an applicable component, make a component with Tailwind CSS utilities.
  5. When you use Tailwind CSS flex or grid for a layout, add responsive utility prefixes.
  6. Use only current daisyUI class names or Tailwind CSS utility classes.
  7. If custom CSS is not necessary, do not write it. If possible, use daisyUI class names or Tailwind CSS utility classes.
  8. If you need placeholder images, use https://picsum.photos/200/300 with the necessary dimensions.
  9. If a custom font is not necessary, do not add one.
  10. If bg-base-100 text-base-content is not necessary, do not add it to the body.
  11. For design decisions, use the methods in the Refactoring UI book.
  12. If the user does not request a variant or color, use the default variant. For example, use btn for a button. If the user does not request that variant, do not use btn btn-primary.

Each daisyUI 5 class name is in one of these categories. These category names are for reference only. Do not use them in code.

  • component: The necessary component class.
  • part: A child part of a component.
  • style: Sets a specified style on a component or part.
  • behavior: Changes the behavior of a component or part.
  • color: Sets a specified color on a component or part.
  • size: Sets a specified size on a component or part.
  • placement: Sets a specified position for a component or part.
  • direction: Sets a specified direction for a component or part.
  • modifier: Changes the component or part in a specified way.
  • variant: A prefix for a utility class that applies styles in specified conditions. The syntax is variant:utility-class.

Change a component in CSS

Use the Tailwind @utility directive to change a daisyUI component globally:

css
@utility btn {  @apply rounded-full;}

daisyUI utilities and variables

  • You can use semantic colors with Tailwind color utilities and opacity modifiers. Examples are bg-primary, border-base-300, and text-base-content/60.
  • rounded-box, rounded-field, and rounded-selector use the radius tokens of the active theme.
  • glass applies the daisyUI glass effect.
  • Some components supply CSS variables for component-specific changes. Countdown uses --value and --digits. Radial progress uses --size and --thickness.

Base modules

daisyUI includes the properties, rootcolor, scrollbar, rootscrolllock, rootscrollgutter, and svg base modules. To exclude a module from the plugin configuration, use its module name:

css
@plugin "daisyui" {  exclude: rootscrollgutter;}

Use include or exclude for library modules. For visual changes, use Tailwind utilities or @utility.

来源与署名

来源:saadeghi/daisyui位于skills/daisyui/usage提交9adbeaa

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架