How to import a CSS file in a React Component
You don't even have to name it if you don't need to:
e.g.
import React from 'react';
import './App.css';
see a complete example here (Build a JSX Live Compiler as a React Component).
in react, how to change CSS files linked in the head of index.html?
so what I did is getting the link tag that has the direction style and changes it's href to the other CSS file, and it works fine.
index.html
<link rel="stylesheet" id="style-direction" href="/css/style-ltr.css">
then in the component, i do something like that
const style = document.getElementById('style-direction');
if (lang === 'ar') {
style.href = '/css/style-ltr.css';
} else {
style.href = '/css/style-rtl.css';
}
Related Topics
How to Apply Theme to Jupyter Lab
Is It Bad Practice to Use Negative Margins or Padding in CSS
Sass Watching Multiple Directories
How to Place Div Inside Another Div to Absolute Position
How to Add Compass Syntax Support to Jetbrains PHPstorm
CSS Fade Out Horizontal Rule/Line Styled Div Effect Without Images
Cannot Understand the Use of :Host in Components in Angular2
How to Get Only One Rounded Corner with Border-Radius Htc Hack and Msie V:Roundrect
React Pseudo Selector Inline Styling
CSS Difference Between Background: and Background-Image:
How to Center Variable Width Divs in CSS
CSS Floats, Change Order on Mobile Layout
Why Do Anchor Pseudo-Classes A:Link, :Visited, :Hover, :Active Need to Be in Correct Order
CSS Sibling Absolute Positioning
How to Change Background-Color on Text Links on Hover But Not Image Links