# styled-components

styled-components is a CSS-in-JavaScript library for styling React components.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## How to Structure and Organize a React Application

DevFeed: [How to Structure and Organize a React Application](<https://devfeed.tech/articles/how-to-structure-and-organize-a-react-application-37602.md>)

Original publisher: [Read original article](<https://www.taniarascia.com/react-architecture-directory-structure/>)

Author: hello@taniarascia.com

Published: 2021-06-23T00:00:00Z

Content type: tutorial

Language: en

Sources: [Tania Rascia](<https://devfeed.tech/sources/tania-rascia.md>)

Topics: [React](<https://devfeed.tech/topics/react.md>), [structure](<https://devfeed.tech/topics/structure.md>), [React Hooks](<https://devfeed.tech/topics/react-hooks.md>), [Redux](<https://devfeed.tech/topics/redux.md>), [React Router](<https://devfeed.tech/topics/react-router.md>), [styled-components](<https://devfeed.tech/topics/styled-components.md>), [Jest](<https://devfeed.tech/topics/jest.md>), [testing-library](<https://devfeed.tech/topics/testing-library.md>), [Authentication](<https://devfeed.tech/topics/authentication.md>)

Tags: [authentication](<https://devfeed.tech/tags/authentication.md>), [css](<https://devfeed.tech/tags/css.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [jest](<https://devfeed.tech/tags/jest.md>), [react](<https://devfeed.tech/tags/react.md>), [react-hooks](<https://devfeed.tech/tags/react-hooks.md>), [react-router](<https://devfeed.tech/tags/react-router.md>), [redux](<https://devfeed.tech/tags/redux.md>), [state-management](<https://devfeed.tech/tags/state-management.md>), [structure](<https://devfeed.tech/tags/structure.md>)

### AI overview

This tutorial presents an opinionated, feature-focused directory structure for organizing large-scale production React applications. It explains how to separate global shared components from feature-specific code and discusses accompanying choices for Redux, React Router, styling, testing, and authentication.

### Source excerpt

There is no consensus on the right way to organize a React application. React gives you a lot of freedom, but with that freedom comes the...

## Theme with styled-components and Typescript

DevFeed: [Theme with styled-components and Typescript](<https://devfeed.tech/articles/theme-with-styled-components-and-typescript-19124.md>)

Original publisher: [Read original article](<https://medium.com/rbi-tech/theme-with-styled-components-and-typescript-209244ec15a3?source=rss----904782439303---4>)

Author: Ethan Nguyen

Published: 2020-07-14T12:58:19Z

Content type: tutorial

Language: en

Sources: [RBI Tech](<https://devfeed.tech/sources/rbi-tech.md>)

Topics: [styled-components](<https://devfeed.tech/topics/styled-components.md>), [TypeScript](<https://devfeed.tech/topics/typescript.md>), [CSS](<https://devfeed.tech/topics/css.md>), [Design system](<https://devfeed.tech/topics/design-system.md>), [modern web development](<https://devfeed.tech/topics/modern-web-development.md>)

Tags: [css](<https://devfeed.tech/tags/css.md>), [dark-mode](<https://devfeed.tech/tags/dark-mode.md>), [design-system](<https://devfeed.tech/tags/design-system.md>), [design-systems](<https://devfeed.tech/tags/design-systems.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [styled-components](<https://devfeed.tech/tags/styled-components.md>), [themes](<https://devfeed.tech/tags/themes.md>), [typescript](<https://devfeed.tech/tags/typescript.md>), [visual-studio-code](<https://devfeed.tech/tags/visual-studio-code.md>)

### AI overview

A tutorial on theming applications with styled-components and TypeScript. It covers installation, Visual Studio Code support, declaration files, theme interfaces, naming conventions, theme creation, ThemeProvider setup, and switching between themes.

### Source excerpt

What is styled-components? Styled-components is arguably the most common CSS-in-JS library out there (Don't trust me? Check out their site and their adoption from many organizations, 7.6M/month downloads on NPM 🔥). One of its advanced use cases for this library is theming. Theming in styled-components allows your app to support multiple design patterns within the same app. Imagine an amazing code editor with no dark mode! Having options to customize the look and feel of your app from the primary colour palette to the typography scale can help our system to capture more personas. This article will give some breakdown of the basic setup and naming convention for theming your app with styled-components, and how to setup Typescript with styled-components themes Installationyarn add styled-components yarn add @types/styled-components -DVSCode plugin If you are using Visual Studio Code, I highly recommend installing this helpful plugin. It will highlight and IntelliSense your syntax for styled-components Create a declaration file Firstly, we will need to define how our theme interface looks like. Inside src folder, create styled.d.ts file and extend the existing styled-component DefaultTheme. This will help with IntelliSense and ensure a contract for all available themes. // styled.d.ts import 'styled-components';interface IPalette { main: string contrastText: string }declare module 'styled-components' { export interface DefaultTheme { borderRadius: string palette: { common: { black: string white: string } primary: IPalette secondary: IPalette } } }Naming convention Let's break down some logic here for the naming convention of theming. As I mentioned earlier, our goal for theming a system is to be able to control the compactness and colour palette. Hence we should define our theme around these styles like border-radius font-weight font-size ... and all colour related. About colour naming, avoid naming variable with actual colour but do name with something likeprimary or sec

## Using Tailwind CSS with Gatsby, React & Emotion Styled Components

DevFeed: [Using Tailwind CSS with Gatsby, React & Emotion Styled Components](<https://devfeed.tech/articles/using-tailwind-css-with-gatsby-react-emotion-styled-components-31316.md>)

Original publisher: [Read original article](<https://nystudio107.com/blog/using-tailwind-css-with-gatsby-react-emotion-styled-components>)

Author: andrew@nystudio107.com (Andrew Welch)

Published: 2019-10-20T14:08:00Z

Content type: tutorial

Language: en

Sources: [nystudio107 | Articles on modern web development.](<https://devfeed.tech/sources/nystudio107-articles-on-modern-web-development.md>)

Topics: [Tailwind CSS](<https://devfeed.tech/topics/tailwind.md>), [gatsby](<https://devfeed.tech/topics/gatsby.md>), [React](<https://devfeed.tech/topics/react.md>), [styled-components](<https://devfeed.tech/topics/styled-components.md>), [CSS](<https://devfeed.tech/topics/css.md>), [PostCSS](<https://devfeed.tech/topics/postcss.md>), [Babel](<https://devfeed.tech/topics/babel.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>)

Tags: [babel](<https://devfeed.tech/tags/babel.md>), [components](<https://devfeed.tech/tags/components.md>), [css](<https://devfeed.tech/tags/css.md>), [css-in-js](<https://devfeed.tech/tags/css-in-js.md>), [emotion](<https://devfeed.tech/tags/emotion.md>), [gatsby](<https://devfeed.tech/tags/gatsby.md>), [insights](<https://devfeed.tech/tags/insights.md>), [learn](<https://devfeed.tech/tags/learn.md>), [postcss](<https://devfeed.tech/tags/postcss.md>), [project](<https://devfeed.tech/tags/project.md>), [react](<https://devfeed.tech/tags/react.md>), [styled](<https://devfeed.tech/tags/styled.md>), [styled-components](<https://devfeed.tech/tags/styled-components.md>), [tailwind](<https://devfeed.tech/tags/tailwind.md>), [tailwind-css](<https://devfeed.tech/tags/tailwind-css.md>), [utility-first](<https://devfeed.tech/tags/utility-first.md>)

### AI overview

A tutorial on combining Tailwind CSS with Gatsby and React through Emotion Styled Components. It explains a hybrid setup using twin.macro for component-level Tailwind styles and PostCSS for Tailwind's base and global styles.

### Source excerpt

Learn how to use the utility-first Tailwind CSS with Emotion "CSS-in-JS" Styled Components in a Gatsby JS + React project.

## Screenshot testing with React and Storybook

DevFeed: [Screenshot testing with React and Storybook](<https://devfeed.tech/articles/screenshot-testing-with-react-and-storybook-24570.md>)

Original publisher: [Read original article](<https://medium.com/bleeding-edge/screenshot-testing-with-react-and-storybook-19ab7e49ec92?source=rss----d8ebe85cdc0f---4>)

Author: Jesse Pinho

Published: 2018-03-19T09:18:02Z

Content type: tutorial

Language: en

Sources: [Bleeding Edge - Medium](<https://devfeed.tech/sources/bleeding-edge-medium.md>)

Topics: [screenshot-testing](<https://devfeed.tech/topics/screenshot-testing.md>), [Storybook](<https://devfeed.tech/topics/storybook.md>), [React](<https://devfeed.tech/topics/react.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [styled-components](<https://devfeed.tech/topics/styled-components.md>), [Selenium](<https://devfeed.tech/topics/selenium.md>)

Tags: [continuous-integration](<https://devfeed.tech/tags/continuous-integration.md>), [react](<https://devfeed.tech/tags/react.md>), [screenshot-testing](<https://devfeed.tech/tags/screenshot-testing.md>), [selenium](<https://devfeed.tech/tags/selenium.md>), [storybook](<https://devfeed.tech/tags/storybook.md>), [styled-components](<https://devfeed.tech/tags/styled-components.md>), [testing](<https://devfeed.tech/tags/testing.md>), [visual-regression-testing](<https://devfeed.tech/tags/visual-regression-testing.md>)

### AI overview

The article explains why end-to-end UI tests can miss visual regressions and explores screenshot testing with React and Storybook to check component appearance across different states.

### Source excerpt

Visual regression testing for fun, profit, and peace of mind Illustration by Marta Pucci A friend of mine recently related a scary story about the lack of automated visual regression testing where he works--a huge international tech firm that you've heard of and probably use. He'd added a CSS class to an element to hide it from the user. Unbeknownst to him, and despite using BEM-style naming for CSS classes, this class name was already being used for an important checkbox in the user settings screen of his company's web app. The result? Users could no longer change the setting represented by the checkbox, because it was invisible! I asked him why that hadn't been caught by automated tests. He explained that, although they did have end-to-end tests in place that went through the UI and tested its functionality, the tests didn't catch the bug. Selenium was still able to check the original checkbox via its selector, so its visibility had no effect on the outcome of the test. The only way this could have been caught is via visual regression testing -- or, as it is sometimes called, screenshot testing. 💅 Switching to styled-components I recalled this story recently while working on a sizable project at Clue: converting all of our "native" CSS to use styled-components. The new helloclue.com website consists of dozens of components. An article page, for example, contains at least ten different React components, all of which have accompanying CSS files. Converting all of this CSS to styled-components means there's an enormous risk of bugs exactly like the one my friend experienced. So before the project began, I investigated setting up screenshot testing for the site. 📕 Enter Storybook (Note: if you're already familiar with Storybook and @storybook/react, feel free to skip to the next section.) We use Storybook when developing simple presentational components. This way, we can test them in every possible state, without having to reproduce all the logic and so forth required t