Skip to content

Commit 066984e

Browse files
authored
converted the old tailwind css example to typescript (#32808)
## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint`
1 parent 4a2bfa7 commit 066984e

File tree

12 files changed

+66
-11
lines changed

12 files changed

+66
-11
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "next/core-web-vitals"
3+
}

examples/with-tailwindcss/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ yarn-error.log*
3232

3333
# vercel
3434
.vercel
35+
36+
# typescript
37+
*.tsbuildinfo

examples/with-tailwindcss/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
<p align="center">
2+
3+
<img src="https://res.cloudinary.com/ddcg0rzlo/image/upload/v1640340715/nextjs-tailwind-typescript-banner_vslgq4.png" alt="Next.js TypeScript Starter">
4+
5+
</p>
6+
7+
<br />
8+
19
# Next.js + Tailwind CSS Example
210

311
This example shows how to use [Tailwind CSS](https://tailwindcss.com/) [(v3.0)](https://tailwindcss.com/blog/tailwindcss-v3) with Next.js. It follows the steps outlined in the official [Tailwind docs](https://tailwindcss.com/docs/guides/nextjs).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/basic-features/typescript for more information.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/** @type {import('next').NextConfig} */
2+
module.exports = {
3+
reactStrictMode: true,
4+
}

examples/with-tailwindcss/package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@
1111
"react-dom": "^17.0.2"
1212
},
1313
"devDependencies": {
14+
"@types/node": "17.0.4",
15+
"@types/react": "17.0.38",
1416
"autoprefixer": "^10.4.0",
15-
"postcss": "^8.4.4",
16-
"tailwindcss": "^3.0.0"
17+
"eslint": "8.5.0",
18+
"eslint-config-next": "12.0.7",
19+
"postcss": "^8.4.5",
20+
"tailwindcss": "^3.0.7",
21+
"typescript": "4.5.4"
1722
}
1823
}

examples/with-tailwindcss/pages/_app.js renamed to examples/with-tailwindcss/pages/_app.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import '../styles/globals.css'
2+
import type { AppProps } from 'next/app'
23

3-
function MyApp({ Component, pageProps }) {
4+
function MyApp({ Component, pageProps }: AppProps) {
45
return <Component {...pageProps} />
56
}
67

examples/with-tailwindcss/pages/api/hello.js

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
2+
import type { NextApiRequest, NextApiResponse } from 'next'
3+
4+
type Data = {
5+
name: string
6+
}
7+
8+
export default function handler(
9+
req: NextApiRequest,
10+
res: NextApiResponse<Data>
11+
) {
12+
res.status(200).json({ name: 'John Doe' })
13+
}

examples/with-tailwindcss/pages/index.js renamed to examples/with-tailwindcss/pages/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default function Home() {
1919
<p className="mt-3 text-2xl">
2020
Get started by editing{' '}
2121
<code className="p-3 font-mono text-lg bg-gray-100 rounded-md">
22-
pages/index.js
22+
pages/index.tsx
2323
</code>
2424
</p>
2525

0 commit comments

Comments
 (0)