Unverified Commit 4ac2f147 authored by Niaz Morshed Nayeem's avatar Niaz Morshed Nayeem Committed by GitHub

docs: update Tailwind CSS installation and configuration instructions (#76259)

parent c9d93c45
...@@ -9,56 +9,25 @@ description: Style your Next.js Application using Tailwind CSS. ...@@ -9,56 +9,25 @@ description: Style your Next.js Application using Tailwind CSS.
## Installing Tailwind ## Installing Tailwind
Install the Tailwind CSS packages and run the `init` command to generate both the `tailwind.config.js` and `postcss.config.js` files: Install the necessary Tailwind CSS packages:
```bash filename="Terminal" ```bash filename="Terminal"
npm install -D tailwindcss postcss autoprefixer npm install -D tailwindcss @tailwindcss/postcss postcss
npx tailwindcss init -p
``` ```
## Configuring Tailwind ## Configuring Tailwind
Inside your Tailwind configuration file, add paths to the files that will use Tailwind class names: Create a `postcss.config.mjs` file in the root of your project and add the `@tailwindcss/postcss` plugin to your PostCSS configuration:
```ts filename="tailwind.config.ts" highlight={5-10} switcher ```js filename="postcss.config.mjs" highlight={4}
import type { Config } from 'tailwindcss'
export default {
content: [
'./app/**/*.{js,ts,jsx,tsx,mdx}', // Note the addition of the `app` directory.
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
'./components/**/*.{js,ts,jsx,tsx,mdx}',
// Or if using `src` directory:
'./src/**/*.{js,ts,jsx,tsx,mdx}',
],
theme: {
extend: {},
},
plugins: [],
} satisfies Config
```
```js filename="tailwind.config.js" highlight={4-9} switcher
/** @type {import('tailwindcss').Config} */ /** @type {import('tailwindcss').Config} */
module.exports = { export default {
content: [ plugins: {
'./app/**/*.{js,ts,jsx,tsx,mdx}', // Note the addition of the `app` directory. '@tailwindcss/postcss': {},
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
'./components/**/*.{js,ts,jsx,tsx,mdx}',
// Or if using `src` directory:
'./src/**/*.{js,ts,jsx,tsx,mdx}',
],
theme: {
extend: {},
}, },
plugins: [],
} }
``` ```
You do not need to modify `postcss.config.js`.
<AppOnly> <AppOnly>
## Importing Styles ## Importing Styles
...@@ -66,9 +35,7 @@ You do not need to modify `postcss.config.js`. ...@@ -66,9 +35,7 @@ You do not need to modify `postcss.config.js`.
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: 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:
```css filename="app/globals.css" ```css filename="app/globals.css"
@tailwind base; @import 'tailwindcss';
@tailwind components;
@tailwind utilities;
``` ```
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. 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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment