Getting Started
Components
Special Effects
Animations
Text Animations
Backgrounds
A visually engaging button component that responds to hover with dynamic transitions, adapting smoothly between light and dark modes for enhanced user interactivity.
@lucide/svelte
interactive-hover-button.svelte
<script lang="ts"> import { InteractiveHoverButton } from "$lib/components/magic/interactive-hover-button/index.js";</script>
<InteractiveHoverButton>Hover Me</InteractiveHoverButton>Installation
pnpm dlx shadcn-svelte@latest add https://sv-animations.vercel.app/r/interactive-hover-button.json
Install dependencies
Install the required packages for this component:
pnpm add @lucide/svelte
Copy the Source Code
Copy and paste the following code into your project:
interactive-hover-button.svelte
<script lang="ts"> import { ArrowRight } from "@lucide/svelte"; import { cn } from "#lib/utils.js"; import type { Snippet } from "svelte"; import type { ClassValue, HTMLButtonAttributes } from "svelte/elements";
interface InteractiveHoverButtonProps extends HTMLButtonAttributes { children: Snippet; class?: ClassValue; }
let { children, class: className, ...props }: InteractiveHoverButtonProps = $props();</script>
<button class={cn( "group bg-background relative w-auto cursor-pointer overflow-hidden rounded-full border p-2 px-6 text-center font-semibold", className )} {...props}> <div class="flex items-center gap-2"> <div class="bg-primary h-2 w-2 rounded-full transition-all duration-300 group-hover:scale-[100.8]" ></div> <span class="inline-block transition-all duration-300 group-hover:translate-x-12 group-hover:opacity-0" > {@render children()} </span> </div> <div class="text-primary-foreground absolute top-0 z-10 flex h-full w-full translate-x-12 items-center justify-center gap-2 opacity-0 transition-all duration-300 group-hover:-translate-x-5 group-hover:opacity-100" > <span>{@render children()}</span> <ArrowRight /> </div></button> index.ts
import InteractiveHoverButton from "./interactive-hover-button.svelte";export { InteractiveHoverButton };Folder Structure
Folder Structure
src/└── lib/ └── components/ └── magic/ └── interactive-hover-button/ ├── interactive-hover-button.svelte └── index.tsInstall and integrate the Svelte component documented below.https://sv-animations.vercel.app/magic/docs/components/interactive-hover-button/llms.txt
Follow the guide's installation and usage instructions.Match the project's existing structure, imports, and styles.Keep changes scoped to the component and verify it works.Reply with a short bullet list of completed changes.Usage
<script lang="ts"> import { InteractiveHoverButton } from "#lib/components/magic/interactive-hover-button/index.js";</script>
<InteractiveHoverButton>Hover me</InteractiveHoverButton>Props
Interactive Hover Button
A component for Interactive Hover Button.
| Name | Type | Default | Description |
|---|---|---|---|
class | ClassValue | "" | Additional CSS classes to apply |
children | Snippet | required | The content to display inside the button |