SvelteKit
The Svelte registry items ship their transitions and the reduced-motion branch.
Prerequisites
You need SvelteKit 3 with Svelte 5, Tailwind CSS v4 and the #lib subpath imports that sv create writes into package.json.
- Node.js 22.17 or newer, the floor for SvelteKit 3.
- A SvelteKit app created with sv create.
- Tailwind CSS v4 through @tailwindcss/vite.
- components.json at the project root, which shadcn-svelte's init writes.
New app or existing app
Create a SvelteKit app with the official CLI, then add Tailwind. Choose the minimal template and TypeScript; the registry does not need any other add-on.
Create a SvelteKit app
npx sv create my-app --template minimal --types ts --no-add-onsAdd Tailwind CSS v4
npx sv add tailwindcss="plugins:none"Existing app? Run sv add tailwindcss if the stylesheet does not already start with @import "tailwindcss";. If shadcn-svelte ever reports a missing $app/tsconfig, run npm install once so svelte-kit sync recreates it.
Configuration
The Svelte registry item is written to src/lib/components/prequelui and imported through #lib, the Node subpath import that sv create declares in package.json. There is no provider to add: the component owns its transitions and asks the browser about reduced motion.
Create components.json and the theme
npx shadcn-svelte@latest init{
"imports": {
"#lib": "./src/lib/index.js",
"#lib/*": "./src/lib/*"
}
}{
"tailwind": {
"css": "src/routes/layout.css",
"baseColor": "neutral"
},
"aliases": {
"components": "#lib/components",
"utils": "#lib/utils",
"ui": "#lib/components/ui",
"hooks": "#lib/hooks",
"lib": "#lib"
}
}@import "tailwindcss";Add a component
Run the Svelte CLI from the project root. It syncs the generated tsconfig, then writes the dialog and its dependencies.
Add the animated component
npx shadcn-svelte@latest add https://prequeluianimate.terravidhal.me/r/svelte/dialog.json<script lang="ts">
import Dialog from "#lib/components/prequelui/Dialog.svelte";
</script>
<div class="grid min-h-svh place-items-center">
<Dialog trigger="Open dialog" title="A SvelteKit route" />
</div>Dark mode
The shadcn-svelte stack uses mode-watcher: it follows the system, stores the choice and applies the class before the page paints.
Install the runtime
npm install mode-watcher<script lang="ts">
import { ModeWatcher } from "mode-watcher";
import "./layout.css";
let { children } = $props();
</script>
<ModeWatcher />
{@render children()}Verification
Run the dev server and open the route. Check the motion in both themes, then enable reduced motion at the OS level and reload.
- The component mounts without a hydration warning.
- Both themes use the same tokens and the same durations.
- Reduced motion keeps the state change and removes the travel.
Start the dev server
npm run devMore Svelte guides
All frameworks