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

    Function stat

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

      Import from blessed-components/stat/blessed. The adapter disables Blessed tags, renders content through renderStat, and leaves terminal rendering under caller control.

      Parameters

      • options: StatOptions

        Parent node, renderer data, and optional box settings.

      Returns StatHandle

      Handle for the created box, updates, and cleanup.

      RangeError Propagates validation errors from renderStat.

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

      const screen = blessed.screen({ smartCSR: true });
      const revenue = stat({
      parent: screen,
      box: { top: 0, left: 0, width: 40, height: 3 },
      data: {
      label: 'Revenue',
      value: '$84K',
      trend: {
      direction: 'up',
      value: '12.5%',
      },
      },
      });

      screen.render();
      revenue.setData({
      label: 'Revenue',
      value: '$91K',
      });
      screen.render();

      revenue.destroy();
      screen.destroy();