gatsby styled-components plugin code example

Example 1: gatsby-plugin-styled-components

npm install --save gatsby-plugin-styled-components styled-components babel-plugin-styled-components

# yarn 
yarn add  gatsby-plugin-styled-components styled-components babel-plugin-styled-components


# Edit gatsby-config.js

module.exports = {
  plugins: [
    {
      resolve: `gatsby-plugin-styled-components`,
      options: {
        // Add any options here
      },
    },
  ],
}

Example 2: install styled components in Gatsby

npm install gatsby-plugin-styled-components styled-components babel-plugin-styled-components

Also requires this addition to gatsby-config.js
module.exports = {
  plugins: [`gatsby-plugin-styled-components`],
}