Installation
Install the component
Run the following command to install the component and its dependencies:
Import the component
Import the component into your Svelte file:
Usage
Props
1.000s
Pointer
A wrapper that applies spring physics to elements, making them stick to the cursor on hover.
npx @motion-core/cli add magneticnpx @motion-core/cli add magneticpnpm dlx @motion-core/cli add magneticpnpm dlx @motion-core/cli add magneticbunx @motion-core/cli add magneticbunx @motion-core/cli add magneticyarn dlx @motion-core/cli add magneticyarn dlx @motion-core/cli add magneticimport { Magnetic } from "$lib/motion-core";import { Magnetic } from "$lib/motion-core";<script lang="ts">
import { Magnetic } from "motion-core";
import type { ComponentProps } from "svelte";
type Props = Partial<ComponentProps<typeof Magnetic>>;
let { duration = 1, ease = "elastic.out(1, 0.3)" }: Props = $props();
</script>
<Magnetic {duration} {ease}>
<button
class="h-8 gap-1.5 rounded-sm bg-background-muted px-3 text-xs font-medium tracking-wide text-foreground uppercase card"
>
Magnetic Button
</button>
</Magnetic>
<script lang="ts">
import { Magnetic } from "motion-core";
import type { ComponentProps } from "svelte";
type Props = Partial<ComponentProps<typeof Magnetic>>;
let { duration = 1, ease = "elastic.out(1, 0.3)" }: Props = $props();
</script>
<Magnetic {duration} {ease}>
<button
class="h-8 gap-1.5 rounded-sm bg-background-muted px-3 text-xs font-medium tracking-wide text-foreground uppercase card"
>
Magnetic Button
</button>
</Magnetic>
| Prop | Type | Default |
|---|---|---|
duration | number | 1 |
ease | string | "elastic.out(1, 0.3)" |
class | string | — |