TailwindCSS
Installing Tailwind
Since the RedwoodSDK is based on React and Vite, we can work through the “Using Vite” documentation.
-
Install Tailwind CSS
Terminal window npm install tailwindcss @tailwindcss/vite -
Configure the Vite Plugin
// vite.config.mtsimport { defineConfig } from "vite";import tailwindcss from '@tailwindcss/vite'import { redwood } from "@redwoodjs/sdk/vite";export default defineConfig({plugins: [redwood(),tailwindcss(),],}); -
Import Tailwind CSS Create a
src/app/styles.css
file.@import "tailwindcss"; -
Add a
<link>
to thestyles.css
file. In theDocument.tsx
file, within the<head>
section, add:src/app/Document.tsx <head>...<link rel="stylesheet" href="/src/app/styles.css" />...</head> -
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>