简体   繁体   中英

How to use multiple CSS modules with Tailwind in Remix.js?

I'm using Remix with Tailwind css. currently I followed the tailwind and remix docs to add a global css file:

"scripts": {
  "dev:css": "tailwindcss -i ./styles/tailwind.css -o ./app/styles/tailwind.css -w"
}

But what if I want to have a tailwind css file for a single component? like so:

# app/components/button.css
.button-primary {
  @apply bg-slate-400;
}
// app/components/Button.jsx
import './button.css'

export function Button() {
  return <button className='button-primary'>My Button</button>
}

Remix doesn't throw any errors but the styles are not applied, not sure if this is related to tailwind not parsing the button.css file or remix's issue

CSS modules are not currently supported in remix, you can follow the relevant discussion in the repo: https://github.com/remix-run/remix/discussions/2214

For now, you will need to expose your component CSS using the links() function on every route that uses it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM