skip to Main Content

The problem at hand is about finding alternative methods to apply CSS styles to React components without directly importing CSS files into the component.

I attempted to use inline styles by defining styles within JavaScript objects directly in the component JSX. While this approach worked well for simpler styling needs, it became cumbersome and less maintainable for larger stylesheets or complex styling requirements.

2

Answers


  1. With most bundler setups you could typically do:

    // App.tsx or equivalent top-level component
    
    import "./style.css";
    ...
    

    If this fails, you would have to include the relevant config for your bundler/framework.

    Login or Signup to reply.
  2. You can put internal as well external css for any of your project.

    if you want the import the css file without importing in component,
    you have to import in the main app component as

    import "./style.css";
    //or
    @import url('');
    

    or you can host your css file externally( such as https://github.com) and import in you project.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search