Getting Started
Components
Special Effects
Animations
Text Animations
Backgrounds
An SVG filter wrapper that adds a soft, saturated backlight glow around the content it wraps.

backlight.svelte
<script lang="ts"> import { Backlight } from "$lib/components/magic/backlight/index.js";</script>
<div class="flex min-h-100 w-full items-center justify-center"> <div class="relative isolate w-full max-w-lg"> <div class="pointer-events-none absolute inset-0 -z-10" aria-hidden="true"> <Backlight blur={40} class="w-full"> <img class="aspect-video w-full rounded-2xl object-cover" src="https://i.ytimg.com/vi/B2MhkPtBWs4/hqdefault.jpg" alt="" /> </Backlight> </div> <iframe class="aspect-video w-full rounded-2xl" src="https://www.youtube.com/embed/B2MhkPtBWs4?si=EFiavzs7uNWyfYby" title="The Complete Svelte 5 Course" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerPolicy="strict-origin-when-cross-origin" allowFullScreen ></iframe> </div></div>Installation
pnpm dlx shadcn-svelte@latest add https://sv-animations.vercel.app/r/backlight.json
Copy the Source Code
Copy and paste the following code into your project:
backlight.svelte
<script lang="ts"> import type { ClassValue } from "svelte/elements"; import type { Snippet } from "svelte";
type Props = { children?: Snippet; class?: ClassValue; blur?: number; }; let { children, class: className, blur = 10 }: Props = $props(); let id = $props.id();</script>
<div class={className}> <svg width="0" height="0" aria-hidden="true"> <filter {id} y="-50%" x="-50%" width="200%" height="200%"> <feGaussianBlur in="SourceGraphic" stdDeviation={blur} result="blurred" ></feGaussianBlur> <feColorMatrix type="saturate" in="blurred" values="4"></feColorMatrix> <feComposite in="SourceGraphic" operator="over"></feComposite> </filter> </svg> <div style="filter: url(#{id})"> {@render children?.()} </div></div> index.ts
export { default as Backlight } from "./backlight.svelte";Folder Structure
Folder Structure
src/└── lib/ └── components/ └── magic/ └── backlight/ ├── backlight.svelte └── index.tsInstall and integrate the Svelte component documented below.https://sv-animations.vercel.app/magic/docs/components/backlight/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 { Backlight } from "#lib/components/magic/backlight/index.js";</script>
<Backlight blur={20}> <div class="rounded-xl bg-background p-8">Backlit content</div></Backlight>Examples
Image

backlight-image-example.svelte
<script> import { Backlight } from "$lib/components/magic/backlight/index.js";</script>
<Backlight class="w-full"> <img class="mx-auto h-auto w-full max-w-lg rounded-xl" src="https://i.pinimg.com/1200x/a4/10/85/a410856c63bd607ce6b356b02f6a2931.jpg" alt="fancy gradient background" /></Backlight>Svg
backlight-svg-example.svelte
<script lang="ts"> import { Backlight } from "$lib/components/magic/backlight/index.js";</script>
<Backlight blur={5}> <!-- Svelte Logo from: https://svgl.app/?search=svelte --> <svg class="size-20" viewBox="0 0 256 308" preserveAspectRatio="xMidYMid"> <path d="M239.682 40.707C211.113-.182 154.69-12.301 113.895 13.69L42.247 59.356a82.198 82.198 0 0 0-37.135 55.056 86.566 86.566 0 0 0 8.536 55.576 82.425 82.425 0 0 0-12.296 30.719 87.596 87.596 0 0 0 14.964 66.244c28.574 40.893 84.997 53.007 125.787 27.016l71.648-45.664a82.182 82.182 0 0 0 37.135-55.057 86.601 86.601 0 0 0-8.53-55.577 82.409 82.409 0 0 0 12.29-30.718 87.573 87.573 0 0 0-14.963-66.244" fill="#FF3E00" /> <path d="M106.889 270.841c-23.102 6.007-47.497-3.036-61.103-22.648a52.685 52.685 0 0 1-9.003-39.85 49.978 49.978 0 0 1 1.713-6.693l1.35-4.115 3.671 2.697a92.447 92.447 0 0 0 28.036 14.007l2.663.808-.245 2.659a16.067 16.067 0 0 0 2.89 10.656 17.143 17.143 0 0 0 18.397 6.828 15.786 15.786 0 0 0 4.403-1.935l71.67-45.672a14.922 14.922 0 0 0 6.734-9.977 15.923 15.923 0 0 0-2.713-12.011 17.156 17.156 0 0 0-18.404-6.832 15.78 15.78 0 0 0-4.396 1.933l-27.35 17.434a52.298 52.298 0 0 1-14.553 6.391c-23.101 6.007-47.497-3.036-61.101-22.649a52.681 52.681 0 0 1-9.004-39.849 49.428 49.428 0 0 1 22.34-33.114l71.664-45.677a52.218 52.218 0 0 1 14.563-6.398c23.101-6.007 47.497 3.036 61.101 22.648a52.685 52.685 0 0 1 9.004 39.85 50.559 50.559 0 0 1-1.713 6.692l-1.35 4.116-3.67-2.693a92.373 92.373 0 0 0-28.037-14.013l-2.664-.809.246-2.658a16.099 16.099 0 0 0-2.89-10.656 17.143 17.143 0 0 0-18.398-6.828 15.786 15.786 0 0 0-4.402 1.935l-71.67 45.674a14.898 14.898 0 0 0-6.73 9.975 15.9 15.9 0 0 0 2.709 12.012 17.156 17.156 0 0 0 18.404 6.832 15.841 15.841 0 0 0 4.402-1.935l27.345-17.427a52.147 52.147 0 0 1 14.552-6.397c23.101-6.006 47.497 3.037 61.102 22.65a52.681 52.681 0 0 1 9.003 39.848 49.453 49.453 0 0 1-22.34 33.12l-71.664 45.673a52.218 52.218 0 0 1-14.563 6.398" fill="#FFF" /> </svg></Backlight>Props
Backlight
Wraps content in an SVG blur and saturation filter to create a glowing backlight effect.
| Name | Type | Default | Description |
|---|---|---|---|
children | Snippet | undefined | The content rendered inside the backlight wrapper. |
class | ClassValue | undefined | Custom classes applied to the outer wrapper element. |
blur | number | 10 | Controls the blur intensity used by the SVG filter. |