Getting Started
Components
Special Effects
Animations
Text Animations
Backgrounds
Add an animated gradient shine to cards, buttons, and panels with the customizable Shine Border component for Svelte 5.
Login
Enter your credentials to access your account
shine-border.svelte
<script lang="ts"> import ShineBorder from "$lib/components/magic/shine-border/shine-border.svelte"; import { Button } from "$lib/components/ui/button/index.js"; import * as Card from "$lib/components/ui/card/index.js"; import { Input } from "$lib/components/ui/input/index.js"; import { Label } from "$lib/components/ui/label/index.js";</script>
<Card.Root class="relative mx-auto w-full max-w-md overflow-hidden"> <ShineBorder shineColor={["#A07CFE", "#FE8FB5", "#FFBE7B"]} /> <Card.Header> <Card.Title>Login</Card.Title> <Card.Description>Enter your credentials to access your account</Card.Description> </Card.Header> <Card.Content> <form> <div class="grid gap-4"> <div class="grid gap-2"> <Label for="email">Email</Label> <Input id="email" type="email" placeholder="name@example.com" /> </div> <div class="grid gap-2"> <Label for="password">Password</Label> <Input id="password" type="password" /> </div> </div> </form> </Card.Content> <Card.Footer> <Button class="w-full">Sign In</Button> </Card.Footer></Card.Root>Installation
pnpm dlx shadcn-svelte@latest add https://sv-animations.vercel.app/r/shine-border.json
Copy the Source Code
Copy and paste the following code into your project:
shine-border.svelte
<script lang="ts"> import { cn } from "#lib/utils.js"; import type { HTMLAttributes } from "svelte/elements";
interface Props extends HTMLAttributes<HTMLDivElement> { borderWidth?: number; duration?: number; shineColor?: string | string[]; }
let { borderWidth = 1, duration = 14, shineColor = "#000000", class: className, style, ...restProps }: Props = $props();
let computedStyle = $derived.by(() => { const shineColorValue = Array.isArray(shineColor) ? shineColor.join(",") : shineColor;
const baseStyles = ` --border-width: ${borderWidth}px; --duration: ${duration}s; background-image: radial-gradient(transparent,transparent, ${shineColorValue},transparent,transparent); background-size: 300% 300%; mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask-composite: xor; mask-composite: exclude; padding: var(--border-width); `;
return style ? `${baseStyles} ${style}` : baseStyles; });</script>
<!-- svelte-ignore element_invalid_self_closing_tag --><div style={computedStyle} class={cn( "motion-safe:animate-shine pointer-events-none absolute inset-0 size-full rounded-[inherit] will-change-[background-position]", className )} {...restProps}/> index.ts
import ShineBorder from "./shine-border.svelte";export { ShineBorder };Add Tailwind CSS
Add the following to your routes/layout.css file:
src/routes/layout.css
@theme inline { --animate-shine: shine var(--duration) infinite linear;
@keyframes shine { 0% { background-position: 0% 0%; } 50% { background-position: 100% 100%; } to { background-position: 0% 0%; } }}Folder Structure
Folder Structure
src/└── lib/ └── components/ └── magic/ └── shine-border/ ├── shine-border.svelte └── index.tsInstall and integrate the Svelte component documented below.https://sv-animations.vercel.app/magic/docs/components/shine-border/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 { ShineBorder } from "#lib/components/magic/shine-border/index.js";</script>
<div class="relative overflow-hidden rounded-xl border p-8"> Shine border <ShineBorder /></div>Examples
Monotone
A responsive card up to 28rem wide with a theme-aware shine border.
Login
Enter your credentials to access your account
shine-border-monotone.svelte
<script lang="ts"> import ShineBorder from "$lib/components/magic/shine-border/shine-border.svelte"; import { Button } from "$lib/components/ui/button/index.js"; import * as Card from "$lib/components/ui/card/index.js"; import { Input } from "$lib/components/ui/input/index.js"; import { Label } from "$lib/components/ui/label/index.js"; // For Light and Dark Mode import { mode } from "mode-watcher";</script>
<Card.Root class="relative mx-auto w-full max-w-md overflow-hidden"> <ShineBorder shineColor={mode.current === "dark" ? "white" : "black"} /> <Card.Header> <Card.Title>Login</Card.Title> <Card.Description>Enter your credentials to access your account</Card.Description> </Card.Header> <Card.Content> <form> <div class="grid gap-4"> <div class="grid gap-2"> <Label for="email">Email</Label> <Input id="email" type="email" placeholder="name@example.com" /> </div> <div class="grid gap-2"> <Label for="password">Password</Label> <Input id="password" type="password" /> </div> </div> </form> </Card.Content> <Card.Footer> <Button class="w-full">Sign In</Button> </Card.Footer></Card.Root>Props
Shine Border
A component for ShineBorder.
| Name | Type | Default | Description |
|---|---|---|---|
class | ClassValue | "" | Additional CSS classes to apply |
borderWidth | number | 2 | Width of the border |
duration | number | 300 | Duration of the shine animation in milliseconds |
shineColor | string | string[] | "" | Color(s) of the shine effect |