wrapped in a useEffect hook and add a state value that is set to true after the stylesheet is appended to the document head.

const [isLinkElementLoaded, setLinkElementLoaded] = useState(false)

    useEffect(() => {
    const linkElement = document.createElement("link");
          linkElement.setAttribute("rel", "stylesheet");
          linkElement.setAttribute("type", "text/css");
          linkElement.setAttribute(
            "href",
            "//fake.net/thirdpartylibrary.js/latest/thirdpartylibrary.min.css"
          );
          document.head.appendChild(linkElement);

          setLinkElementLoaded(true)
    }, []);

return (
          <>
            {isLinkElementLoaded && <div>Styled Component</div>}
          </>
)
Answer from hustle100 on Stack Overflow
๐ŸŒ
Medium
medium.com โ€บ @anuththaraneranji โ€บ adding-external-css-and-inline-css-in-react-f717d9cf37ee
Adding External CSS and Inline CSS in React | by NeranjiAbeysekara | Medium
September 9, 2024 - import React from 'react'; function ... it the style object. External CSS: Keeps styles separate from your components, making it easier to manage and reuse styles across multiple components....
๐ŸŒ
Altcademy
altcademy.com โ€บ blog โ€บ how-to-use-external-css-in-reactjs
How to use external css in ReactJS
November 10, 2023 - When we talk about external CSS, we refer to the approach where we write CSS in separate files from the HTML file. This approach can make the code more modular and easier to maintain, especially for larger projects.
๐ŸŒ
Create React App
create-react-app.dev โ€บ docs โ€บ adding-a-stylesheet
Adding a Stylesheet | Create React App
import React, { Component } from 'react'; import './Button.css'; // Tell webpack that Button.js uses these styles class Button extends Component { render() { // You can use them as regular CSS styles return <div className="Button" />; } } Copy ยท This is not required for React but many people find this feature convenient. You can read about the benefits of this approach here. However you should be aware that this makes your code less portable to other build tools and environments than webpack. In development, expressing dependencies this way allows your styles to be reloaded on the fly as you edit them.
๐ŸŒ
W3Schools
w3schools.com โ€บ react โ€บ react_css.asp
React CSS
React Compiler React Quiz React Exercises React Syllabus React Study Plan React Server React Interview Prep React Bootcamp React Certificate ... There are many ways to style React with CSS, this tutorial will take a closer look at inline styling, and CSS stylesheet.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ reactjs โ€บ how-to-import-a-css-file-in-react
How to import a CSS file in React ? - GeeksforGeeks
July 23, 2025 - Steps to Import a CSS file in a React ยท Importing an External CSS File ยท Using Inline CSS in React ยท Using Internal CSS in React ยท Step 1: Create a new ReactJS project and install the required dependencies:- npx create-react-app css-app ยท Step 2: Navigate to the root directory of your project using the following command.
Find elsewhere
๐ŸŒ
SitePoint
sitepoint.com โ€บ blog โ€บ javascript โ€บ styling in react: from external css to styled components
Styling in React: From External CSS to Styled Components โ€” SitePoint
November 7, 2024 - CSS Modules use separate CSS files and hash class names to provide granular style, Glamor allows CSS declaration in the same file as JavaScript, and styled-components keep React components and styles together.
Top answer
1 of 2
1

The best way I've found to use styles in react to avoid that type of problem is the use of styled-components (23k+ stars on github)

Example of styled-components usage:

const Button = styled.a`
  /* This renders the buttons above... Edit me! */
  display: inline-block;
  border-radius: 3px;
  padding: 0.5rem 0;
  margin: 0.5rem 1rem;
  width: 11rem;
  background: transparent;
  color: white;
  border: 2px solid white;

  /* The GitHub button is a primary button
   * edit this to target it specifically! */
  ${props => props.primary && css`
    background: white;
    color: palevioletred;
  `}
`

render(
  <div>
    <Button
      href="https://github.com/styled-components/styled-components"
      target="_blank"
      rel="noopener"
      primary
    >
      GitHub
    </Button>

    <Button as={Link} href="/docs" prefetch>
      Documentation
    </Button>
  </div>
)

Ref: https://www.styled-components.com/

 External CSS

If you are using external css you can parse it with:

import { css } from "styled-components";

// Css loaded as string and passed to css method of styled-components
export const borderBottom = css`
    &:after{
        content: "";
        display: block;
        height: 3px;
        width: 200px;
        background-color: ${props => props.color || "black"};
        /* position */
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
`;

Be aware that if you want to pack your css as string an edit to your webpack config may be needed.

Another way to import existing styles in styled-components

import React, { Component } from "react";
import ReactDOM from "react-dom";
import Styled from "styled-components";

const fetchStyles = () =>
  fetch(
    "https://gist.githubusercontent.com/bionicvapourboy/61d3d7a8546cb42e0e3194eb9505f48a/raw/5432218dd83320d53d1cbc2f230b81c765183585/style.css"
  ).then(response => response.text());

class App extends Component {
  state = {
    style: ""
  };

  componentDidMount() {
    fetchStyles().then(data => this.setState({ style: data }));
  }

  Wrapper = () => Styled.div`
    ${this.state.style}
  `;
  render() {
    const Wrapper = this.Wrapper();
    return (
      <div className="App">
        <Wrapper>
          <h1>Styled</h1>
        </Wrapper>
        <h1>Not Styled</h1>
        <h2>Start editing to see some magic happen!</h2>
      </div>
    );
  }
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

https://codesandbox.io/s/yw7xmx6x3x

2 of 2
-1

You can try using this:

import React from 'react'

let cssLoaded = false;

export default class MyComponent extends React.Component {
    render() {
        if (cssLoaded === false) {
            cssLoaded = true;
            import('./MyComponentStyle.css');
        }

        // other stuff
    }
}

And in your css file: @import url('example.com/styles.css'); Source: React: Load component's CSS only when component is rendered

๐ŸŒ
Elightwalk
elightwalk.com โ€บ home
Different Ways to Import CSS Files in React
August 5, 2025 - Explore straightforward methods for importing CSS in React, encompassing the utilization of external stylesheets, CSS Modules, and inline styles.
Price ย  $
Call ย  +917600897405
Address ย  611, Shivalik Square, near Adani CNG pump, Ramapir Thekra, Nava Vadaj, 380027, Ahmedabad
๐ŸŒ
Saleh Mubashar
salehmubashar.com โ€บ blog โ€บ different-ways-to-add-css-in-react-js
Different Ways to add CSS in React JS
You can create a new CSS file in your project directory and add your CSS inside it. It can then be imported into your React component or class. The following code is used to import an external CSS stylesheet.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ how-to-style-react-components
How to Style React Components
May 22, 2024 - Using external stylesheets is a common styling approach in React because it's straightforward. All you need to do is create a CSS file, define your styles in it, and then import the stylesheet into your React component.
๐ŸŒ
DEV Community
dev.to โ€บ theudemezue โ€บ how-to-import-a-css-file-in-react-js-473a
How To Import a CSS File In React JS - DEV Community
March 26, 2025 - This simple import ensures that your CSS file is bundled with your component and applied correctly. After making these changes, run your application by typing: ... This command starts the development server and opens your React app in a browser.
๐ŸŒ
DEV Community
dev.to โ€บ salehmubashar โ€บ 3-ways-to-add-css-in-react-js-336f
Different Ways to add CSS in React JS - DEV Community
April 23, 2023 - You can create a new CSS file in your project directory and add your CSS inside it. It can then be imported into your React component or class. The following code is used to import an external CSS stylesheet.
๐ŸŒ
Locofy
locofy.ai โ€บ blog โ€บ 5-ways-to-handle-css-in-react
5 Ways to Handle CSS in React | Locofy Blogs
The easiest way to include CSS inside your React project is by creating a CSS file and importing it to the React file. This is similar to how you would use an external CSS file inside HTML files.
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ what-are-the-different-ways-to-add-css-in-react-js
What are the different ways to add CSS in React JS?
You can create a new CSS file in your project directory and add your CSS inside it. You can then import the file in your component, class, or React JS page. You can use the code below to import an external CSS stylesheet:
๐ŸŒ
Geekster
geekster.in โ€บ home โ€บ using css in react
Using CSS In React With Example
June 13, 2024 - Developers can create separate CSS files and import them into their React components using the import statement. This traditional approach allows for separation of concerns, where CSS styles are maintained separately from the component logic.