Getting Started
Components
Special Effects
Animations
Text Animations
Backgrounds
A text component with a moving line shadow.
motion-sv
Ship Fast
line-shadow-text.svelte
<script lang="ts"> import { LineShadowText } from "$lib/components/magic/line-shadow-text/index.js"; import { mode } from "mode-watcher";</script>
<h2 class="text-5xl leading-none font-semibold tracking-tighter text-balance sm:text-6xl md:text-7xl lg:text-8xl"> Ship <LineShadowText content="Fast" class="italic" shadowColor={mode.current === "dark" ? "white" : "black"} ></LineShadowText></h2>Installation
pnpm dlx shadcn-svelte@latest add https://sv-animations.vercel.app/r/line-shadow-text.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:
line-shadow-text.svelte
<script lang="ts"> import type { ClassValue } from "svelte/elements"; import { motion } from "motion-sv"; import { cn } from "#lib/utils.js";
type ElementType = "span" | "div" | "p" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
interface LineShadowTextProps { content: string; class?: ClassValue; shadowColor?: string; as?: ElementType; }
let { content, class: className, shadowColor = "black", as = "span", }: LineShadowTextProps = $props();
let MotionComponent = $derived(motion[as]);</script>
<MotionComponent style={{ "--shadow-color": shadowColor }} class={cn( "relative z-0 inline-block whitespace-pre", "after:absolute after:top-[0.04em] after:left-[0.04em] after:content-[attr(data-text)]", "after:bg-[linear-gradient(45deg,transparent_45%,var(--shadow-color)_45%,var(--shadow-color)_55%,transparent_0)]", "after:-z-10 after:bg-size-[0.06em_0.06em] after:bg-clip-text after:text-transparent", "after:animate-line-shadow", className )} data-text={content}> {content}</MotionComponent> index.ts
import LineShadowText from "./line-shadow-text.svelte";export { LineShadowText };Add Tailwind CSS
Add the following to your routes/layout.css file:
src/routes/layout.css
@theme inline { --animate-line-shadow: line-shadow 15s linear infinite;
@keyframes line-shadow { 0% { background-position: 0 0; } 100% { background-position: 100% -100%; } }}Folder Structure
Folder Structure
src/└── lib/ └── components/ └── magic/ └── line-shadow-text/ ├── line-shadow-text.svelte └── index.tsInstall and integrate the Svelte component documented below.https://sv-animations.vercel.app/magic/docs/components/line-shadow-text/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 { LineShadowText } from "#lib/components/magic/line-shadow-text/index.js";</script>
<LineShadowText content="Shadow" />Examples
Emerald Shadow
Emerald lettering with a lighter mint shadow in dark mode.
Shadow
line-shadow-text-emerald.svelte
<script lang="ts"> import { LineShadowText } from "$lib/components/magic/line-shadow-text/index.js";</script>
<LineShadowText as="h2" content="Shadow" shadowColor="var(--line-shadow)" class="text-5xl font-semibold text-emerald-600 [--line-shadow:var(--color-emerald-400)] after:top-[0.12em] after:left-[0.12em] sm:text-7xl dark:text-emerald-400 dark:[--line-shadow:var(--color-emerald-200)]"/>Orange Shadow
Orange italic lettering with a bright peach shadow in dark mode.
Shadow
line-shadow-text-orange.svelte
<script lang="ts"> import { LineShadowText } from "$lib/components/magic/line-shadow-text/index.js";</script>
<LineShadowText as="h2" content="Shadow" shadowColor="var(--line-shadow)" class="text-5xl font-semibold text-orange-600 italic [--line-shadow:var(--color-orange-400)] after:top-[0.12em] after:left-[0.12em] sm:text-7xl dark:text-orange-400 dark:[--line-shadow:var(--color-orange-200)]"/>Sky Shadow
Sky-blue monospace lettering with an ice-blue shadow in dark mode.
Shadow
line-shadow-text-blue.svelte
<script lang="ts"> import { LineShadowText } from "$lib/components/magic/line-shadow-text/index.js";</script>
<LineShadowText as="h2" content="Shadow" shadowColor="var(--line-shadow)" class="font-mono text-5xl font-semibold text-sky-600 [--line-shadow:var(--color-sky-400)] after:top-[0.12em] after:left-[0.12em] sm:text-7xl dark:text-sky-400 dark:[--line-shadow:var(--color-sky-200)]"/>Props
Line Shadow Text
A component for Line Shadow Text.
| Name | Type | Default | Description |
|---|---|---|---|
class | ClassValue | "" | Additional CSS classes to apply |
shadowColor | string | "black" | Color of the shadow |
as | ElementType | "span" | HTML element to render as |
content | string | "" | Content of the text |