Updates, ideas and resources

In this article, we will learn how to use daisyUI component library in Next.js.
Next.js is currently one of the popular JavaScript meta frameworks for building web applications. Since we can use daisyUI in any JavaScript framework, we can also use it in Next.js.
Installing Next.js is pretty straightforward. It also includes Tailwind CSS by default. After installing Next.js, we can install daisyUI as a plugin and start using it in our Next.js project.
npx create-next-app@latest Tailwind CSS when asked about it:
Go to the project directory. If you named it my-app:
cd my-app npm i -D daisyui@latest tailwind.config.ts fileimport type { Config } from 'tailwindcss'
+ import daisyui from 'daisyui'
const config: Config = {
content: [
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
'./components/**/*.{js,ts,jsx,tsx,mdx}',
'./app/**/*.{js,ts,jsx,tsx,mdx}',
],
theme: {
extend: {
backgroundImage: {
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
'gradient-conic':
'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
},
},
},
- plugins: [],
+ plugins: [daisyui],
}
export default config
/app/page.tsx fileexport default function Home() {
return (
<>
<button className="btn btn-primary">Hello daisyUI!</button>
</>
)
} npm run dev And open http://localhost:3000/ to see a button with daisyUI styles.
You can now use any daisyUI component or any Tailwind CSS utility class in your Next.js project.
app/globals.css, to have a clean start. Only keep the following line:@tailwind base;
@tailwind components;
@tailwind utilities;Subscribe to daisyUI blog newsletter to get updates on new posts.
You will only receive a single email when a new blog post is published. No spam. No ads.