tailwindcss
daisyui
react installation
react
install reactjs
Install React Efficiently (react + vite + tailwindcss + daisyui)
Installing React Efficiently
- Create a regular
React
app scaffoldingterminal or consolenpm create vite@latest .
- Install
tailwindcss
terminal or consolenpm install -D tailwindcss postcss autoprefixer npx tailwindcss init -p
- Open
tailwind.config.js
file & Modify the content array to include:tailwind.config.jscontent: [ "./index.html", "./src/**/*.{js,ts,jsx,tsx}", ],
- Open
index.css
& replace it its contentsindex.css@tailwind base; @tailwind components; @tailwind utilities;
Open
main.css
as this is already imported insidemain.js
. Comment everything insidemain.css
. - Begin styling with Tailwind’s utility classes in
App.jsx
App.jsxexport default function App() { return <h1 className="text-3xl font-bold underline">Hello world!</h1>; }
- Install
daisyui
terminal or consolenpm i daisyui
- Open
tailwind.config.js
& adddaisyui
to the pluginstailwind.config.js
or using ES Module syntax:/** @type {import('tailwindcss').Config} \*/ export default { content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"], theme: { extend: {}, }, plugins: [require("daisyui")], };
tailwind.config.jsimport daisyui from "daisyui"; /** @type {import('tailwindcss').Config} \*/ export default { content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"], theme: { extend: {}, }, plugins: [daisyui], };
- Open
App.jsx
& update the code to check ifdaisyui
is working correctlyApp.jsximport "./App.css"; function App() { return ( <> <h1 className="text-3xl">Hello</h1> <button className="btn btn-outline"> Hello</button> </> ); } export default App;