Skip to main content
Update: We have added full support for React 19 and Tailwind v4 in the canary release. See the docs for Tailwind v4 for more information.
1
Create project
2
Start by creating a new Gatsby project using create-gatsby:
3
npm init gatsby
4
Configure your Gatsby project to use TypeScript and Tailwind CSS
5
You will be asked a few questions to configure your project:
6
✔ What would you like to call your site?
· your-app-name
✔ What would you like to name the folder where your site will be created?
· your-app-name
✔ Will you be using JavaScript or TypeScript?
· TypeScript
✔ Will you be using a CMS?
· Choose whatever you want
✔ Would you like to install a styling system?
· Tailwind CSS
✔ Would you like to install additional features with other plugins?
· Choose whatever you want
✔ Shall we do this? (Y/n) · Yes
7
Edit tsconfig.json file
8
Add the following code to the tsconfig.json file to resolve paths:
9
{
  "compilerOptions": {
    // ...
    "baseUrl": ".",
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
    // ...
  }
}
10
Create gatsby-node.ts file
11
Create a gatsby-node.ts file at the root of your project if it doesn’t already exist, and add the code below to the gatsby-node file so your app can resolve paths:
12
import * as path from "path"

export const onCreateWebpackConfig = ({ actions }) => {
  actions.setWebpackConfig({
    resolve: {
      alias: {
        "@/components": path.resolve(__dirname, "src/components"),
        "@/lib/utils": path.resolve(__dirname, "src/lib/utils"),
      },
    },
  })
}
13
Run the CLI
14
Run the shadcn init command to setup your project:
15
npx shadcn@latest init
16
Configure components.json
17
You will be asked a few questions to configure components.json:
18
Would you like to use TypeScript (recommended)? no / yes
Which style would you like to use? › Default
Which color would you like to use as base color? › Slate
Where is your global CSS file? › › ./src/styles/globals.css
Do you want to use CSS variables for colors? › no / yes
Where is your tailwind.config.js located? › tailwind.config.js
Configure the import alias for components: › @/components
Configure the import alias for utils: › @/lib/utils
Are you using React Server Components? › no
19
That’s it
20
You can now start adding components to your project.
21
npx shadcn@latest add button
22
The command above will add the Button component to your project. You can then import it like this:
23
import { Button } from "@/components/ui/button"

export default function Home() {
  return (
    <div>
      <Button>Click me</Button>
    </div>
  )
}

Build docs developers (and LLMs) love