Last checked with Wasp 0.21 and Tailwind 4.
This guide depends on external libraries or services, so it may become outdated over time. We do our best to keep it up to date, but make sure to check their documentation for any changes.Tailwind CSS
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.
Adding Tailwind to your Wasp 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.tsfile:vite.config.tsimport { wasp } from 'wasp/client/vite'
import tailwindcss from '@tailwindcss/vite'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
wasp(),
tailwindcss()
],
server: {
open: true,
},
}) -
Import Tailwind into your base CSS file. For example, in a project created with
wasp newyou might import Tailwind intoMain.css.src/Main.css@import "tailwindcss";
/* ... */ -
Start using Tailwind 🥳
- JavaScript
- TypeScript
src/MainPage.jsx// ...
<h1 className="text-3xl font-bold underline">Hello world!</h1>;
// ...src/MainPage.tsx// ...
<h1 className="text-3xl font-bold underline">Hello world!</h1>;
// ...
Adding Tailwind Plugins
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";
/* ... */