Vite + React - Skeleton

  1. get started
  2. installation
  3. vite react

Vite + React

Install and configure Skeleton for Vite + React.

WARNING: The following guide will install a pre-release version of Skeleton v3. Be aware that some features may be missing, incomplete, or non-functional at this time. Please report bugs and issues on GitHub or Discord.

1

Create a Project

Start by creating a new Vite project. The template flags will install React and Typescript.

Terminal window
npm create vite@latest my-skeleton-app -- --template react-ts
cd my-skeleton-app
npm install
2

Install Skeleton

Install the Skeleton core and React component packages.

Terminal window
npm i -D @skeletonlabs/skeleton@next @skeletonlabs/skeleton-react@next
3

Install Tailwind

Install Tailwind and its dependencies.

Terminal window
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
4

Configure Tailwind

Locate tailwind.config in the root of your project and make the following changes:

tailwind.config
import { skeleton, contentPath } from "@skeletonlabs/skeleton/plugin";
import * as themes from "@skeletonlabs/skeleton/themes";
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
contentPath(import.meta.url, "react"),
],
theme: {
extend: {},
},
plugins: [
skeleton({
// NOTE: each theme included will increase the size of your CSS bundle
themes: [themes.cerberus, themes.rose],
}),
],
};
5

Add Tailwind Directives

Open /src/index.css and add the following Tailwind directives:

src/index.css
@tailwind base;
@tailwind components;
@tailwind utilities;

We also recommend removing all existing CSS styles in /src/index.css and /src/App.css.

6

Set the Active Theme

Open index.html, then set the data-theme attribute on the body tag to define the active theme.

index.html
<body data-theme="cerberus">...</body>

Done

Start the dev server using the following command.

Terminal window
npm run dev