Skip to content

Vite + React

Setup Space UI in a modern Vite React SPA with Tailwind CSS v4 and TypeScript path aliases.

This guide walks you through setting up Space UI in a Vite + React 19 Single Page Application using Tailwind CSS v4 and the official @tailwindcss/vite plugin.

Path Aliases: Vite requires configuring path resolution in vite.config.ts and tsconfig.json so that the @/components aliases work seamlessly with the shadcn CLI.

Create a Vite Project

Scaffold a new Vite React application with TypeScript:

Bash

Install Tailwind CSS v4 & Core Dependencies

Install @tailwindcss/vite, Tailwind CSS v4, Base UI, Motion, and utility libraries:

Bash

Configure Path Aliases in vite.config.ts

Update vite.config.ts to add the @ path alias and load the Tailwind CSS plugin:

vite.config.ts

Update tsconfig.json and tsconfig.app.json

Add path mappings to tsconfig.app.json (or tsconfig.json):

tsconfig.app.json

Configure src/index.css

Import Tailwind CSS and declare the theme variables in src/index.css:

src/index.css

Initialize Space UI Preset

Run the preset initializer to create components.json:

Bash

Add Components

Install components into your Vite project:

Bash

Test in src/App.tsx

Import and test your component:

src/App.tsx