yosevu / react-content-script

An example project to build Chrome extensions using React and TypeScript. Ideal for developers looking to create efficient and modern Chrome extensions with a focus on a clean development workflow using Vite and crxjs.
202 stars 56 forks source link

using TailwindCSS for styling #16

Closed nkilm closed 1 year ago

nkilm commented 1 year ago

Description

How to add TailwindCSS to both content-script and popup html? I've tried installing Tailwind by referring the offical docs but the CSS is not getting applied. Any help would be appreciated.

yosevu commented 1 year ago

Hi @nkilm, I'll take a look at this and let you know!

yosevu commented 1 year ago

Is this the setup you wanted @nkilm?

I created an example in Popup src: https://github.com/yosevu/react-content-script/pull/17

nkilm commented 1 year ago

@yosevu Yes similar setup, but the example #17 you provided is not working for popup.

The tailwind classes are not applied to the popup,

/// <reference types="chrome" />
/// <reference types="vite-plugin-svgr/client" />

import Logo from "./Logo";
import "./App.css";

function App() {
  return (
    <div className="App">
      <header className="bg-gray-800 min-h-screen flex flex-col items-center justify-center text-white text-lg">
        // the above classes are not applied
        <Logo className="App-logo" id="App-logo" title="React logo" />
        <p>Hello, World!</p>
        <p>I'm a Chrome Extension Popup!</p>
      </header>
    </div>
  );
}

export default App;

e.g - bg-gray-800 should make the bg gray colored

image

yosevu commented 1 year ago

Hmm, let's see if we can troubleshoot @nkilm. Did you run yarn build and reload the extension from dist? Also, did you try on the branch I created: add-tailwindcss-example?

This is what I see:

Screen Shot 2023-03-12 at 2 12 46 PM
nkilm commented 1 year ago

@yosevu Ah it worked after I removed and added the extension with recent changes. Thank you so much Yosefu!✨