Skip to main content
Version: 0.23
note

Last checked with Wasp 0.21 and Shadcn (as of Feb 16, 2026).

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.

Shadcn

Setting up Shadcn in a Wasp projectโ€‹

We'll be loosely following the Vite instructions for Shadcn since Wasp is using Vite + React. Some of the steps don't apply, so we've adjusted them accordingly.

You won't be able to use the @ alias setup since it's not currently supported by Wasp. Because of this you'll need to adjust some imports when we generate components, but it should be fairly straightforward to do.

1. Add Tailwind CSSโ€‹

If you haven't added Tailwind CSS to your Wasp project yet, follow the instructions in the Tailwind CSS guide first.

2. Temporarily set up the @ aliasโ€‹

We need to temporarily setup the @ alias to pass Shadcn's "Preflight checks". We'll remove it later.

Add the following lines to your tsconfig.json:

tsconfig.json
{
"compilerOptions": {
// ...
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
// ...
}
}

3. Setup Shadcnโ€‹

Go into your project directory and run:

npx shadcn@latest init

Select the options like this:

โœ” Preflight checks.
โœ” Verifying framework. Found Vite.
โœ” Validating Tailwind CSS.
โœ” Validating import alias.
โœ” Which style would you like to use? โ€บ New York
โœ” Which color would you like to use as the base color? โ€บ Neutral
โœ” Would you like to use CSS variables for theming? โ€ฆ yes
โœ” Writing components.json.
โœ” Checking registry.
โœ” Updating tailwind.config.js
โœ” Updating src/Main.css
โœ” Installing dependencies.
โœ” Created 1 file:
- src/lib/utils.ts

4. Remove the @ aliasโ€‹

Remove the lines we added in the tsconfig.json:

tsconfig.json
{
"compilerOptions": {
// ...
- "baseUrl": ".",
- "paths": {
- "@/*": ["./src/*"]
- }
}
}

5. Adjust the components.jsonโ€‹

Adjust the aliases in components.json to be:

components.json
{
"$schema": "https://ui.shadcn.com/schema.json",
// ...
"aliases": {
"components": "src/components",
"utils": "src/lib/utils",
"ui": "src/components/ui",
"lib": "src/lib",
"hooks": "src/hooks"
},
}

Adding a componentโ€‹

In this example, we'll add the Button component.

1. Use the shadcn CLI to add the componentโ€‹

We'll add a button component with:

npx shadcn@latest add button

2. Adjust the utils importโ€‹

You'll notice that you now have a brand new button.tsx file in src/components/ui. We need to fix some import issues:

src/components/ui/button.tsx
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"

-import { cn } from "src/lib/utils"
+import { cn } from "../../lib/utils"

3. Use the Button componentโ€‹

That's it, now you are ready to use the Button component!

src/MainPage.tsx
import "./Main.css";

import { Button } from "./components/ui/button";

export const MainPage = () => {
return (
<div className="container">
<Button>This works</Button>
</div>
);
};