API Reference

Full props, types, and imperative API reference.

Terminal Props

Prop Type Default Description
variant"dropdown" | "inline" | "floating" | "fullscreen""dropdown"Display mode
filesystemFsNode[] | FileSystemVirtual filesystem tree or adapter
commandsCommand[][]Custom commands
pluginsTerminalPlugin[][]Plugins to load
themeTerminalThemeConfigTheme integration config
logostring | string[] | (() => string) | falseASCII art logo for welcome screen
welcomeMessagestringMessage shown below logo
bootSequenceBootStep[] | falseBoot animation steps
crtbooleanfalseCRT scanline/glow effects
animatebooleantrueLine fade-in animations
soundsboolean | SoundConfigfalseProcedural typing sounds
hotkeystring | false"`"Toggle keyboard shortcut
defaultOpenbooleanfalseStart terminal open
persistStatebooleantruePersist state to localStorage
storageKeystring"terminal"localStorage key prefix
colorMapPartial<Record<OutputColor, string>>Semantic color overrides
panels{ id: string; component: ComponentType }[][]Panel components
statusBarStatusBarConfigStatus bar configuration
bottomBarBottomBarItem[]TUI-style shortcut bar
screenshotKeystring | false"ctrl+shift+s"Screenshot shortcut
onNavigate(path: string) => voidNavigation callback
closeOnNavigatebooleantrueClose after navigation
onReady() => voidFires after boot completes
onPopOut() => voidPop-out button clicked
onDock() => voidDock button clicked
onScreenshot(blob: Blob) => voidScreenshot callback
classNamestringAdditional CSS class

TerminalHandle

Use a ref to access the imperative API.

handle.tsx
import { useRef } from "react"
import { Terminal, type TerminalHandle } from "@trents/terminal"

function App() {
  const ref = useRef<TerminalHandle>(null)

  return (
    <>
      <Terminal ref={ref} />
      <button onClick={() => ref.current?.execute("help")}>
        Run help
      </button>
    </>
  )
}
Method Signature Description
execute(command: string) => Promise<void>Execute a command string
open() => voidOpen the terminal
close() => voidClose the terminal
toggle() => voidToggle open/closed
focus() => voidFocus the input field
clear() => voidClear all history

TerminalProvider

Wrap multiple <Terminal> components in a provider to share history and filesystem state across instances.

provider.tsx
import { Terminal, TerminalProvider } from "@trents/terminal"

<TerminalProvider storageKey="app-terminal">
  <Terminal ref={ref1} variant="dropdown" />
  <Terminal ref={ref2} variant="inline" />
</TerminalProvider>

Types

All types are exported from the main entry point.

types.ts
// Core
import type { Command, CommandResult, CommandContext } from "@trents/terminal"

// Output
import type { OutputSegment, OutputColor } from "@trents/terminal"

// Filesystem
import type { FsNode, FileSystem, FsEntry, FsStat } from "@trents/terminal"

// Plugins
import type { TerminalPlugin, PluginContext, MiddlewareFn, PanelProps } from "@trents/terminal"

// UI
import type {
  TerminalHandle,
  TerminalThemeConfig,
  BottomBarItem,
  BootStep,
  SoundConfig,
  StatusBarConfig,
  SelectOption,
  HistoryEntry,
} from "@trents/terminal"
0