Getting Started
Components
Special Effects
Animations
Text Animations
Backgrounds
Terminal
A description for Terminal component.
motion-svruned
✔ Preflight checks. ✔ Verifying framework. Found Next.js. ✔ Validating Tailwind CSS. ✔ Validating import alias. ✔ Writing components.json. ✔ Checking registry. ✔ Updating tailwind.config.ts ✔ Updating app/globals.css ✔ Installing dependencies. ℹ Updated 1 file: - lib/utils.ts
terminal.svelte
<script lang="ts"> import { Terminal, AnimatedSpan, TypingAnimation, } from "$lib/components/magic/terminal/index.js";</script>
<Terminal> <TypingAnimation text="> pnpm dlx shadcn@latest init"></TypingAnimation> <AnimatedSpan class="text-green-500">✔ Preflight checks.</AnimatedSpan> <AnimatedSpan class="text-green-500">✔ Verifying framework. Found Next.js.</AnimatedSpan> <AnimatedSpan class="text-green-500">✔ Validating Tailwind CSS.</AnimatedSpan> <AnimatedSpan class="text-green-500">✔ Validating import alias.</AnimatedSpan> <AnimatedSpan class="text-green-500">✔ Writing components.json.</AnimatedSpan> <AnimatedSpan class="text-green-500">✔ Checking registry.</AnimatedSpan> <AnimatedSpan class="text-green-500">✔ Updating tailwind.config.ts</AnimatedSpan> <AnimatedSpan class="text-green-500">✔ Updating app/globals.css</AnimatedSpan> <AnimatedSpan class="text-green-500">✔ Installing dependencies.</AnimatedSpan> <AnimatedSpan class="text-blue-500"> <span>ℹ Updated 1 file:</span> <span class="pl-2">- lib/utils.ts</span> </AnimatedSpan> <TypingAnimation class="text-muted-foreground" text="Success! Project initialization completed." ></TypingAnimation> <TypingAnimation class="text-muted-foreground" text="You may now add components." ></TypingAnimation></Terminal>Installation
pnpm dlx shadcn-svelte@latest add https://sv-animations.vercel.app/r/terminal.json
Install dependencies
Install the required packages for this component:
pnpm add motion-sv runed
Copy the Source Code
Copy and paste the following code into your project:
terminal.svelte
<script lang="ts"> import type { ClassValue } from "svelte/elements"; import { onMount, setContext } from "svelte"; import { cn } from "#lib/utils.js"; import type { Snippet } from "svelte"; import { watch } from "runed";
interface TerminalProps { children: Snippet; class?: ClassValue; sequence?: boolean; startOnView?: boolean; }
let { children, class: className, sequence = true, startOnView = true, }: TerminalProps = $props();
let containerRef: HTMLDivElement | null = $state(null); let isInView = $state(false); let activeIndex = $state(0);
const sequenceHasStarted = $derived(sequence ? !startOnView || isInView : false);
// Set context for child components - always set it, check sequence inside let useSequence = $derived(sequence); watch( () => useSequence, () => { // setContext("terminal-sequence", val); setContext( "terminal-sequence", useSequence ? { get activeIndex() { return activeIndex; }, get sequenceStarted() { return sequenceHasStarted; }, completeItem: (index: number) => { if (index === activeIndex) { activeIndex = activeIndex + 1; } }, } : null ); } );
onMount(() => { if (!startOnView || !sequence) { isInView = true; return; }
if (!containerRef) return;
const observer = new IntersectionObserver( ([entry]) => { if (entry.isIntersecting) { isInView = true; observer.disconnect(); } }, { threshold: 0.3, } );
observer.observe(containerRef);
return () => observer.disconnect(); });</script>
<div bind:this={containerRef} class={cn( "border-border bg-background z-0 h-full max-h-[400px] w-full max-w-lg rounded-xl border", className )}> <div class="border-border flex flex-col gap-y-2 border-b p-4"> <div class="flex flex-row gap-x-2"> <div class="h-2 w-2 rounded-full bg-red-500"></div> <div class="h-2 w-2 rounded-full bg-yellow-500"></div> <div class="h-2 w-2 rounded-full bg-green-500"></div> </div> </div> <pre class="p-4"> <code class="grid gap-y-1 overflow-auto">{@render children()}</code> </pre></div> index.ts
export { default as Terminal } from "./terminal.svelte";export { default as AnimatedSpan } from "./animated-span.svelte";export { default as TypingAnimation } from "./typing-animation.svelte";Folder Structure
Folder Structure
src/└── lib/ └── components/ └── magic/ └── terminal/ ├── terminal.svelte └── index.tsInstall and integrate the Svelte component documented below.https://sv-animations.vercel.app/magic/docs/components/terminal/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 { Terminal, TypingAnimation } from "#lib/components/magic/terminal/index.js";</script>
<Terminal> <TypingAnimation text="> pnpm install" /></Terminal>Props
Terminal
A component for Terminal.
| Name | Type | Default | Description |
|---|---|---|---|
class | ClassValue | "" | Additional CSS classes to apply |