Getting Started
Components
Special Effects
Animations
Text Animations
Backgrounds
Shiny Button
A description for Shiny Button component.
motion-sv
shiny-button.svelte
<script lang="ts"> import { ShinyButton } from "$lib/components/magic/shiny-button/index.js";</script>
<ShinyButton>Shiny Button</ShinyButton>Installation
pnpm dlx shadcn-svelte@latest add https://sv-animations.vercel.app/r/shiny-button.json
Install dependencies
Install the required packages for this component:
pnpm add motion-sv
Copy the Source Code
Copy and paste the following code into your project:
shiny-button.svelte
<script lang="ts"> import { motion, type MotionProps, type Transition } from "motion-sv"; import { cn } from "#lib/utils.js"; import type { Snippet } from "svelte"; import type { ClassValue, HTMLButtonAttributes } from "svelte/elements";
interface ShinyButtonProps extends HTMLButtonAttributes { children: Snippet; class?: ClassValue; }
let { children, class: className, ...props }: ShinyButtonProps = $props();
let animationProps: MotionProps = { initial: { "--x": "100%", scale: 0.8 }, animate: { "--x": "-100%", scale: 1 }, // whileTap: { scale: 0.95 }, whilePress: { scale: 0.95 }, transition: { repeat: Infinity, repeatType: "loop", repeatDelay: 1, type: "spring", stiffness: 20, damping: 15, mass: 2, scale: { type: "spring", stiffness: 200, damping: 5, mass: 0.5, }, }, };</script>
<motion.button class={cn( "relative cursor-pointer rounded-lg border px-6 py-2 font-medium backdrop-blur-xl transition-shadow duration-300 ease-in-out hover:shadow dark:bg-[radial-gradient(circle_at_50%_0%,var(--primary)/10%_0%,transparent_60%)] dark:hover:shadow-[0_0_20px_var(--primary)/10%]", className )} {...animationProps}> <span class="relative block size-full text-sm tracking-wide text-[rgb(0,0,0,65%)] uppercase dark:font-light dark:text-[rgb(255,255,255,90%)]" style="mask-image: linear-gradient(-75deg,var(--primary) calc(var(--x) + 20%),transparent calc(var(--x) + 30%),var(--primary) calc(var(--x) + 100%));" > {@render children()} </span> <span style="mask: linear-gradient(rgb(0,0,0), rgb(0,0,0)) content-box exclude,linear-gradient(rgb(0,0,0), rgb(0,0,0)); -webkit-mask: linear-gradient(rgb(0,0,0), rgb(0,0,0)) content-box exclude,linear-gradient(rgb(0,0,0), rgb(0,0,0)); background-image: linear-gradient(-75deg,var(--primary)/10% calc(var(--x)+20%),var(--primary)/50% calc(var(--x)+25%),var(--primary)/10% calc(var(--x)+100%))" class="absolute inset-0 z-10 block rounded-[inherit] p-px" > </span></motion.button> index.ts
export { default as ShinyButton } from "./shiny-button.svelte";Folder Structure
Folder Structure
src/└── lib/ └── components/ └── magic/ └── shiny-button/ ├── shiny-button.svelte └── index.tsInstall and integrate the Svelte component documented below.https://sv-animations.vercel.app/magic/docs/components/shiny-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 { ShinyButton } from "#lib/components/magic/shiny-button/index.js";</script>
<ShinyButton>Get started</ShinyButton>Props
Shiny Button
A component for Shiny Button.
| Name | Type | Default | Description |
|---|---|---|---|
class | ClassValue | "" | Additional CSS classes to apply |