Skip to content

Configuring Citadel and command history

Pass runtime options through the config prop.

tsx
import {
  Citadel,
  type CitadelConfig,
  command,
  createCommandRegistry,
  text,
} from 'citadel_cli';

const commandRegistry = createCommandRegistry([
  command('hello')
    .describe('Print a hello message')
    .handle(async () => text('Hello from a configured Citadel')),
]);

const config: CitadelConfig = {
  showCitadelKey: '/',
  commandTimeoutMs: 5000,
  displayMode: 'panel',
  showOnLoad: false,
  closeOnEscape: true,
  includeHelpCommand: true,
  cursorType: 'blink',
  cursorSpeed: 530,
  cursorColor: 'oklch(0.92 0 0)',
  fontFamily: '"JetBrains Mono", monospace',
  fontSize: '0.875rem',
  outputFontSize: '0.8125rem',
  initialHeight: '45vh',
  minHeight: '240px',
  maxHeight: '70vh',
  showOutputPane: true,
  resetStateOnHide: false,
  storage: {
    type: 'memory',
    maxCommands: 25,
  },
};

export function ConfiguredCitadelExample() {
  return <Citadel commandRegistry={commandRegistry} config={config} />;
}

Common options

OptionPurposeDefault
displayModeChoose panel or inline rendering.'panel'
showCitadelKeyKeyboard shortcut that opens the panel.'.'
showOnLoadStart visible in panel mode.false
closeOnEscapeLet Escape close the panel.true
includeHelpCommandInject the built-in help command.true
showOutputPaneRender the output/history pane.true
resetStateOnHideClear state when the panel closes.false
commandTimeoutMsMaximum time before a command times out.10000
fontFamilyMain font family.'monospace'
fontSizeBase UI font size.'0.875rem'
outputFontSizeOutput text font size override.'0.875rem'
initialHeightStarting height for the panel or inline container.'50vh'
minHeightMinimum height.'200'
maxHeightMaximum height.'80vh'
cursorTypeCursor style: blink, spin, solid, or bbs.'blink'
cursorSpeedCursor animation speed in milliseconds.530
cursorColorCursor color as any CSS color value.'var(--cursor-color, #fff)'
storage.typeCommand history backend.'localStorage'
storage.maxCommandsMaximum saved history entries.100
logLevelInternal logger verbosity.DEBUG in development, ERROR in production

History storage

Citadel stores command history through config.storage.

tsx
storage: {
  type: 'localStorage',
  maxCommands: 100,
}

Available backends:

  • localStorage: persisted across page reloads
  • memory: reset on refresh

If local storage cannot be created, Citadel falls back to in-memory storage.

Choosing sensible defaults

A few combinations work well:

  • Internal admin overlay: displayMode: 'panel', default showOutputPane, storage.type: 'localStorage'
  • Embedded dashboard console: displayMode: 'inline', explicit height constraints
  • Action-only command surface: showOutputPane: false, storage.type: 'memory'

Previous: Embedding Citadel and choosing a display mode

Next: Using integration recipes