Integrate Redux NextJS TypeScript
09 Januari, 2023
This is the simple way to configuration your NextJS Project with TailwindCSS. I'll guide you how to configure it based the official documentation of TailwindCSS.
Installation & configuration
-
Create your NextJS Project first.
if you already created NextJS you can skip this step, Use your fav terminal and input this command.npx create-next-app@latest tailwind-demo-next --typescript --eslint
-
Open NextJS project in your text editor.
-
Install Tailwind CSS.
following this command in the terminal to generate bothtailwind.config.js
andpostcss.config.js
.npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p -
Configure path tailwindcss.
add this all script to yourtailwind.config.js
/** @type {import('tailwindcss').Config} */ module.exports = { content: [ "./pages/**/*.{js,ts,jsx,tsx}", "./components/**/*.{js,ts,jsx,tsx}", ], theme: { extend: {}, }, plugins: [], };
-
Implement tailwindcss to your public CSS.
i prefer you to create a new css file inside the folder./styles/index.css
also add this script to yourindex.css
.@tailwind base; @tailwind components; @tailwind utilities;
-
Change the css link inside file
_app.tsx
.
you can adjust yourindex.css
to be your public css in this project, like this -
Implement tailwind style in this project.
you can use tailwind style insideindex.tsx
file.
the file directori is in./pages/index.tsx
or you can use CTRL + P in Visual Studio Code and enterindex.tsx
. Automatically vscode will open the file you are looking forExample:
export default function Home() { return <h1 className="text-3xl font-bold underline">Hello world!</h1>; }
-
Start your NextJS project.
enter this command in your terminal inside project, and show what happen
npm run dev
Voila.. 🎉✨🎉
now you can use tailwindcss in nextjs project
Source: Tailwind CSS NextJS