Skip to content

printBanner ​

Print an ASCII-art banner (via figlet) with optional version, dividers and clearing — handy for CLI entry points.

Usage ​

ts
import { printBanner } from '@maz-ui/node'

printBanner({
  name: 'maz-cli',
  version: 'v1.0.0',
})

Renders:

text
███╗   ███╗ █████╗ ███████╗     ██████╗██╗     ██╗
████╗ ████║██╔══██╗╚══███╔╝    ██╔════╝██║     ██║
██╔████╔██║███████║  ███╔╝     ██║     ██║     ██║
██║╚██╔╝██║██╔══██║ ███╔╝      ██║     ██║     ██║
██║ ╚═╝ ██║██║  ██║███████╗    ╚██████╗███████╗██║
╚═╝     ╚═╝╚═╝  ╚═╝╚══════╝     ╚═════╝╚══════╝╚═╝

v1.0.0

API ​

ts
function printBanner(args: {
  name: string
  version?: string
  options?: FigletOptions & {
    clear?: boolean
    divider?: boolean
    breakBefore?: boolean
    breakAfter?: boolean
  }
}): void
ParameterTypeDescription
namestringText rendered as ASCII art (required).
versionstringOptional version line printed under the banner.
optionsobjectFiglet options + extras (see below).

Options ​

OptionTypeDefaultDescription
clearbooleantrueClear the terminal screen before printing.
dividerbooleanfalsePrint a separator line after the banner.
breakBeforebooleantruePrint a blank line before the banner.
breakAfterbooleantruePrint a blank line after the banner.
fontstring'ANSI Shadow'Any figlet font name.
horizontalLayoutstring'full'Figlet horizontal layout: 'default', 'full', 'fitted', …

All standard figlet options are forwarded.

Examples ​

Minimal banner:

ts
printBanner({ name: 'maz-cli' })

Banner with divider, no screen clearing:

ts
printBanner({
  name: 'maz-cli',
  version: 'v1.0.0',
  options: { clear: false, divider: true },
})

Custom font:

ts
printBanner({
  name: 'Hi!',
  options: { font: 'Standard', horizontalLayout: 'fitted' },
})