You never have to worry about duplication, overlap or misspellings. No class name bugs: Styled Components generates unique class names for your styles.Combined with code splitting, this means your users load the least amount of code necessary. Automatic critical CSS: Styled Components keeps track of which components are rendered on a page and injects their styles and nothing else, fully automatically.Styled Components was created because of the following reasons: It removes the mapping between components and styles - component is made into a low-level styling construct. Styled Components enable writing of CSS in JavaScript using tagged template literals. It helps to write CSS that's scoped to a single component and does not leak to any other element in the page. Styled Components allow you to write plain CSS in your components without worrying about class name collisions. Styling Fragmentation: Using CSS-in-JS means you can write styles freely without worrying about compatibility issues.Īn example of the CSS-in-JS approach is styled-components.Reduce the number of HTTP requests: CSS-in-JS would mean that we don't have to make HTTP requests to load assets and resources.The benefits of using CSS-in-JS includes: This is the idea that CSS can be scoped to a specific component only and as opposed to the document level. This is popularly known as CSS-in-JS.ĬSS-in-JS is a styling approach that abstracts the CSS model to the component level, rather than the document level. There's the general and oldest method of styling at document level - creating a style.css file and linking to it in the HTML file and more recently the method of styling in JS. So much has been said about the appropriate way to style modern web apps.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |