Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize a theme in daisy-ui?

  1. I want to customize a theme in daisyui. Is it possible to customize i.e. the dark theme (just fix one color, or add a further color-entry)?

  2. Furthermore: is it possible to add a new color entry to your custom theme?

I.e. I tried the following without success:

  daisyui: {
    styled: true,
    themes: [
      "light", // first one will be the default theme
      "dark",
      {
        mytheme: {
          primary: "#793ef9",
          "new-color": "#eff1ae",
          "primary-focus": "#570df8",
        },
      },
      "cupcake",
    ],
  },

...but when I use the new color new-color, in my css (theme("colors.new-color")). I get following error:

(146:7) /home/armwur/code/booking-overview/src/index.css 'colors.new-color' does not exist in your theme config. 'colors' has the following valid keys: 'inherit', 'current', 'transparent', 'black', 'white', 'neutral', 'primary', 'primary-focus', 'primary-content', 'secondary', 'secondary-focus', 'secondary-content', 'accent', 'accent-focus', 'accent-content', 'neutral-focus', 'neutral-content', 'base-100', 'base-200', 'base-300', 'base-content', 'info', 'success', 'warning', 'error'

  144 |  }
  145 |   .fast-table tr:hover td {
> 146 |       background-color: theme('colors.new-color');
      |       ^
  147 |  }
  148 |   .fast-table th, .fast-table td {

I need to add a custom color-entry. How is that possible?

like image 670
wuarmin Avatar asked Dec 06 '25 07:12

wuarmin


1 Answers

  1. What you are trying to do is create another theme. Here's how editing an existing theme can be done:
module.exports = {
  //...
  daisyui: {
    themes: [
      {
        light: {
          ...require("daisyui/src/theming/themes")["light"],
          primary: "blue",
          "primary-focus": "mediumblue",
        },
      },
    ],
  },
}

Further info can be found here.

  1. This can also be done by adding your CSS into the theme:
[data-theme="mytheme"] .btn {
  border-width: 2px;
  border-color: black;
}

Further info can be found here.

like image 182
Artie Avatar answered Dec 09 '25 03:12

Artie