Terminal
scificn/terminalFreeComponent
Scrollable log/output block with typed line entries, color-coded types, and a blinking cursor.
Live preview
live · rendered by the registry
Rendered by scificn on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.scificn.dev/r/terminal.jsonSource
1'use client'23import * as React from 'react'4import { cn } from '@/lib/utils'56export type TerminalLineType = 'input' | 'output' | 'warn' | 'error' | 'system'78export interface TerminalLine {9 type?: TerminalLineType10 text: string11 timestamp?: string12}1314export interface TerminalProps extends React.HTMLAttributes<HTMLDivElement> {15 lines?: TerminalLine[]16 prompt?: string17 title?: string18 height?: string | number19 blinkCursor?: boolean20}2122function lineColor(type: TerminalLineType = 'output'): string {23 switch (type) {24 case 'input': return 'var(--color-green)'25 case 'output': return 'var(--text-secondary)'26 case 'warn': return 'var(--color-amber)'27 case 'error': return 'var(--color-red)'28 case 'system': return 'var(--text-muted)'29 }30}3132function linePrefix(type: TerminalLineType = 'output'): string {33 switch (type) {34 case 'input': return '>'35 case 'output': return ' '36 case 'warn': return '⚠'37 case 'error': return '✕'38 case 'system': return '#'39 }40}4142const Terminal = React.forwardRef<HTMLDivElement, TerminalProps>(43 (44 {45 className,46 lines = [],47 prompt = '>',48 title = 'TERMINAL',49 height = '16rem',50 blinkCursor = true,51 style,52 ...props53 },54 ref55 ) => {56 const bodyRef = React.useRef<HTMLDivElement>(null)5758 React.useEffect(() => {59 if (bodyRef.current) {60 bodyRef.current.scrollTop = bodyRef.current.scrollHeight61 }62 }, [lines])6364 return (65 <div66 ref={ref}67 className={cn(className)}68 style={{69 border: '1px solid var(--border)',70 background: 'var(--surface)',71 fontFamily: 'var(--font-mono)',72 overflow: 'hidden',73 display: 'flex',74 flexDirection: 'column',75 ...style,76 }}77 {...props}78 >79 {/* Title bar */}80 <div81 style={{82 display: 'flex',83 alignItems: 'center',84 gap: '0.5rem',85 padding: '0.4rem 0.75rem',86 borderBottom: '1px solid var(--border)',87 background: 'var(--surface-raised)',88 }}89 >90 <span91 style={{92 fontSize: '0.6rem',93 color: 'var(--text-muted)',94 letterSpacing: '0.12em',95 textTransform: 'uppercase',96 }}97 >98 {title}99// … truncated
More from scificn
All 33 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Alertalert | scificn | Components | Free | 1 dep | |
| Badgebadge | scificn | Components | Free | 1 dep | |
| Bar Chartbar-chart | scificn | Components | Free | no deps | |
| Breadcrumbbreadcrumb | scificn | Components | Free | no deps | |
| Buttonbutton | scificn | Components | Free | 2 deps | |
| Cardcard | scificn | Components | Free | no deps | |
| Checkboxcheckbox | scificn | Components | Free | 1 dep | |
| Dialogdialog | scificn | Components | Free | 1 dep |
