Skip to content
4th April 2025: This is a preview, whilst production-ready, it means some APIs might change

TailwindCSS

Installing Tailwind

Since the RedwoodSDK is based on React and Vite, we can work through the “Using Vite” documentation.

  1. Install Tailwind CSS

    Terminal window
    npm install tailwindcss @tailwindcss/vite
  2. Configure the Vite Plugin

    // vite.config.mts
    import { defineConfig } from "vite";
    import tailwindcss from '@tailwindcss/vite'
    import { redwood } from "@redwoodjs/sdk/vite";
    export default defineConfig({
    plugins: [
    redwood(),
    tailwindcss(),
    ],
    });
  3. Import Tailwind CSS Create a src/app/styles.css file.

    @import "tailwindcss";
  4. Add a <link> to the styles.css file. In the Document.tsx file, within the <head> section, add:

    src/app/Document.tsx
    <head>
    ...
    <link rel="stylesheet" href="/src/app/styles.css" />
    ...
    </head>
  5. Now, you can run pnpm run dev and the “Hello World” text should look different.

    Terminal window
    pnpm run dev

Customizing TailwindCSS

With Tailwind v4, there is no longer a tailwind.config.js file for customizations. Instead, we use the styles.css file.

All of your customizations should be within a @theme block.

@import "tailwindcss";
@theme {
--color-bg: #e4e3d4;
}

Now, this custom color can be used:

<div className="bg-bg">
<h1>Hello World</h1>
</div>

Further reading