Skip to content

Commit 4ac2f14

Browse files
docs: update Tailwind CSS installation and configuration instructions (#76259)
1 parent c9d93c4 commit 4ac2f14

File tree

1 file changed

+8
-41
lines changed

1 file changed

+8
-41
lines changed

docs/01-app/03-building-your-application/05-styling/02-tailwind-css.mdx

+8-41
Original file line numberDiff line numberDiff line change
@@ -9,66 +9,33 @@ description: Style your Next.js Application using Tailwind CSS.
99

1010
## Installing Tailwind
1111

12-
Install the Tailwind CSS packages and run the `init` command to generate both the `tailwind.config.js` and `postcss.config.js` files:
12+
Install the necessary Tailwind CSS packages:
1313

1414
```bash filename="Terminal"
15-
npm install -D tailwindcss postcss autoprefixer
16-
npx tailwindcss init -p
15+
npm install -D tailwindcss @tailwindcss/postcss postcss
1716
```
1817

1918
## Configuring Tailwind
2019

21-
Inside your Tailwind configuration file, add paths to the files that will use Tailwind class names:
20+
Create a `postcss.config.mjs` file in the root of your project and add the `@tailwindcss/postcss` plugin to your PostCSS configuration:
2221

23-
```ts filename="tailwind.config.ts" highlight={5-10} switcher
24-
import type { Config } from 'tailwindcss'
25-
26-
export default {
27-
content: [
28-
'./app/**/*.{js,ts,jsx,tsx,mdx}', // Note the addition of the `app` directory.
29-
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
30-
'./components/**/*.{js,ts,jsx,tsx,mdx}',
31-
32-
// Or if using `src` directory:
33-
'./src/**/*.{js,ts,jsx,tsx,mdx}',
34-
],
35-
theme: {
36-
extend: {},
37-
},
38-
plugins: [],
39-
} satisfies Config
40-
```
41-
42-
```js filename="tailwind.config.js" highlight={4-9} switcher
22+
```js filename="postcss.config.mjs" highlight={4}
4323
/** @type {import('tailwindcss').Config} */
44-
module.exports = {
45-
content: [
46-
'./app/**/*.{js,ts,jsx,tsx,mdx}', // Note the addition of the `app` directory.
47-
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
48-
'./components/**/*.{js,ts,jsx,tsx,mdx}',
49-
50-
// Or if using `src` directory:
51-
'./src/**/*.{js,ts,jsx,tsx,mdx}',
52-
],
53-
theme: {
54-
extend: {},
24+
export default {
25+
plugins: {
26+
'@tailwindcss/postcss': {},
5527
},
56-
plugins: [],
5728
}
5829
```
5930

60-
You do not need to modify `postcss.config.js`.
61-
6231
<AppOnly>
6332

6433
## Importing Styles
6534

6635
Add the [Tailwind CSS directives](https://tailwindcss.com/docs/functions-and-directives#directives) that Tailwind will use to inject its generated styles to a [Global Stylesheet](/docs/app/building-your-application/styling/css#global-styles) in your application, for example:
6736

6837
```css filename="app/globals.css"
69-
@tailwind base;
70-
@tailwind components;
71-
@tailwind utilities;
38+
@import 'tailwindcss';
7239
```
7340

7441
Inside the [root layout](/docs/app/building-your-application/routing/layouts-and-templates#root-layout-required) (`app/layout.tsx`), import the `globals.css` stylesheet to apply the styles to every route in your application.

0 commit comments

Comments
 (0)