Use Tailwind CSS and daisyUI with HTMX without class-heavy fragments
HTMX keeps interaction in HTML attributes. Tailwind CSS pairs well with that because it also keeps styling in the markup. You can build server-rendered fragments that carry both behavior and presentation without a client framework.
That directness is useful, especially for forms, filters, tables, and inline updates. A fragment can return from the server ready to display and ready to respond to the next interaction.
The trouble is density. hx-* attributes already add meaning to the markup. Long Tailwind CSS class strings beside them can make fragments hard to scan.
An HTMX button may include a URL, target, swap strategy, indicator, disabled state, and accessibility text. Add a long utility chain and the element becomes hard to edit.
LLMs also spend tokens on both sets of attributes. If the goal is to change server interaction, repeated utility classes become expensive background noise.
daisyUI shortens repeated UI classes while preserving the HTML-first model.
: class="btn btn-primary" is easier to read beside hx-post and hx-target.
Works with swaps: daisyUI has no JavaScript binding layer, so HTMX can replace fragments freely.
: alert, card, table, modal, and loading cover common server-rendered UI.
Tailwind CSS remains precise: Add utilities for one-off layout and responsive behavior.
HTMX keeps behavior declarative. daisyUI makes Tailwind CSS less noisy in the HTML that carries it.
The HTMX guide uses Tailwind CSS CLI and daisyUI as Node dependencies. Add @import "tailwindcss" and @plugin "daisyui" to your CSS file, build it, and link the generated CSS from your HTML.
For the exact commands, see How to install daisyUI with HTMX.
Used by engineers at