Based on your previous question about flipping the shadcn chevron, I understand you're asking about properly configuring Tailwind CSS in a Next.js project to ensure the peer modifier works correctly. Let me explain how to set this up:
Configuring Tailwind CSS in Next.js
Installing Tailwind CSS
First, install the necessary packages:
npm install -D tailwindcss @tailwindcss/postcss postcss
Setting up PostCSS Configuration
Create a postcss.config.mjs file in the root of your project:
export default {
plugins: {
'@tailwindcss/postcss': {},
},
}
Importing Tailwind Styles
For Next.js with the App Router, add this to your app/globals.css file:
@import 'tailwindcss';
Then import this CSS file in your root layout:
import './globals.css'
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body>{children}</body>
</html>
)
}
For Pages Router, add the import to your styles/globals.css and import it in pages/_app.tsx:
import '@/styles/globals.css'
Ensuring Peer Modifiers Work
For your specific chevron rotation case, the peer modifier should work as long as:
- The
peer class is on your trigger element
- The element you want to style (the chevron) is a sibling of the peer element
- You're using the correct data attribute selector
Your current implementation looks correct: