Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between index.css and App.css? [duplicate]

Tags:

css

reactjs

I usually define global styles in index.css. What is the best practice to define global style? When should I put it in index.css vs App.css when I work on React app?

like image 526
ChuChu Avatar asked Jun 30 '26 02:06

ChuChu


1 Answers

For a React app, the best practice is to put every component in its own directory containing its corresponding JS and CSS files. The App component is the topmost component in a React app for wrapping all components. There aren't any predefined rules for using App.css or index.css for global CSS.

Check out this article for React styling best practices: https://medium.com/the-non-traditional-developer/styling-best-practices-using-react-c37b96b8be9c

Relevant question: index.css vs. App.css in default app created by "create-react-app" -- what's the difference?

like image 83
waqas Mumtaz Avatar answered Jul 01 '26 16:07

waqas Mumtaz