Migrate to Netlify Today

Netlify announces the next evolution of Gatsby Cloud. Learn more

PostCSS

PostCSS transforms extended syntaxes and features into modern, browser-friendly CSS. This guide will show you how to get started with Gatsby and PostCSS.

Installing and configuring PostCSS

This guide assumes that you have a Gatsby project set up. If you need to set up a project, head to the quick start guide, then come back.

  1. Install the Gatsby plugin gatsby-plugin-postcss.
  1. Include the plugin in your gatsby-config.js file.

Note: If you need to pass options to PostCSS use the plugins options; see postcss-loader for all available options.

  1. Write your stylesheets using PostCSS (.css files) and require or import them as normal.

With CSS modules

To use CSS modules, prepend .module to the extension. For example: App.css -> App.module.css. Any file with the module extension will use CSS modules.

PostCSS plugins

If you would prefer to add additional postprocessing to your PostCSS output you can specify plugins in the plugin options:

Alternatively, you can use postcss.config.js to specify your particular PostCSS configuration:

Other resources

Start building today on Netlify!
Edit this page on GitHub
© 2024 Gatsby, Inc.