Toolforge Docs
DocsBlock OutputsOverview of Block Outputs

Overview of Block Outputs

Create rich visual outputs like charts, tables, KPI cards, and layouts in your tools and agents.

Overview

The Block class provides methods to create rich visual outputs in your tools and agents. Every handler function receives a block object that lets you build charts, tables, KPI cards, images, and complex layouts—all from your backend code.

handler: async ({ block }) => {
  return block.barChart({
    title: 'Monthly Revenue',
    data: revenueData,
    index: 'month',
    categories: ['revenue', 'expenses'],
  })
}

Block outputs are returned from your handler or displayed via io.message(). Tool Forge automatically renders them as interactive visualizations in the dashboard.

Charts

Visualize data with a variety of chart types.

Progress & Status

Track progress and display status indicators.

Data Display

Present data in structured formats.

Content & Layout

Display content and arrange multiple blocks.

Quick Reference

MethodDescriptionCategory
areaChart()Area chart with gradient fillsCharts
barChart()Vertical or horizontal bar chartCharts
lineChart()Line chart for trendsCharts
donutChart()Donut or pie chartCharts
comboChart()Combined bar and line chartCharts
heatmapChart()Color-coded matrix chartCharts
sparkChart()Compact inline chartCharts
progressBar()Horizontal progress indicatorProgress
progressCircle()Circular progress indicatorProgress
tracker()Status trackerProgress
categoryBar()Segmented category barProgress
barList()List of comparison barsProgress
kpiCard()Key performance indicator cardData Display
table()Data table with featuresData Display
object()Key-value displayData Display
image()Image displayContent
text()Markdown textContent
layout()Grid layout containerLayout

Common Patterns

Returning a Block

Return a block directly from your handler:

handler: async ({ block }) => {
  const data = await fetchSalesData()

  return block.barChart({
    title: 'Sales by Region',
    data,
    index: 'region',
    categories: ['sales'],
    colors: ['blue'],
  })
}

Displaying Blocks with Messages

Use io.message() to display blocks mid-workflow:

handler: async ({ io, block }) => {
  const data = await processData()

  await io.message({
    title: 'Processing Complete',
    message: block.kpiCard({
      name: 'Records Processed',
      value: data.count,
      change: 15,
      changeType: 'positive',
    }),
  })

  // Continue with more operations...
}

Creating Dashboards with Layout

Combine multiple blocks in a grid layout:

handler: async ({ block }) => {
  return block.layout({
    columns: 12,
    children: [
      {
        element: block.kpiCard({ name: 'Revenue', value: 125000 }),
        colSpan: 4,
      },
      {
        element: block.kpiCard({ name: 'Users', value: 8420 }),
        colSpan: 4,
      },
      {
        element: block.kpiCard({ name: 'Conversion', value: '3.2%' }),
        colSpan: 4,
      },
      {
        element: block.areaChart({
          title: 'Revenue Trend',
          data: monthlyData,
          index: 'month',
          categories: ['revenue'],
        }),
        colSpan: 8,
      },
      {
        element: block.donutChart({
          title: 'Revenue by Source',
          data: sourceData,
          category: 'source',
          value: 'revenue',
        }),
        colSpan: 4,
      },
    ],
  })
}

Value Formatting

Format numbers as currency, percentages, or with custom options:

block.kpiCard({
  name: 'Total Revenue',
  value: 125000,
  valueFormat: {
    type: 'currency',
    currency: 'USD',
    notation: 'compact', // Shows as $125K
  },
})

block.barChart({
  // ...chart config
  valueFormat: {
    type: 'percentage',
    decimals: 1,
  },
})

Available Colors

Charts support these color options:

type ChartColor =
  | 'blue'
  | 'emerald'
  | 'violet'
  | 'amber'
  | 'gray'
  | 'cyan'
  | 'pink'
  | 'lime'
  | 'fuchsia'
  | 'red'
  | 'green'
  | 'yellow'

Next Steps

On this page