Next.js
💡
Next (opens in a new tab) project created with
create-next-app
(opens in a new tab).
Setup
-
Create a new Next.js app with
create-next-app
:npx create-next-app@latest next
-
Add Tailwind CSS to your Next.js app:
npm install tailwindcss@latest postcss@latest autoprefixer@latest
-
Initialize Tailwind CSS in your project:
npx tailwindcss init -p
-
Create a
styles/globals.css
file with the following content:@tailwind base; @tailwind components; @tailwind utilities;
-
Import the
globals.css
file in yourapp/_layout.tsx
:import "../styles/globals.css" //...
-
Add
tw.ts
for usingtailwindest
import { createTools, type Tailwindest } from "tailwindest" /** * Custom type definition of tailwindest * @see {@link https://tailwindest.vercel.app/apis/Tailwindest api reference} */ type TailwindCustom = Tailwindest<{}, {}> /** * Full type definition of `tailwindcss` */ type Tailwind = Required<TailwindCustom> const tw = createTools<TailwindCustom>() export { tw, type Tailwind }
There you go! You have successfully set up Tailwind CSS in your Next.js app.
Next counter