blessed-components - v1.20.0
    Preparing search index...

    Function badge

    • Creates a display-only Badge backed by a Blessed BoxElement.

      Import from blessed-components/badge/blessed. The adapter disables Blessed tags, renders through renderBadge, and leaves screen rendering under caller control.

      Parameters

      • options: BadgeOptions

        Parent node, renderer data, and optional box settings.

      Returns BadgeHandle

      Handle for the created box, updates, and cleanup.

      RangeError Propagates validation errors from renderBadge.

      import blessed from 'blessed';
      import { badge } from 'blessed-components/badge/blessed';

      const screen = blessed.screen({ smartCSR: true });
      const status = badge({
      parent: screen,
      box: { top: 0, left: 0, width: 20, height: 1 },
      data: {
      text: 'Queued',
      tone: 'info',
      },
      });

      screen.render();
      status.setData({
      text: 'Passed',
      tone: 'success',
      });
      screen.render();

      status.destroy();
      screen.destroy();