-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Learn React with TypeScript
By :

In this chapter, we learned three methods of styling and their pros and cons.
First, we learned that plain CSS could be used to style React apps, but all the styles in the imported CSS file are bundled regardless of whether a style is used. Also, the styles are not scoped to a specific component – we observed the container
CSS class names clashing with the App
and Alert
components.
Next, we learned about CSS modules, which allow us to write plain CSS files imported in a way that scopes styles to the component, allowing it to be used anywhere in the app. We learned that CSS modules is an open source library pre-installed and preconfigured in projects created with Vite. We saw how this resolved the CSS clashing problem but didn’t remove redundant styles.
We looked at styling with the popular Tailwind CSS library. We learned that Tailwind provides a set of reusable CSS classes that can be applied to React elements, including a nice default color palette...