---
title: "Getting started"
description: "Install solid-motion in a Solid 2 app and animate your first element."
url: "https://opensource.rising.sh/solid-motion/docs/getting-started"
---

# Getting started

Install solid-motion in a Solid 2 app and animate your first element.

```sh
npm install @risinghq/solid-motion
```

## Set up the build

Vite needs the Solid plugin, which a Solid app already has:

```ts
// vite.config.ts
import solid from "@solidjs/vite-plugin";
import { defineConfig } from "vite";

export default defineConfig({ plugins: [solid()] });
```

With another bundler, compile Solid JSX inside `node_modules` too, because the
package ships TSX.

For TypeScript, set `"jsx": "preserve"` and `"jsxImportSource": "@solidjs/web"`
in `tsconfig.json`.

## Animate something

```tsx
import { motion } from "@risinghq/solid-motion";
import { render } from "@solidjs/web";
import { createSignal } from "solid-js";

function App() {
  const [open, setOpen] = createSignal(true);

  return (
    <>
      <button onClick={() => setOpen((value) => !value)}>Toggle</button>
      <motion.div
        initial={{ opacity: 0, y: 20 }}
        animate={{ opacity: open() ? 1 : 0.2, y: 0 }}
        transition={{ duration: 0.2 }}
      >
        Fades and slides in on mount
      </motion.div>
    </>
  );
}

render(() => <App />, document.getElementById("root")!);
```

The element starts at `initial` and animates to `animate` on mount. It animates
again each time a signal read inside `animate` changes.

[Animating elements](https://opensource.rising.sh/solid-motion/docs/animating-elements.md) covers the rest of the props. If you
know `motion/react`, start with
[what differs in the code](https://opensource.rising.sh/solid-motion/docs/compare.md#what-differs-in-the-code).

The manual's pages are listed in [llms.txt](https://opensource.rising.sh/solid-motion/llms.txt).
