---
title: "SVG"
description: "Use motion.line, motion.path, motion.circle and the other SVG tags the same way as motion.div. Geometry such as x1, x2 and viewBox is written as attributes."
url: "https://opensource.rising.sh/solid-motion/docs/svg"
---

# SVG

Use `motion.line`, `motion.path`, `motion.circle` and the other SVG tags the
same way as `motion.div`. Geometry such as `x1`, `x2` and `viewBox` is written
as attributes.

```tsx
import { motion } from "@risinghq/solid-motion";

<svg viewBox="0 0 100 100">
  <motion.line
    x1="0"
    y1="50"
    y2="50"
    stroke="black"
    initial={{ x2: 0 }}
    animate={{ x2: 100 }}
    transition={{ duration: 0.3 }}
  />
</svg>;
```

The first paint puts `x2="0"` on the element, in the server HTML as well as on
the client.

## Drawing a path

`pathLength` animates from 0 to 1 and draws the stroke. It sets
`stroke-dasharray`, so leave that one to it.

```tsx
<motion.path
  d="M0 0 L100 100"
  stroke="black"
  initial={{ pathLength: 0 }}
  animate={{ pathLength: 1 }}
  transition={{ duration: 0.3 }}
/>
```

The [web page](https://opensource.rising.sh/solid-motion/docs/svg) shows a live demo here.

## Style and attributes

CSS properties such as `opacity`, `transform` and `fill` go through `style`, as
on HTML elements.

Tags with a capital letter, such as `foreignObject`, `clipPath` and
`linearGradient`, and components from `motion.create` paint `initial` as inline
style instead of attributes.

Sizes that go between units, such as `"auto"`, are measured for HTML elements
only.

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