# Install Keyframery in Astro (/docs/installation/astro)

Add Keyframery's animated UI SDK components to an Astro site as React islands: install them with the shadcn CLI and hydrate each one with a client directive.

Choose the setup that matches your starting point.

- [Use Keyframery Create](#use-keyframery-create): Build your preset, then install it into a new Astro site.
- [Use the CLI](#use-the-cli): Scaffold a new Astro project from the terminal.
- [Existing Project](#existing-project): Add Keyframery to an Astro site you already have.

## Use Keyframery Create [#use-keyframery-create]

### Build your preset [#build-your-preset]

Open [Keyframery Create](/create) and pick your colours, corners, font and motion. Copy the command under the preview.

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

```bash
npx shadcn@latest init -t astro
```

### Add the preset [#add-the-preset]

Run the command you copied from the project's folder:

```bash
npx shadcn@latest add @keyframery/preset-<code>
```

It writes the colours, corners and motion into `src/styles/global.css`. A preset with a font installs it from Fontsource and imports it there too.

### Add components [#add-components]

```bash
npx shadcn@latest add @keyframery/tabs
```

Then [use it in a page](#use-it).

## Use the CLI [#use-the-cli]

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

```bash
npx shadcn@latest init -t astro
```

The template adds Astro's React integration and Tailwind CSS v4. For a project inside a monorepo, add `--monorepo`.

### Add components [#add-components-1]

```bash
npx shadcn@latest add @keyframery/tabs
```

The files land in `src/components/keyframery/`, and the motion tokens go into `src/styles/global.css`.

### Use it [#use-it]

Put the parts together in a React component:

```tsx title="src/components/settings-tabs.tsx"
import { Tabs, TabsList, TabsPanel, TabsPanels, TabsTab } from "@/components/keyframery/tabs"

export default function SettingsTabs() {
  return (
    <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>
  )
}
```

Then use it in a page with a client directive, so it hydrates:

```astro title="src/pages/index.astro"
---
import Layout from "@/layouts/main.astro"
import SettingsTabs from "@/components/settings-tabs"
---

<Layout>
  <SettingsTabs client:load />
</Layout>
```

## Existing Project [#existing-project]

### Check the setup [#check-the-setup]

You need Astro's React integration (`npx astro add react`), Tailwind CSS v4 and the `@/*` alias in `tsconfig.json`. [shadcn's Astro guide](https://ui.shadcn.com/docs/installation/astro#existing-project) has each step. Then set up the CLI:

```bash
npx shadcn@latest init
```

### Add components [#add-components-2]

```bash
npx shadcn@latest add @keyframery/tabs
```

## Notes for Astro [#notes-for-astro]

* **Client directives.** Without one, a React component is static HTML: it shows, but nothing opens, slides or responds. Use `client:load` for what's on screen at once, `client:visible` for what's further down.
* **One island per widget.** A dialog and the button that opens it, or tabs and their panels, belong in the same `.tsx` file and the same island.
* **Motion style and speed.** Put `data-motion="calm"` on `<html>` in your layout, so the style is there before any island hydrates. A `speed` set on `KeyframeryProvider` only reaches the components in its own island.

## Questions

### Why don't my components animate in Astro?

Astro renders React components to static HTML unless you add a client directive. Add `client:load` (or `client:visible`) where you use them, so they hydrate and respond.

### Can I write `<Tabs>` and `<TabsTab>` straight into an .astro file?

Not as one interactive component. Each island hydrates on its own and children passed from Astro arrive as static HTML, so the parts can't share state. Put them together in a .tsx file and use that one component in your page.
