ScanSkill

Style React Using External CSS

We can style React using external CSS stylesheet. We need to create a new file with a .css extension and import that file into the application.

Example

style.css

.div-1{
    background-color: red;
    height: 100px;
    width: 300px;
}

App,js

import React from 'react';
import './style.css';

const MyComponent = () => {
  return (
    <div className="div-1">
         This is my element.
    </div>
  );
}
Style React Using External CSS