web/docs/guides/libraries/tailwind.md
import LastCheckedWithVersionsNotice from "@site/src/components/LastCheckedWithVersionsNotice";
<LastCheckedWithVersionsNotice versions={{ Wasp: "0.24", Tailwind: 4 }} />
Wasp works great with Tailwind CSS, a utility-first CSS framework. You can use Tailwind CSS by setting it up through their Vite installation method, as with any other project.
Install Tailwind and its Vite plugin.
npm install tailwindcss
npm install -D @tailwindcss/vite
Add the Tailwind CSS Vite plugin to your vite.config.ts file:
import { wasp } from 'wasp/client/vite'
// highlight-next-line
import tailwindcss from '@tailwindcss/vite'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
wasp(),
// highlight-next-line
tailwindcss()
],
server: {
open: true,
},
})
Import Tailwind into your base CSS file. For example, in a project created with wasp new you might import Tailwind into Main.css.
@import "tailwindcss";
/* ... */
Start using Tailwind 🥳
// ...
<h1 className="text-3xl font-bold underline">
Hello world!
</h1>
// ...
Wasp doesn't require any special configuration to use Tailwind plugins. You can follow each plugin's installation instructions as you normally would.
For example, to add the Tailwind Forms and Tailwind Typography plugins, we can check the installation instructions on their respective documentation pages and follow them as usual:
npm install -D @tailwindcss/forms
npm install -D @tailwindcss/typography
@import "tailwindcss";
@plugin "@tailwindcss/forms";
@plugin "@tailwindcss/typography";
/* ... */