Installation
Setting up Tailwind CSS in a Rsbuild project.
Start by creating a new Rsbuild project if you don’t have one set up already. The most common approach is to use Rsbuild CLI.
npm create rsbuild@latest
Install @tailwindcss/postcss
and its peer dependencies.
npm add tailwindcss @tailwindcss/postcss -D
In your rsbuild.config.js
file, enable the PostCSS loader. See the documentation for more information.
import { defineConfig } from '@rsbuild/core'import tailwindCssPostcss from '@tailwindcss/postcss'export default defineConfig({ tools: { postcss: { postcssOptions: { plugins: [tailwindCssPostcss()], }, }, }})
Add an @import
to ./src/index.css
that imports Tailwind CSS.
@import "tailwindcss";
Run your build process with npm run dev
.
npm run dev
Start using Tailwind’s utility classes to style your content.
export default function App() { return ( <h1 className="text-3xl font-bold underline"> Hello world! </h1> )}