--- name: phoenix-tailwind-daisyui description: "Use when styling Phoenix 1.8 UI — Tailwind v4 app.css (@source, @plugin, no tailwind.config.js), dynamic classes, daisyUI themes/dark mode, core_components (<.input>, <.button>, <.icon>), Layouts.app, flash, accessibility. Not for LiveView forms/lifecycle or JS hooks (use phoenix-liveview-essentials)." --- # Phoenix UI: Tailwind v4, daisyUI and core_components > Verified against Phoenix 1.8, LiveView 1.2, Tailwind 4.3, daisyUI 5.5 — October 2026 ## RULES — Follow these with no exceptions 1. **Wrap every page in ``**, and pass `current_scope={@current_scope}` when the app has auth. In 1.8 the app layout is a function component that you call from the template; it is not applied automatically. It already renders the flash group, so don't render a second one. 2. **Tailwind is configured in `assets/css/app.css`.** There is no `tailwind.config.js`. Keep `@import "tailwindcss" source(none)`, and add an `@source` line for every directory outside `lib/my_app_web` that contains class names. Tailwind scans only the listed paths. 3. **Write every class name as a complete literal.** `"text-#{color}-500"` produces no CSS. Map values to full strings (`%{error: "badge-error"}`) or use function clauses. Safelist with `@source inline("...")` only when the values really come from data. 4. **Use daisyUI's semantic colors rather than raw palette colors.** Write `bg-base-100`, `text-base-content`, `btn-primary`, `text-error` and the `*-content` pairs, not `bg-white`, `text-gray-900` or `text-red-600`. The semantic colors switch with the light/dark theme; hard-coded colors don't. 5. **Use `core_components.ex` first, and extend it rather than writing one-off markup.** To get a new look, add a variant, an attr or a new component in that module, and keep its `attr`/`slot` declarations, including `values:` and `required:`. 6. **Passing `class` to `<.button>` or `<.input>` replaces the default classes; it doesn't add to them.** `<.button class="w-full">` loses `btn`. Pass the full class list (`class="btn btn-primary w-full"`) or add a variant. 7. **Icons are `<.icon name="hero-…">` with a literal name.** The suffixes are none (outline 24), `-solid`, `-mini` and `-micro`. `icon/1` accepts only `name` and `class`; any other attribute is a compile warning and isn't rendered. 8. **`<.button>` declares only `href navigate patch method download name value disabled`.** `type="button"` (which you need for a non-submitting button inside a form) is an "undefined attribute" warning, and that warning fails `mix precommit` (`compile --warnings-as-errors`). Add `type` to the button's `include:` list. 9. **Accessibility you add yourself:** a `label` on every `<.input>` (a placeholder is not a label), an `aria-label` on every icon-only button, ` """ end end ``` **Errors that screen readers announce.** The generated `<.input>` wraps the control in its `