How to replace React components’ ugly styles with modern CSS.
With the help of a few tools and an old-school, modern-style web designer, we’re going to fix up the app for you.
Here’s what we’re working on and what you need to know.1.
React Styles¶When you create a React component, you create its parent component.
That component is the first one in your application that you’ll see in your React app.
So, in this tutorial, we’ll replace the default React component style with a modern one.
If you’re not familiar with the React style guide, we recommend checking out this tutorial.
The new style is simple, elegant, and consistent.
It should feel familiar to you.2.
Modern Components¶When a component is added to your React component tree, it creates a new component tree with its parent components, but the original components are hidden.
That means you can’t modify the styles of those components.
To change that, you need a way to get those components to display properly on the page.
We’ll be using the tag to create the styles.
In the examples, we use a
component that are nested in the
You can also create a component, which you can use to hide and display the rest of the content.3.
Advanced Styles¶For the sake of this tutorial and for simplicity, we won’t go into much detail on styling components.
We’ll just be showing how to add styles to elements and classes in the component tree.
To make things easier to follow, we also created a separate CSS file for the styles in our styles.css file.4.
Adding Modern Styles¶We’ll use the React StyleSheet to style our .
The style sheet uses two styles: a white background, and an inline-block element.
Each of these styles have a specific color, and they can be styled using the CSS Selector.
When you select an element in the style sheet, you can then change its color.
For example, if you select the .header element, you’ll change the background color to white.
, and tags are all styled with the same background color.5.
How to Replace React Components’ Unnecessary Styling with Modern Styles?
We’ll show you how to use the CSS selector to style elements, classes, and even elements that don’t exist in the DOM.
We’re going the full modern-designer route, though.
Let’s start by creating a style for our tag, which will be styled to white with an inline block: