Vite
Install and configure Glass UI in a React Vite project.
Installation
Create a new project
Start by creating a new React project using Vite and TypeScript. If you already have a project, you can skip this step.
npm create vite@latestInstall Tailwind CSS
Install Tailwind CSS and its Vite plugin. If your project already has it configured, you can skip this step.
npm install tailwindcss @tailwindcss/viteConfigure Vite Plugin
Add the Tailwind CSS plugin to your vite.config.ts file:
Import Tailwind CSS
Replace the contents of your src/index.css with the Tailwind import directive:
Configure Path Aliases
Glass UI requires the @/ path alias for absolute imports. If your project already has this configured, you can skip this step.
First, install Node types to use the path module:
npm install -D @types/nodeUpdate vite.config.ts
Add the resolve alias to your Vite configuration:
Update tsconfig.app.json
Vite uses multiple tsconfig files. Add the paths configuration to your tsconfig.app.json (or tsconfig.json if you are on an older Vite version):
Run the CLI
Run the init command to set up your configuration, base utilities, and global styles.
npx @glass-ui-kit/cli@latest initAdd your first component
You can now start adding glassmorphism components to your project. Let’s add the Card component:
npx @glass-ui-kit/cli@latest add cardUse the component
Clear your src/App.tsx and replace it with the following code to see Glass UI in action: