Skip to content

Commit e10a103

Browse files
authored
docs(examples): drop JS config from Tailwind example (#10445)
### Description Found out that JS configurations aren't hip with the kids these days, so switching out the approach. The CSS variables are a bit contrived, but work great for showing off what we're needing to show off.
1 parent a598510 commit e10a103

File tree

15 files changed

+45
-89
lines changed

15 files changed

+45
-89
lines changed

docs/site/content/docs/guides/tools/tailwind.mdx

+30-60
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
2-
title: TailwindCSS
3-
description: Learn how to use TailwindCSS in a Turborepo.
2+
title: Tailwind CSS
3+
description: Learn how to use Tailwind CSS in a Turborepo.
44
---
55

66
import { PackageManagerTabs, Tabs, Tab } from '#components/tabs';
77
import { Callout } from '#components/callout';
88
import { Steps, Step } from '#components/steps';
99

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

1212
## Quickstart
1313

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

1616
<PackageManagerTabs>
1717

@@ -50,7 +50,7 @@ bunx create-turbo@latest -e with-tailwind
5050

5151
## Guide
5252

53-
<Callout type="info">This guide is for TailwindCSS v4.</Callout>
53+
<Callout type="info">This guide is for Tailwind CSS v4.</Callout>
5454

5555
<Steps>
5656
<Step>
@@ -98,67 +98,56 @@ bunx create-turbo@latest
9898

9999
<Step>
100100

101-
### Add TailwindCSS to your application
101+
### Add Tailwind CSS to your application
102102

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

105-
Once completed, we can integrate your UI package into the applications.
105+
Once completed, you can start working on bringing your UI package into the applications.
106106

107107
</Step>
108108

109109
<Step>
110110

111-
### Create a shared TailwindCSS configuration package
111+
### Create a shared Tailwind CSS configuration package
112112

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

115-
<Tabs items={["package.json", "tailwind.config.ts", "tsconfig.json", "postcss.config.js (Optional)"]}>
115+
<Tabs items={["package.json", "shared-styles.css", "postcss.config.js (Optional)"]}>
116116

117117
<Tab value="package.json">
118118

119-
This `package.json` installs TailwindCSS so we can create the configuration file and exports the configuration file for use in the rest of the repository.
119+
This `package.json` installs Tailwind CSS so we can create the file shared styles and export for the rest of the repository.
120120

121121
```json title="./packages/tailwind-config/package.json"
122122
{
123123
"name": "@repo/tailwind-config",
124124
"version": "0.0.0",
125+
"type": "module",
125126
"private": true,
126127
"exports": {
127-
".": "./tailwind.config.ts"
128+
".": "./shared-styles.css",
129+
"./postcss": "./postcss.config.js"
128130
},
129131
"devDependencies": {
130-
"@repo/typescript-config": "workspace:*",
132+
"postcss": "^8.5.3",
131133
"tailwindcss": "^4.1.5"
132134
}
133135
}
134136
```
135137

136138
</Tab>
137139

138-
<Tab value="tailwind.config.ts">
140+
<Tab value="shared-styles.css">
139141

140-
This `tailwind.config.ts` will be shared to the libraries and applications in the repository.
142+
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.
141143

142-
```ts title="./packages/tailwind-config/tailwind.config.ts"
143-
import type { Config } from 'tailwindcss';
144-
145-
const config: Omit<Config, 'content'> = {
146-
darkMode: 'class',
147-
};
148-
export default config;
149-
```
150-
151-
</Tab>
152-
153-
<Tab value="tsconfig.json">
154-
155-
A simple TypeScript configuration file so we can use TypeScript for the `tailwind.config.ts`
144+
```css title="./packages/tailwind-config/shared-styles.css"
145+
@import 'tailwindcss';
156146

157-
```ts title="./packages/tailwind-config/tconfig.json"
158-
{
159-
"extends": "@repo/typescript-config/base.json",
160-
"include": ["."],
161-
"exclude": ["dist", "build", "node_modules"]
147+
@theme {
148+
--blue-1000: #2a8af6;
149+
--purple-1000: #a853ba;
150+
--red-1000: #e92a67;
162151
}
163152
```
164153

@@ -185,11 +174,11 @@ export const postcssConfig = {
185174

186175
### Create the UI package
187176

188-
You can now build the components you share to your applications.
177+
You can now build the components to share to your applications.
189178

190-
For a full example, [visit the source code for `@repo/ui` package in the TailwindCSS example](https://github.com/vercel/turborepo/tree/main/examples/with-tailwind/packages/ui). The files required for your TailwindCSS setup are below.
179+
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.
191180

192-
<Tabs items={["package.json", "turbo.json", "tailwind.config.ts", "styles.css"]}>
181+
<Tabs items={["package.json", "turbo.json", "styles.css"]}>
193182

194183
<Tab value="package.json">
195184

@@ -259,20 +248,10 @@ Create a `build` and `dev` task that runs the scripts for building of components
259248

260249
</Tab>
261250

262-
<Tab value="tailwind.config.ts">
263-
264-
Use the shared configuration from the Tailwind configuration package.
265-
266-
```ts title="./packages/ui/turbo.json"
267-
import sharedConfig from '@repo/tailwind-config';
268-
269-
export default sharedConfig;
270-
```
271-
272-
</Tab>
273-
274251
<Tab value="styles.css">
275252

253+
This file is small! It makes sure that Tailwind CSS runs for the package.
254+
276255
```css title="./packages/ui/src/index.css"
277256
@import 'tailwindcss';
278257
```
@@ -326,22 +305,13 @@ bun install @repo/ui @repo/tailwind-config --dev --filter=@repo/ui --filter=web
326305

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

329-
<Tabs items={["tailwind.config.ts", "globals.css", "postcss.config.js (Optional)"]}>
330-
331-
<Tab value="tailwind.config.ts">
332-
333-
```ts title="./apps/web/tailwind.config.ts"
334-
import sharedConfig from '@repo/tailwind-config';
335-
336-
export default sharedConfig;
337-
```
338-
339-
</Tab>
308+
<Tabs items={["globals.css", "postcss.config.js (Optional)"]}>
340309

341310
<Tab value="globals.css">
342311

343312
```css title="./apps/web/app/globals.css"
344313
@import 'tailwindcss';
314+
@import '@repo/tailwind-config';
345315
@import '@repo/ui/styles.css';
346316
```
347317

examples/with-tailwind/apps/docs/app/globals.css

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import "tailwindcss";
2+
@import "@repo/tailwind-config";
23
@import "@repo/ui/styles.css";
34

45
:root {

examples/with-tailwind/apps/docs/tailwind.config.ts

-3
This file was deleted.

examples/with-tailwind/apps/web/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ First, run the development server:
66
yarn dev
77
```
88

9-
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
9+
Open [http://localhost:3001](http://localhost:3001) with your browser to see the result.
1010

1111
You can start editing the page by modifying `src/app/page.tsx`. The page auto-updates as you edit the file.
1212

13-
To create [API routes](https://nextjs.org/docs/app/building-your-application/routing/router-handlers) add an `api/` directory to the `app/` directory with a `route.ts` file. For individual endpoints, create a subfolder in the `api` directory, like `api/hello/route.ts` would map to [http://localhost:3000/api/hello](http://localhost:3000/api/hello).
13+
To create [API routes](https://nextjs.org/docs/app/building-your-application/routing/router-handlers) add an `api/` directory to the `app/` directory with a `route.ts` file. For individual endpoints, create a subfolder in the `api` directory, like `api/hello/route.ts` would map to [http://localhost:3001/api/hello](http://localhost:3001/api/hello).
1414

1515
## Learn More
1616

examples/with-tailwind/apps/web/app/globals.css

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import "tailwindcss";
2+
@import "@repo/tailwind-config";
23
@import "@repo/ui/styles.css";
34

45
:root {

examples/with-tailwind/apps/web/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "module",
55
"private": true,
66
"scripts": {
7-
"dev": "next dev --port 3000 --turbopack",
7+
"dev": "next dev --port 3001 --turbopack",
88
"build": "next build",
99
"start": "next start",
1010
"lint": "next lint --max-warnings 0",

examples/with-tailwind/apps/web/tailwind.config.ts

-3
This file was deleted.

examples/with-tailwind/packages/tailwind-config/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
"type": "module",
55
"private": true,
66
"exports": {
7-
".": "./tailwind.config.ts",
7+
".": "./shared-styles.css",
88
"./postcss": "./postcss.config.js"
99
},
1010
"devDependencies": {
11-
"@repo/typescript-config": "workspace:*",
1211
"postcss": "^8.5.3",
1312
"tailwindcss": "^4.1.5"
1413
}

examples/with-tailwind/packages/tailwind-config/postcss.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Optional PostCSS configuration for applications that need it
12
export const postcssConfig = {
23
plugins: {
34
"@tailwindcss/postcss": {},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@import "tailwindcss";
2+
3+
@theme {
4+
--blue-1000: #2a8af6;
5+
--purple-1000: #a853ba;
6+
--red-1000: #e92a67;
7+
}

examples/with-tailwind/packages/tailwind-config/tailwind.config.ts

-6
This file was deleted.

examples/with-tailwind/packages/tailwind-config/tsconfig.json

-5
This file was deleted.

examples/with-tailwind/packages/ui/src/gradient.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function Gradient({
1313
small ? "blur-[32px]" : "blur-[75px]"
1414
} ${
1515
conic
16-
? "bg-[conic-gradient(from_180deg_at_50%_50%,_#2a8af6_0deg,_#a853ba_180deg,_#e92a67_360deg)]"
16+
? "bg-[conic-gradient(from_180deg_at_50%_50%,var(--red-1000)_0deg,_var(--purple-1000)_180deg,_var(--blue-1000)_360deg)]"
1717
: ""
1818
} ${className ?? ""}`}
1919
/>

examples/with-tailwind/packages/ui/tailwind.config.ts

-3
This file was deleted.

examples/with-tailwind/pnpm-lock.yaml

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)