October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

How to Install shadcn/ui with Vite, React, TypeScript, and Tailwind CSS v4 Using pnpm

Set up shadcn/ui in Vite with React, TypeScript, Tailwind CSS v4 and pnpm: Tailwind plugin, alias config, CLI init and your first component.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The short version: create a Vite React + TypeScript app, add Tailwind CSS v4 with the @tailwindcss/vite plugin, set up the @/* import alias in both TypeScript and Vite, run pnpm dlx shadcn@latest init, then add components with pnpm dlx shadcn@latest add. This guide follows the official shadcn/ui Vite guide and covers both new and existing projects.

Pick your starting point

  • New app: scaffold with Vite, or let the shadcn CLI scaffold a Vite project for you.
  • Existing Vite app: only configure what is missing (Tailwind, alias), then initialize shadcn/ui.

New project

Option A: Vite first

Create the app and choose the React + TypeScript template when prompted:

As an Amazon Associate I earn from qualifying purchases.

pnpm create vite@latest

Then continue with the existing-project steps below, which cover Tailwind, the alias and initialization.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Option B: let the shadcn CLI scaffold it

pnpm dlx shadcn@latest init -t vite

The CLI prompts for choices such as base, preset and monorepo options. The installation overview also describes shadcn/create, a tool for building a preset and generating a framework-specific command. The generated command depends on the options you pick in its UI, so use whatever it outputs.

Existing Vite project

Confirm you have a Vite React + TypeScript app. Skip any step already correctly configured.

1. Add Tailwind CSS v4

pnpm add tailwindcss @tailwindcss/vite

Replace the contents of src/index.css with:

@import "tailwindcss";

2. Configure the @/* alias for TypeScript

Vite splits TypeScript configuration across several files. The official guide adds baseUrl and paths to both tsconfig.json and tsconfig.app.json:

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

If @/* is already mapped, don’t add a second, conflicting entry.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Map the alias in Vite

Install Node type definitions so path and __dirname type-check:

pnpm add -D @types/node

Then update vite.config.ts so the bundler resolves the alias and loads the Tailwind plugin next to the React plugin:

import path from "path"
import tailwindcss from "@tailwindcss/vite"
import react from "@vitejs/plugin-react"
import { defineConfig } from "vite"

export default defineConfig({
  plugins: [react(), tailwindcss()],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
})

4. Initialize shadcn/ui

pnpm dlx shadcn@latest init

The CLI sets up its configuration and dependencies, adds the cn utility and configures CSS variables for theming. Answer the prompts; they vary with the CLI version.

5. Add components

Install only what you use:

pnpm dlx shadcn@latest add button

The component’s source is copied into your project, and you import it through the alias:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { Button } from "@/components/ui/button"

export default function App() {
  return <Button>Click me</Button>
}

Start the dev server (typically pnpm dev) and confirm the button renders with styling. If it appears unstyled, check that src/index.css is imported in your entry file and that the Tailwind plugin is in vite.config.ts. If imports fail to resolve, recheck both TypeScript files and the Vite alias.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Monorepos

Run the CLI from the app directory, or point it at the app with -c, for example -c apps/web. Depending on the generated structure, imports may use the workspace package path rather than @/.

Compatibility: Tailwind v4, React 19 and older projects

According to the shadcn/ui Tailwind v4 page, the CLI can initialize Tailwind v4 projects, and new projects start with Tailwind v4 and React 19. Existing Tailwind v3 and React 18 apps keep working, so you don’t need to upgrade just to add components. The page also warns that Tailwind v4 relies on modern browser features, so review its compatibility notes first if you support older browsers.

Manual installation

If you skip the CLI, the manual guide lists these dependencies:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
pnpm add shadcn class-variance-authority cn lucide-react tw-animate-css

It also supplies a stylesheet that imports tailwindcss, tw-animate-css and shadcn/tailwind.css, plus theme configuration. It allows aliases via TypeScript paths or package.json#imports. For Vite, the @/* setup above is the direct match.

A note on versions

The commands use @latest, so they track the current CLI rather than a pinned version, and prompts may change over time. Check the official Vite guide if a prompt or step differs from what is shown here.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.