---
title: Tailwind CSS
description: Learn how to use Tailwind CSS in a Turborepo.
url: "https://turborepo.dev/docs/guides/tools/tailwind"
docs_index: /llms.txt
lastUpdated: 2026-11-20
product: turborepo
type: integration
summary: Share Tailwind CSS configuration and styles across packages in your monorepo.
related:
  - /docs/guides/tools/shadcn-ui
  - /docs/guides/tools/storybook
  - /docs/guides/tools/typescript
---

> For an index of all documentation, see [/llms.txt](/llms.txt).

[Tailwind CSS](https://tailwindcss.com/) is a CSS framework that allows you to rapidly build modern websites without ever leaving your HTML.

## Quickstart

If you'd rather use a template, this guide is walking through how to build [this Tailwind CSS + Turborepo template](https://github.com/vercel/turborepo/tree/main/examples/with-tailwind).

#### pnpm

```bash title="Terminal"
pnpm dlx create-turbo@latest -e with-tailwind
```

#### yarn

```bash title="Terminal"
yarn dlx create-turbo@latest -e with-tailwind
```

#### npm

```bash title="Terminal"
npx create-turbo@latest -e with-tailwind
```

#### bun

```bash title="Terminal"
bunx create-turbo@latest -e with-tailwind
```

#### nub

```bash title="Terminal"
nubx create-turbo@latest -e with-tailwind
```

#### aube

```bash title="Terminal"
aubx create-turbo@latest -e with-tailwind
```

## Guide

> This guide is for Tailwind CSS v4.

### 1. Create a monorepo

If you don't have an existing project, use [create-turbo](/docs/getting-started/installation) to create a new monorepo:

#### pnpm

```bash title="Terminal"
pnpm dlx create-turbo@latest
```

#### yarn

```bash title="Terminal"
yarn dlx create-turbo@latest
```

#### npm

```bash title="Terminal"
npx create-turbo@latest
```

#### bun

```bash title="Terminal"
bunx create-turbo@latest
```

#### nub

```bash title="Terminal"
nubx create-turbo@latest
```

#### aube

```bash title="Terminal"
aubx create-turbo@latest
```

### 2. Add Tailwind CSS to your application

[Follow Tailwind CSS's guides](https://tailwindcss.com/docs/installation/using-vite) to set up Tailwind CSS for your frontend framework.

Once completed, you can start working on bringing your UI package into the applications.

### 3. Create a shared Tailwind CSS configuration package

First, build an [Internal Package](https://turborepo.dev/docs/core-concepts/internal-packages) with four files:

#### package.json

This `package.json` installs Tailwind CSS so we can create the file shared styles and export for the rest of the repository.

```json title="./packages/tailwind-config/package.json"
{
  "name": "@repo/tailwind-config",
  "version": "0.0.0",
  "type": "module",
  "private": true,
  "exports": {
    ".": "./shared-styles.css",
    "./postcss": "./postcss.config.js"
  },
  "devDependencies": {
    "postcss": "^8.5.3",
    "tailwindcss": "^4.1.5"
  }
}
```

#### shared-styles.css

This `shared-styles.css` file will be shared to the libraries and applications in the repository. The variables shown will be available anywhere that the file is included.

```css title="./packages/tailwind-config/shared-styles.css"
@import "tailwindcss";

@theme {
  --blue-1000: #2a8af6;
  --purple-1000: #a853ba;
  --red-1000: #e92a67;
}
```

#### postcss.config.js (Optional)

If your frontends need a PostCSS configuration file, you can create one to share.

```js title="./packages/tailwind-config/postcss.config.js"
export const postcssConfig = {
  plugins: {
    "@tailwindcss/postcss": {},
  },
};
```

### 4. Create the UI package

You can now build the components to share to your applications.

For a full example, [visit the source code for `@repo/ui` package in the Tailwind CSS example](https://github.com/vercel/turborepo/tree/main/examples/with-tailwind/packages/ui). The files required for your Tailwind CSS setup are below.

#### package.json

The `package.json` installs the dependencies for the package, sets up scripts for development and build environments, and marks the exports for the package.

```json title="./packages/ui/package.json"
{
  "exports": {
    "./styles.css": "./dist/index.css",
    "./*": "./dist/*.js"
  },
  "scripts": {
    "build:styles": "tailwindcss -i ./src/styles.css -o ./dist/index.css",
    "build:components": "tsc",
    "dev:styles": "tailwindcss -i ./src/styles.css -o ./dist/index.css --watch",
    "dev:components": "tsc --watch"
  },
  "devDependencies": {
    "@repo/tailwind-config": "workspace:*",
    "@tailwindcss/cli": "^4.1.5",
    "@tailwindcss/postcss": "^4.1.5",
    "autoprefixer": "^10.4.20",
    "tailwindcss": "^4.1.5"
  }
}
```

> Above, we've only included the code related to setting up Tailwind. The full
> package.json is
> [here](https://github.com/vercel/turborepo/tree/main/examples/with-tailwind/packages/ui/package.json).

#### turbo.json

Create a `build` and `dev` task that runs the scripts for building of components and style sheets in parallel.

```json title="./packages/ui/turbo.json"
{
  "extends": ["//"],
  "tasks": {
    "build": {
      "dependsOn": ["build:styles", "build:components"]
    },
    "build:styles": {
      "outputs": ["dist/**"]
    },
    "build:components": {
      "outputs": ["dist/**"]
    },
    "dev": {
      "with": ["dev:styles", "dev:components"]
    },
    "dev:styles": {
      "cache": false,
      "persistent": true
    },
    "dev:components": {
      "cache": false,
      "persistent": true
    }
  }
}
```

#### styles.css

This `styles.css` contains component-level styles for the shared UI library.

```css title="./packages/ui/src/styles.css"
/* Component-level styles for the UI package */
@import "tailwindcss" prefix(ui);
```

> Tailwind classes used in this package should be prefixed with `ui:` to avoid
> style specificity issues.

### 5. Use the UI package in an application

Install the packages you've created into your application.

#### pnpm

```bash title="Terminal"
pnpm add @repo/ui @repo/tailwind-config --save-dev --filter=@repo/ui --filter=web
```

#### yarn

```bash title="Terminal"
yarn workspace web add @repo/ui @repo/tailwind-config --dev
yarn workspace @repo/ui add @repo/ui @repo/tailwind-config --dev
```

#### npm

```bash title="Terminal"
npm install @repo/ui @repo/tailwind-config --workspace=web --workspace=@repo/ui --save-dev
```

#### bun

```bash title="Terminal"
cd apps/web && bun install @repo/ui @repo/tailwind-config --dev
cd packages/ui && bun install @repo/ui @repo/tailwind-config --dev
```

#### nub

```bash title="Terminal"
cd apps/web && nub add @repo/ui @repo/tailwind-config --save-dev
cd packages/ui && nub add @repo/ui @repo/tailwind-config --save-dev
```

#### aube

```bash title="Terminal"
cd apps/web && aube add @repo/ui @repo/tailwind-config --save-dev
cd packages/ui && aube add @repo/ui @repo/tailwind-config --save-dev
```

Then, configure the files in your application so the styles from the UI package are reflected in the application.

#### globals.css

```css title="./apps/web/app/globals.css"
@import "tailwindcss";
@import "@repo/tailwind-config";
```

#### layout.tsx

```tsx title="./apps/web/app/layout.tsx"
import "@repo/ui/styles.css";
import "./globals.css";
```

#### postcss.config.js (Optional)

```js title="./apps/web/postcss.config.js"
import { postcssConfig } from "@repo/tailwind-config/postcss";

export default postcssConfig;
```

---

For a semantic overview of all documentation, see [/sitemap.md](/sitemap.md)

For an index of all available documentation, see [/llms.txt](/llms.txt)

For agent-facing discovery, including API and MCP surfaces, see [/agents.md](/agents.md)