Next.js Discord

Discord Forum

How can i link my tailwindcss to next.js repo

Answered
lun ツ posted this in #help-forum
Open in Discord
i have tailwindcss.config.js,postcss.config.js,but it didnt works
Answered by @ts-ignore
@lun ツ restart the dev server
View full answer

23 Replies

tailwind.config.js
/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./pages/**/*.{js,ts,jsx,tsx}",
    "./components/**/*.{js,ts,jsx,tsx}"
  ],
  theme: {
    extend: {},
  },
  plugins: [],
};

postcss.config.js
module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
}

next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  swcMinify: true,
}

module.exports = nextConfig

../pages/index.tsx
import type { NextPage } from 'next'
import Head from 'next/head'

const Home: NextPage = () => {
  return (
    <div>
      <Head>
        <title>VALLIANTY</title>
      </Head>

      <h1 className='p-10 text-red-500'>test</h1>
    </div>
  )
}

export default Home

but u just dont know why h1 element didnt change color and font-size
iirc postcss.config.css should be postcss.config.js
he probably had typo IG
@lun ツ restart the dev server
Answer
delete .next
Nah wait the author to describe more about his issue, he didn't said tailwind css not working, but instead
h1 element didnt change color and font-size
but surly it can't work if the postcss file is not existent...?
Tailwind CSS does a [Preflight](https://tailwindcss.com/docs/preflight), it resets the default styles of heading elements. You have to do:
<h1 className="text-xl">Hello World</h1>

So that you can get the same look cross browsers/platforms
@lun ツ U followed all steps? in that guide
!!
@dumbboy <@1038029376924688394> U followed all steps? in that guide
i think yes
i read the documents the whole night yesterday
alright restart magic :bigbrain:
the old saying have you tried turning it on and off again
:Acat_stare:
think we should add this to Next.js faq, it helps a lot
thank u guys~~
:B007: