# Vite + React

Install and configure Skeleton for Vite + React.

## Requirements

\| Tooling                              | Minimum Supported |
\| ------------------------------------ | ----------------- |
\| [Vite](https://vite.dev/)            | 6                 |
\| [React](https://react.dev/)          | 18                |
\| [Tailwind](https://tailwindcss.com/) | 4                 |

## Installation

<Process>
  <ProcessStep step="1">
    ### Create a Project

    Start by creating a new [Vite](https://vite.dev/guide/#scaffolding-your-first-vite-project) project. This will install React and Typescript.

    ```bash
    npm create vite@latest
    	- Set your project named as desired
    	- Set React as the framework
    	- Set Typescript as the variant
    cd {yourProjectName}
    npm install
    ```
  </ProcessStep>

  <ProcessStep step="2">
    ### Install Skeleton

    Install the Skeleton core and React component packages.

    ```bash
    npm i -D @skeletonlabs/skeleton @skeletonlabs/skeleton-react
    ```
  </ProcessStep>

  <ProcessStep step="3">
    ### Install Tailwind

    Install Tailwind and and the Tailwind Vite plugin.

    ```bash
    npm install tailwindcss @tailwindcss/vite
    ```

    Implement the plugin in `vite.config` in the root of your project.

    ```ts
    import { defineConfig } from "vite";
    import react from "@vitejs/plugin-react";
    import tailwindcss from "@tailwindcss/vite"; // [!code ++]

    export default defineConfig({
    	plugins: [
    		tailwindcss(), // [!code ++]
    		react() // <-- Must come after Tailwind
    	],
    });
    ```
  </ProcessStep>

  <ProcessStep step="4">
    ### Configure Tailwind

    Open your global stylesheet in `/src/index.css` and append the following at the top of the file.

    ```css
    @import 'tailwindcss';

    @import '@skeletonlabs/skeleton'; /* [!code ++] */
    @import '@skeletonlabs/skeleton-react'; /* [!code ++] */
    @import '@skeletonlabs/skeleton/themes/cerberus'; /* [!code ++] */
    ```
  </ProcessStep>

  <ProcessStep step="5">
    ### Set the Active Theme

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

    ```html
    <!-- [!code word:data-theme="cerberus"] -->
    <html data-theme="cerberus">
        <!-- ... -->
    </html>
    ```
  </ProcessStep>

  <ProcessStep step="check">
    ### Done

    Start the dev server using the following command.

    ```bash
    npm run dev
    ```
  </ProcessStep>
</Process>
