# Install Keyframery in SvelteKit (/docs/installation/svelte)

Add Keyframery's animated UI SDK components to a Svelte 5 app with the shadcn-svelte CLI. Use the same parts, motion styles and Agent view as React.

Keyframery for Svelte has every component React has, with the same parts, Tailwind classes, five motion styles and [Agent view](/docs/agent-view). The [shadcn-svelte](https://shadcn-svelte.com) CLI copies the files into your project, so you own the code.

Choose where to start.

- [SvelteKit](#sveltekit): A new or existing Svelte 5 app with Tailwind CSS.
- [Use it](#use-it): Your first component and its motion style.

## SvelteKit [#sveltekit]

### Create the project [#create-the-project]

```bash
npx sv create my-app --template minimal --types ts --add tailwindcss='plugins:none'
```

Open the new project folder before running the next commands.

### Set up the CLI [#set-up-the-cli]

```bash
npx shadcn-svelte@latest init
```

This writes `components.json`, the colour tokens and the `cn` helper. Keyframery uses the same tokens, so it matches any shadcn-svelte components you add later.

Declare the UI SDK layer before Tailwind in the global CSS file listed in `components.json`. This lets your utility classes take precedence over UI SDK's runtime styles.

```css
@layer ui-sdk;
@import "tailwindcss";
```

### Add components [#add-components]

```bash
npx shadcn-svelte@latest add https://keyframery.com/r/svelte/tabs.json
```

The files land in `src/lib/components/keyframery/tabs/`, one Svelte file per part and an index that exports them. The CLI adds the motion tokens to your global CSS and puts the speed helpers in `src/lib/keyframery.ts`. Components that build on others bring them along.

## Use it [#use-it]

### Import the parts [#import-the-parts]

```svelte title="src/routes/+page.svelte"
<script lang="ts">
import { Tabs, TabsList, TabsPanel, TabsPanels, TabsTab } from "#lib/components/keyframery/tabs/index.js"
</script>

<Tabs defaultValue="account">
  <TabsList aria-label="Settings">
    <TabsTab value="account">Account</TabsTab>
    <TabsTab value="password">Password</TabsTab>
  </TabsList>
  <TabsPanels>
    <TabsPanel value="account">Account settings</TabsPanel>
    <TabsPanel value="password">Password settings</TabsPanel>
  </TabsPanels>
</Tabs>
```

The current SvelteKit scaffold uses `#lib` for `src/lib`. Use `$lib` in place of `#lib` if your project uses the `$lib` alias, and keep the explicit `/index.js` import.

Props use names like `defaultValue` and `onValueChange`. Use `bind:value` on parts with a bindable value. Content that depends on a part's state uses a Svelte snippet, such as `{#snippet children(state)}`.

### Pick how it moves [#pick-how-it-moves]

Subtle is the default. To change it for the app, wrap your pages in `KeyframeryProvider`:

```svelte title="src/routes/+layout.svelte"
<script lang="ts">
import { KeyframeryProvider } from "#lib/keyframery.js"

let { children } = $props()
</script>

<KeyframeryProvider motion="springy">
  {@render children()}
</KeyframeryProvider>
```

Keep your layout's global CSS import. For the chosen style on the first server-rendered paint, set `data-motion="springy"` on the existing `<html>` in `src/app.html`. Any component with a `speed` prop also accepts `"fast"`, `"slow"` or a number. [See the five styles](/docs/motion-styles).

### Install everything [#install-everything]

```bash
npx shadcn-svelte@latest add https://keyframery.com/r/svelte/all.json
```

## Notes for Svelte [#notes-for-svelte]

* **Same code as the docs.** Pick Svelte in the install card or a code tab. The docs remember your choice.
* **Option labels.** Pass matching `items` data to Select and Combobox when an initial value needs a label before the popup opens. Keep the styled item parts. For an example with `state.items`, see [Command](/docs/components/command).
* **Changing labels.** Use the same string for a Badge's `text` prop and its child content when a changing label should pulse: `<Badge dot text={label}>{label}</Badge>`.
* **Accordion copy.** Wrap plain text in a paragraph, as in `<AccordionPanel><p>Changes are free on this fare.</p></AccordionPanel>`.
* **Markdown.** Pass source to Markdown with `content={markdown}` and to ReasoningContent with `text={markdown}`. Use a snippet for custom reasoning content.
* **Typed parts and server rendering.** The parts use UI SDK's props and render in SvelteKit. [Known differences and workarounds](https://github.com/keyframery/keyframery/blob/main/frameworks/SVELTE.md#known-differences).

## Questions

### Are the Svelte components the same as the React ones?

The Svelte components have the same parts, Tailwind classes, five motion styles and Agent view. The Svelte examples use snippets and Svelte's prop conventions.

### Does Keyframery work with SvelteKit server rendering?

Yes. The components render on the server and hydrate in the browser. Put your motion style on the html element in src/app.html to apply it on the first paint.

### Do I need to add other shadcn-svelte components?

The CLI copies the Keyframery files and configures your CSS. Keyframery builds on UI SDK for Svelte, and its files sit next to any shadcn-svelte components you already have.
