-
Aside from alert-success class, all the other color class for alert not working for me. i try alert-warning, alert-error and alert-info but none of it display the correct color background. except alert-success. Please help me. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 6 replies
-
Make sure your class names are not half-string/half-variable. Use classname string as a whole. ❌ This doesn't work: <div class="alert-{{ error ? 'warning' : 'info' }}"></div> ✅ This works: <div class="{{ error ? 'alert-warning' : 'alert-info' }}"></div> Read more here: https://tailwindcss.com/docs/content-configuration#dynamic-class-names |
Beta Was this translation helpful? Give feedback.
-
Im sorry, i think the problem is in the way I build the css and js file with laravel mix. If i use CDN the styling will looks good, but if i switch to using the locally generated CSS file, the layout will be broken. can you give me an example on how to build the daisyUI and tailwind using laravel mix? |
Beta Was this translation helpful? Give feedback.
-
It doesn't matter what template language you're using. It's about how Tailwind CSS finds the class names inside your template files and generate CSS ONLY for the class names it finds. Using CDN is working for you because the CSS files is including ALL class names (whether you have the class names inside your templates or not) but if the locally generated CSS lacks SOME styles, it means Tailwind CSS can not find the string inside your template files. Using Tailwind CSS + Laravel (with or without daisyUI) is the same: https://tailwindcss.com/docs/guides/laravel If some class names are not getting generated, make sure:
|
Beta Was this translation helpful? Give feedback.
-
If all of the HTML code that contains Tailwind or daisyUI class names exist directly inside these directories, that's correct. |
Beta Was this translation helpful? Give feedback.
-
Hey @saadeghi, I seem to have caught a weird behavior today specific to the This does not work for me: <div class="alert alert-info shadow-lg"></div> The daisyui: {
styled: true,
themes: false,
base: true,
utils: false,
themes: [
{
default: {
"primary": "#ffb10f",
"info": "#a9d5ea",
"--rounded-btn": "0.25rem",
"--rounded-box": "0.25rem"
}
}
] PS.: I'm using daisyui v2.15.3 and recently upgraded to tailwindcss v3.1.2 and the problem still persists. |
Beta Was this translation helpful? Give feedback.
-
I know it's kinda late but I'm just gonna drop the solution here. add safelist in your tailwind config file and use pattern to render some classes by default.
safelist accepts array, you can also add single class or use patterns to dynamically render a pattern. |
Beta Was this translation helpful? Give feedback.
If all of the HTML code that contains Tailwind or daisyUI class names exist directly inside these directories, that's correct.
If there are subdirectories, you should use this pattern instead:
/**/*.php
Like: 'resources/views/**/*.blade.php'