terminal
eldoraui/terminalFreeComponent
A terminal component.
Live preview
live · rendered by the registry
Rendered by eldoraui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://eldoraui.site/r/terminal.jsonSource
1"use client"23import { useEffect, useMemo, useState, type ReactElement } from "react"4import { TerminalIcon } from "lucide-react"5import { GoTerminal } from "react-icons/go"67type TerminalStep = {8 text: string9 bold?: boolean10}1112type TerminalProps = {13 command: string14 steps: TerminalStep[]15 pulseInterval?: number16 showLocalhost?: boolean17 hostBarTitle?: string18 hostMessage?: string19}2021function MacControls() {22 return (23 <>24 <GoTerminal className="text-muted-foreground mr-1 size-4" />25 <div className="h-2 w-2 rounded-full bg-red-500" />26 <div className="h-2 w-2 rounded-full bg-yellow-500" />27 <div className="h-2 w-2 rounded-full bg-green-500" />28 </>29 )30}3132function LocalHost({ title, message }: { title: string; message: string }) {33 return (34 <div className="bg-card animate-in fade-in slide-in-from-top-10 absolute right-4 bottom-5 z-10 overflow-hidden rounded-md border shadow-xl">35 <div className="bg-muted text-muted-foreground relative flex h-6 flex-row items-center border-b px-4 text-xs">36 <TerminalIcon className="absolute inset-2 size-3" />37 <p className="absolute inset-x-0 text-center">{title}</p>38 </div>39 <div className="text-card-foreground p-4 text-sm">{message}</div>40 </div>41 )42}4344const Terminal = ({45 command,46 steps,47 pulseInterval = 100,48 showLocalhost = true,49 hostBarTitle = "localhost:3000",50 hostMessage = "New App Created!",51}: TerminalProps) => {52 const typingLen = useMemo(() => command.length, [command])53 const revealLen = useMemo(() => steps.length, [steps])54 const finalCount = typingLen + revealLen + 15556 const [counter, setCounter] = useState(finalCount)5758 useEffect(() => {59 const interval = setInterval(() => {60 setCounter((prev) => (prev >= finalCount ? prev : prev + 1))61 }, pulseInterval)62 return () => clearInterval(interval)63 }, [pulseInterval, finalCount])6465 const elements: ReactElement[] = []6667 const typedChars = Math.min(counter, typingLen)68 const isTyping = counter < typingLen6970 elements.push(71 <span key="command" className="text-foreground">72 {command.substring(0, typedChars)}73 {isTyping && (74 <div className="bg-foreground inline-block h-3 w-1 animate-pulse" />75 )}76 </span>77 )7879 if (!isTyping) {80 const shownSteps = Math.min(revealLen, counter - typingLen)81 if (shownSteps > 0) {82 elements.push(<span key="space"> </span>)83 }84 for (let i = 0; i < shownSteps; i++) {85// … truncated
What it pulls in
npm packages
Files it writes
More from eldoraui
All 115 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| animated-badgeanimated-badge | eldoraui | Components | Free | 2 deps | |
| animated-frameworksanimated-frameworks | eldoraui | Components | Free | 2 deps | |
| animated-grid-patternanimated-grid-pattern | eldoraui | Components | Free | 3 deps | |
| animated-listanimated-list | eldoraui | Components | Free | 1 dep | |
| animated-shiny-buttonanimated-shiny-button | eldoraui | Components | Free | 1 dep | |
| blur-in-textblur-in-text | eldoraui | Components | Free | 3 deps | |
| browserbrowser | eldoraui | Components | Free | 2 deps | |
| card-flip-hovercard-flip-hover | eldoraui | Components | Free | 1 dep |
