Sorry for this lame question - I am quite new in tailwind and the utilities around it. What I want to achieve is to write some local styles for my components using tailwind and @apply. I use the latest nextJS with latest tailwindcss (v4) how can I use the @apply
directive in my local MyComponent.module.css
file?
I mean I have a MyComponent.tsx
like this:
import styles from "./MyComponent.module.css"; export default function MyComponent() { return <div className={styles.green}>Green Text Here</div> }
And in ./MyComponent.module.css
I would write something like this:
.green { @apply text-green-500 }
What package I need, and what setup to achieve this?
Note: in my layout.tsx
I include tailwindcss as usual:
import "@/styles/globals.scss";
where globals.scss looks as:
@import "tailwindcss";
Unfortunately - I got compiler error during npm run build
, saying
| Error: Cannot apply unknown utility class: text-green-500
however this classname works directly in components.