Skip to main content

Starwind UI v3.0 is now available! Migration guide

SvelteKit Installation

Use Svelte 5.29 or newer within Svelte 5.

Use Node.js 22.12 or newer, or a newer version if your starter requires it. Starwind uses Tailwind CSS 4. Starwind Pro does not yet support Svelte.

Create a SvelteKit Project

Use the official Svelte CLI. Choose the minimal SvelteKit app with TypeScript. Skip this step for an existing app.

Set the Svelte Version

Install a supported Svelte version before running Starwind:

Install with the CLI

Use SvelteKit 2 or 3 with the usual src/routes folder and src/app.html. Write your Vite config as defineConfig({ ... }), with sveltekit() in plugins. sveltekit() can hold options. A svelte.config file is optional. If you set files.routes, in the config file or in the sveltekit() options, keep it at src/routes.

The CLI installs the Svelte package and adds the Tailwind Vite plugin. It imports src/styles/starwind.css from src/routes/+layout.svelte, creating that layout when needed. It keeps your existing layout content and sets framework: "svelte" in starwind.config.json.

PurposePath
Styled componentssrc/lib/starwind
Shared utilitiessrc/lib/utils
Starwind stylesheetsrc/styles/starwind.css

Add and Render Button

In SvelteKit 3, import from the #lib alias and name the index.js file. Use this line in the <script> block of src/routes/+page.svelte:

import { Button } from "#lib/starwind/button/index.js";

In SvelteKit 2, import from $lib:

src/routes/+page.svelte
<script lang="ts">
import { Button } from "$lib/starwind/button";
</script>
<Button>Hello from SvelteKit</Button>

SvelteKit 2 provides $lib for src/lib. SvelteKit 3 uses #lib in its place. The import #lib/starwind/button without /index.js fails type checking. When copying component examples, change @/components/starwind/x to #lib/starwind/x/index.js in SvelteKit 3, and to $lib/starwind/x in SvelteKit 2. Keep related parts, such as a Dialog’s trigger and content, together in a .svelte component. When you add your own code that uses window or document, run it after the component mounts so it also works with server rendering.

Manual Setup

To set up Starwind by hand, follow Manual Setup and select Svelte for the packages and starwind.config.json. The Svelte package is @starwind-ui/svelte@beta. Use the paths listed above.

Keep sveltekit() in the Vite plugins array and add tailwindcss() from @tailwindcss/vite. Import ../styles/starwind.css in the <script> of src/routes/+layout.svelte. The CLI handles these changes when you use init. Import components from #lib in SvelteKit 3 and from $lib in SvelteKit 2.

Optional: Set Up Dark Mode

To remember a visitor’s theme choice or follow their system setting, use the Svelte dark mode guide. Add the theme script yourself after installation.

Use Svelte Components

See Svelte usage for more examples. On component pages, choose the Svelte tab for installation commands and code you can copy.