Skip to content

Vite

Install Shark UI in a Vite project.

Use the Shark Preset

Create Project

Run the init command with the Shark preset and the Vite template:

Add Components

You can add components with the CLI or copy them manually from the component docs:

  • CLI: Run npx shadcn@latest add @shark/<component> (e.g. button, dialog).
  • Manual: Copy component source from Manual tab in the component docs.

For example, add the Button component to your project:

You can also install every component at once:

Then import and use components like this:

src/App.tsx

Use the CLI

Create Project

Run the init command to scaffold a new Vite project and configure Shark UI:

For a monorepo project, use the --monorepo flag:

Add Components

You can add components with the CLI or copy them manually from the component docs:

  • CLI: Run npx shadcn@latest add @shark/<component> (e.g. button, dialog).
  • Manual: Copy component source from Manual tab in the component docs.

For example, add the Button component to your project:

If you created a monorepo, run the command from apps/web or specify the workspace from the repo root:

You can also install every component at once:

Then import and use components like this:

src/App.tsx

If you created a monorepo, update apps/web/src/App.tsx and import from your workspace UI package instead.

Existing Project

Create Project

If you need a new Vite project, create one first and select the React + TypeScript template. Otherwise, skip this step.

Add Tailwind CSS

If your project already has Tailwind CSS configured, skip this step.

Replace everything in src/index.css with the following:

src/index.css

Edit tsconfig.json

Vite splits TypeScript config across multiple files. Add baseUrl and paths to the compilerOptions in both tsconfig.json and tsconfig.app.json:

tsconfig.json

Edit tsconfig.app.json

Add the same path resolution so your IDE resolves imports correctly:

tsconfig.app.json

Update vite.config.ts

Add the path alias so Vite resolves @/ at build time:

vite.config.ts

Run the CLI

Run the shadcn init command with the Shark preset to set up your project.

Add Components

You can add components with the CLI or copy them manually from the component docs:

  • CLI: Run npx shadcn@latest add @shark/<component> (e.g. button, dialog).
  • Manual: Copy component source from Manual tab in the component docs.

For example, add the Button component to your project:

You can also install every component at once:

Then import and use components like this:

src/App.tsx