rsnext/examples/with-tailwindcss
2019-05-18 21:07:39 +02:00
..
components Fix GitHub spelling (#7024) 2019-04-13 17:36:07 +02:00
pages Refactor with tailwindcss example to use next-css (#5461) 2018-11-08 14:42:55 +01:00
styles Merge branch 'canary' 2019-02-11 08:22:31 +01:00
next.config.js Refactor with tailwindcss example to use next-css (#5461) 2018-11-08 14:42:55 +01:00
package.json Test updater script on examples folder (#5993) 2019-01-05 12:19:27 +01:00
postcss.config.js Refactor with tailwindcss example to use next-css (#5461) 2018-11-08 14:42:55 +01:00
README.md Remove outdated "extras" section in with-tailwindcss example README (#7379) 2019-05-18 21:07:39 +02:00
tailwind.config.js Refactor with tailwindcss example to use next-css (#5461) 2018-11-08 14:42:55 +01:00

Tailwind CSS example

This is an example of how you can include a global stylesheet in a next.js webapp.

How to use

Using create-next-app

Execute create-next-app with Yarn or npx to bootstrap the example:

npx create-next-app --example with-tailwindcss with-tailwindcss-app
# or
yarn create next-app --example with-tailwindcss with-tailwindcss-app

Download manually

Download the example:

curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/with-tailwindcss
cd with-tailwindcss

Running

To get this example running you just need to

npm install
npm run dev
# or
yarn
yarn dev

Visit http://localhost:3000 and try to modify styles/index.css.

Deploy it to the cloud with now (download)

now

The idea behind the example

This setup is a basic starting point for using tailwind css and next. Along with tailwind, this example also uses some other postcss plugins for imports, autoprefixing, and stripping whitespace/comments. The imports simply allow for an easy way to split up css files but still get one bundled css file in static/css/bundle.css. Changing stylesheets does not trigger auto-reloads. Setting up auto-reloads was avoided because the next.js read me does not recommend doing so. Although, that can easily be done with some webpack loaders. If you are curious about using loaders with next look at this example.

This project shows how you can set it up. Have a look at:

  • pages/_document.js
  • styles/config/postcss.config.js
  • styles/config/tailwind.config.js
  • styles/index.css
  • styles/button.css