how to use daisyui with shadcnui #2480
-
hello everyone . i like to keep boht of this library , i want to sync daisyui theme with shadcn ui , there any way can anyone help me please , at present my tailwind.config.js is look like
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
Please share your project so I can run it and reproduce the problem. |
Beta Was this translation helpful? Give feedback.
-
This is how I end up with it. Not yet sure if everything from shadcn will look correctly, but at least DaisyUI won't break. tailwind.config.tsimport daisyui, { type Config as DaisyUIConfig } from "daisyui";
import { type Config } from "tailwindcss";
type DaisyuiThemeExtend = {
borderRadius: {
badge: string;
btn: string;
box: string;
};
colors: {
"base-100": string;
"base-200": string;
"base-300": string;
"base-content": string;
primary: string;
"primary-content": string;
secondary: string;
"secondary-content": string;
accent: string;
"accent-content": string;
neutral: string;
"neutral-content": string;
info: string;
"info-content": string;
success: string;
"success-content": string;
warning: string;
"warning-content": string;
error: string;
"error-content": string;
};
};
const daisyuiThemeExtend = daisyui.config!.theme!.extend as DaisyuiThemeExtend;
const shadcnThemeExtend = {
borderRadius: {
lg: daisyuiThemeExtend.borderRadius.badge,
md: daisyuiThemeExtend.borderRadius.btn,
sm: daisyuiThemeExtend.borderRadius.box,
},
colors: {
background: daisyuiThemeExtend.colors["base-100"],
foreground: daisyuiThemeExtend.colors["base-content"],
card: {
DEFAULT: daisyuiThemeExtend.colors["base-100"],
foreground: daisyuiThemeExtend.colors["base-content"],
},
popover: {
DEFAULT: daisyuiThemeExtend.colors["base-100"],
foreground: daisyuiThemeExtend.colors["base-content"],
},
primary: {
DEFAULT: daisyuiThemeExtend.colors.primary,
foreground: daisyuiThemeExtend.colors["primary-content"],
},
secondary: {
DEFAULT: daisyuiThemeExtend.colors.secondary,
foreground: daisyuiThemeExtend.colors["secondary-content"],
},
muted: {
DEFAULT: daisyuiThemeExtend.colors["base-300"],
foreground: daisyuiThemeExtend.colors["base-content"],
},
accent: {
DEFAULT: daisyuiThemeExtend.colors.accent,
foreground: daisyuiThemeExtend.colors["accent-content"],
},
destructive: {
DEFAULT: daisyuiThemeExtend.colors.error,
foreground: daisyuiThemeExtend.colors["error-content"],
},
border: daisyuiThemeExtend.colors["base-300"],
input: daisyuiThemeExtend.colors["base-300"],
ring: daisyuiThemeExtend.colors.primary,
chart: {
"1": "hsl(var(--chart-1))",
"2": "hsl(var(--chart-2))",
"3": "hsl(var(--chart-3))",
"4": "hsl(var(--chart-4))",
"5": "hsl(var(--chart-5))",
},
},
};
export default {
content: ["./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {
...shadcnThemeExtend,
},
},
plugins: [
require("@tailwindcss/typography"),
require("daisyui"),
require("tailwindcss-animate"),
],
daisyui: {
themes: ["autumn", "garden", "fantasy"],
} satisfies DaisyUIConfig,
} satisfies Config; src/styles/globals.css@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:root {
/** shadcn */
--chart-1: 12 76% 61%;
--chart-2: 173 58% 39%;
--chart-3: 197 37% 24%;
--chart-4: 43 74% 66%;
--chart-5: 27 87% 67%;
}
}
/** shadcn */
@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
} |
Beta Was this translation helpful? Give feedback.
-
I resolved this issue after removing |
Beta Was this translation helpful? Give feedback.
Thanks.
How do you change the theme in Shadcn?
Because it looks like the colors are hardcoded even after setting
"cssVariables": true
incomponents.json
according to docs, I couldn't see the CSS variables.