Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using inline-css in React #87

Open
erfoon opened this issue Jun 26, 2019 · 4 comments
Open

Using inline-css in React #87

erfoon opened this issue Jun 26, 2019 · 4 comments
Labels

Comments

@erfoon
Copy link

erfoon commented Jun 26, 2019

Hi,
I want to use exact same functionality that is presented in this repo in front-end side (React project). Can this library do that for me? Because as I tested it doesn't work for in project (webpack doesn't get built). Any suggestions?

Thanks

@jonkemp
Copy link
Owner

jonkemp commented Jul 2, 2019

I would suggest changing the title to 'Using inline-css in React' first to get more visibility to this issue.

I haven't tested it with webpack, only gulp. And I wouldn't expect it to work with React as it only works with HTML in the page at runtime, not the HTML injected into the page at runtime.

It could potentially work with Gatsby or Next.js, or something that uses pre-rendering.

@bryik
Copy link

bryik commented Nov 17, 2020

Is this issue about literally using inline-css in React (to manipulate some HTML) or is it about applying inline-css to a React project (I guess to convert classes defined in .css files into inline styles within components)?

I am interested in the first case, but I'm not sure if I should +1 this issue or create a new one.


FWIW: Attempting to import inline-css in a React project produced some kind of bundler error: TypeError: Cannot read property 'native' of undefined. Observable's module require debugger is unable to import it as well:

😭 Okay, so: nothing worked. We tried UMD, we tried bundling, we tried searching for random files that might be loadable. Unfortunately, no 🎲. This doesn’t mean nothing can work - this is an automated tool and doesn’t have human intuition. You might want to browse the files this module exposes on unpkg to see if any of them look viable. Or you might want to ask the module’s author whether there’s a file that people can use with browsers. Where there’s a will there’s a way: good luck. (This also means that all of the grayed-out solutions below won’t work.)

@jonkemp jonkemp changed the title Using inline-css in browser Using inline-css in React Nov 17, 2020
@jonkemp
Copy link
Owner

jonkemp commented Nov 17, 2020

I changed the title to match the original question. How this module is integrated with React is up to us I guess.

@evbo
Copy link

evbo commented Mar 11, 2022

If I'm not mistaken, this project aims to remove inline style tags from HTML and put them in CSS file. This would be enormously helpful if it worked with React and Webpack because it would automate CSP policy by enforcing no inline style tags exist!

So this is a really great thing. @jonkemp do you know if such automation exists or could exist? Inline style tags are super convenient, but CSP exists for a reason and inline style tags should never exist in production code! If this or some such pre-processor could stuff all inline tags into CSS files that would be amazing.

UPDATE*

This is what I was looking for: https://github.com/tailwindlabs/tailwindcss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants