--- title: Colors desc: How to use daisyUI colors? --- ## - bg-green-500 - bg-orange-600 - bg-blue-700 - - bg-primary - bg-secondary - bg-accent - ## Example of theming a div with hardcoded color values
*Using hardcoded color names*
This is a hardcoded dark text on a light background, it needs double the amount of class names to support dark mode.
```html
This is a hardcoded dark text on a light background, it needs double the amount of class names to support dark mode.
``` - πŸͺ¦ Fixed color names, hardcoded based on the value - 🚫 No automatic dark mode - πŸ˜΅β€πŸ’« You have to add dark-mode colors for every element - πŸ’Έ high maintenance cost - 🐒 slow development - 😩 hard to change a theme - ⛓️‍πŸ’₯ high chance of inconsistency - 😰 You are limited to 2 themes only: light and dark
*Using semantic color names*
This is dark text on a light background, which switches to light text on a dark background in dark mode.
```html
This is dark text on a light background, which switches to light text on a dark background in dark mode.
``` - 🎯 Semantic names, based on the purpose of the color - ✨ Automatic dark mode - πŸŒ“ No need to add any dark-mode class names - πŸ€‘ Zero maintenance cost to add a theme - πŸš€ Fast development - ⚑️ Easy to change themes - πŸ“˜ All colors are consistent based on the design system - ♾️ Unlimited themes, easy to switch
##
| | Color name | CSS variable | Where to use | |--------------------------------------------------|-------------------|-----------------------------|--------------------------------------------------------------------| | | primary | `--color-primary` | Primary brand color, The main color of your brand | | | primary-content | `--color-primary-content` | Foreground content color to use on `primary` color

| | | secondary | `--color-secondary` | Secondary brand color, The optional, secondary color of your brand | | | secondary-content | `--color-secondary-content` | Foreground content color to use on `secondary` color

| | | accent | `--color-accent` | Accent brand color, The optional, accent color of your brand | | | accent-content | `--color-accent-content` | Foreground content color to use on `accent` color

| | | neutral | `--color-neutral` | Neutral dark color, For not-saturated parts of UI | | | neutral-content | `--color-neutral-content` | Foreground content color to use on neutral color

| | | base-100 | `--color-base-100` | Base surface color of page, used for blank backgrounds | | | base-200 | `--color-base-200` | Base color, darker shade, to create elevations | | | base-300 | `--color-base-300` | Base color, even more darker shade, to create elevations | | | base-content | `--color-base-content` | Foreground content color to use on `base` color

| | | info | `--color-info` | Info color, For informative/helpful messages | | | info-content | `--color-info-content` | Foreground content color to use on `info` color | | | success | `--color-success` | Success color, For success/safe messages | | | success-content | `--color-success-content` | Foreground content color to use on `success` color | | | warning | `--color-warning` | Warning color, For warning/caution messages | | | warning-content | `--color-warning-content` | Foreground content color to use on `warning` color | | | error | `--color-error` | Error color, For error/danger/destructive messages | | | error-content | `--color-error-content` | Foreground content color to use on `error` color |
## : ```html ``` : ```html ``` These components automatically set the correct background color, text color, border color, etc as needed so you don't need to set those colors manually. For example `btn-primary` sets `primary` color for background and border, and sets `primary-content` color for the text automatically as default. You can customize them using utility classes if you want to change the color. | CSS Class | | |----------------------------|-----------------------------------------------------------------------------------------------------------------------------------| | `bg-{COLOR_NAME}` | Also available on CDN [/colors/properties.css](https://cdn.jsdelivr.net/npm/daisyui@latest/colors/properties.css) | | `text-{COLOR_NAME}` | Also available on CDN [/colors/properties.css](https://cdn.jsdelivr.net/npm/daisyui@latest/colors/properties.css) | | `border-{COLOR_NAME}` | Also available on CDN [/colors/properties.css](https://cdn.jsdelivr.net/npm/daisyui@latest/colors/properties.css) | | `from-{COLOR_NAME}` | Also available on CDN [/colors/properties-extended.css](https://cdn.jsdelivr.net/npm/daisyui@latest/colors/properties-extended.css) | | `via-{COLOR_NAME}` | Also available on CDN [/colors/properties-extended.css](https://cdn.jsdelivr.net/npm/daisyui@latest/colors/properties-extended.css) | | `to-{COLOR_NAME}` | Also available on CDN [/colors/properties-extended.css](https://cdn.jsdelivr.net/npm/daisyui@latest/colors/properties-extended.css) | | `ring-{COLOR_NAME}` | Also available on CDN [/colors/properties-extended.css](https://cdn.jsdelivr.net/npm/daisyui@latest/colors/properties-extended.css) | | `fill-{COLOR_NAME}` | Also available on CDN [/colors/properties-extended.css](https://cdn.jsdelivr.net/npm/daisyui@latest/colors/properties-extended.css) | | `stroke-{COLOR_NAME}` | Also available on CDN [/colors/properties-extended.css](https://cdn.jsdelivr.net/npm/daisyui@latest/colors/properties-extended.css) | | `shadow-{COLOR_NAME}` | Also available on CDN [/colors/properties-extended.css](https://cdn.jsdelivr.net/npm/daisyui@latest/colors/properties-extended.css) | | `outline-{COLOR_NAME}` | Also available on CDN [/colors/properties-extended.css](https://cdn.jsdelivr.net/npm/daisyui@latest/colors/properties-extended.css) | | `divide-{COLOR_NAME}` | | | `accent-{COLOR_NAME}` | | | `caret-{COLOR_NAME}` | | | `decoration-{COLOR_NAME}` | | | `placeholder-{COLOR_NAME}` | | | `ring-offset-{COLOR_NAME}` | | So you can use `bg-primary`, `border-secondary`, etc. Read more about [daisyUI color utility classes](/docs/utilities). ## Color opacity and muted colors `base-content` is the the text color of the page by default. It's a dark color on light themes and it's a light color on dark themes.
nord theme
text-base-content
dracula theme
text-base-content
Sometimes we need a muted text. something with less contrast. The best way to do this is using Tailwind CSS color opacity modifier by adding a `/50` (or any other value) to the end of color name. Like `text-base-content/50`
nord theme
text-base-content
text-base-content/70
text-base-content/50
text-base-content/30
dracula theme
text-base-content
text-base-content/70
text-base-content/50
text-base-content/30
The advantage of using opacity is that it gives a constant result on all themes, for all colors. You can use it with any opacity value, you can use it for any color. For example primary-content:
nord theme
text-primary-content
text-primary-content/50
dracula theme
text-primary-content
text-primary-content/50