coreui / coreui-free-react-admin-template

Open source admin template based on Bootstrap 5 and React.js
https://coreui.io/product/free-react-admin-template/
MIT License
4.54k stars 2.26k forks source link

Tailwind support #421

Closed 10YAR closed 5 months ago

10YAR commented 5 months ago

Hello,

I've installed Tailwind by following the usual way (npm install autoprefixer postcss-cli tailwindcss) + created a tailwind.config.js and postcss.config.js

postcss.config.js content:

module.exports = {
  plugins: [require('tailwindcss')(), require('autoprefixer')()],
}

tailwind.config.js content:

/** @type {import('tailwindcss').Config} */
export default {
  mode: 'jit',
  content: ['./src/**/*.{js,jsx,ts,tsx}'],
  darkMode: 'class',
  theme: {
    extend: {}
  },
  variants: {
    extend: {},
  },
  plugins: [],
}

Also added a style.css file to ./assets/css/style.css with content:

@tailwind base;
@tailwind components;
@tailwind utilities;

And imported it in the index.js file :

import React from 'react'
import { createRoot } from 'react-dom/client'
import { Provider } from 'react-redux'
import 'core-js'
import './assets/css/style.css'

import App from './App'
import store from './store'

createRoot(document.getElementById('root')).render(
  <Provider store={store}>
    <App />
  </Provider>,
)

So the basic installation of tailwindcss on React, but it doesn't work. Even after a restart. When I add for example "h-96" in classNames attribute of an element, there are no styles applied to it.

Maybe there's something different to do with a CoreUI project...

10YAR commented 5 months ago

For people that encounter this problem, you can make it work by using the CDN version of tailwind css, i know it's not really a solution but if it can help others..

I added this code between <head>tags of the index.html file in the root: <script src="https://cdn.tailwindcss.com"></script>