daisyUI comes with 35 built-in themes that instantly transform your website's entire look - a time-saver that lets you focus on building rather than deciding on colors. You can also create your own custom themes or customize built-in themes.
You can manage themes by adding brackets in front of@plugin "daisyui"in your CSS file.
Add data-theme='THEME_NAME' to any element and everything inside will have your theme. You can nest themes and there is no limit! You can force a section of your HTML to only use a specific theme.
index.html
<html data-theme="dark"> <div data-theme="light"> This div will always use light theme <span data-theme="retro">This span will always use retro theme!</span> </div></html>
How to add a new custom theme?
To add a new theme, use@plugin "daisyui/theme" {}in your CSS file, with the following structure:
If you're using CDN and you want to use a custom theme, use it like this:
app.css
:root:has(input.theme-controller[value=mytheme]:checked),[data-theme="mytheme"] { /* mytheme is the name of the custom theme */ color-scheme: light; --color-base-100: oklch(98% 0.02 240); /* ...rest of CSS variables like above example */}
How to customize an existing theme?
To customize a built-in theme, you can use the same structure as adding a new theme, but with the same name as the built-in theme. For example, to customize thelighttheme:
How to apply Tailwind's 'dark:' selector for specific themes
daisyUI can be configured to use Tailwind's `dark:` prefix For example if you want a padding only for a daisyUI dark theme you can use `dark:p-10` In the example below, 'night' is darkmode theme so we add it to `@variant dark`
app.css
@import "tailwindcss";@plugin "daisyui" { themes: winter --default, night --prefersdark;}@custom-variant dark (&:where([data-theme=night], [data-theme=night] *));
index.html
<div class="p-10 dark:p-20"> I will have 10 padding on winter theme and 20 padding on night theme</div>