Tailwind CSS
Tailwind CSS is a utility-first CSS framework for rapidly building custom user interfaces. This guide will show you how to get started with Gatsby and Tailwind CSS.
Installing and configuring Tailwind
Please follow the official “Install Tailwind CSS with Gatsby” guide to install and configure Tailwind CSS with Gatsby. Some important notes when configuring Tailwind with Gatsby:
- It is not recommended that you include Gatsby’s output directories (
publicand.cache) in yourcontentarray in yourtailwind.config.js. You should only include your source files to have Tailwind working as expected. - If you use GraphQL Typegen a file at
src/gatsby-types.d.tswill be generated and with the default configuration forcontentintailwind.config.jsthis will trigger an infinite loop. You have two options to fix this:- Configure GraphQL Typegen’s
typesOutputPathoption to generate the file in another place - Adapt the
contentarray to not include thesrc/gatsby-types.d.tsfile, for example:
- Configure GraphQL Typegen’s