Toolforge Docs
DocsBlock Outputsobject

object

Display structured key-value data in a clean, readable format.

Usage

Object

return block.object({
  title: 'User Details',
  data: {
    name: 'Alice',
    email: 'alice@example.com',
    role: 'Admin',
    lastLogin: '2024-01-15',
  },
})

Props

PropDescriptionTypeRequiredDefault
titleTitle displayed above the objectstringNoundefined
descriptionDescription text below the titlestringNoundefined
dataObject containing key-value pairs to displayRecord<string, unknown>Yes

Returns

Returns an object block that can be returned from a handler or passed to io.message().

Examples

Basic object display

Basic object

return block.object({
  title: 'Configuration',
  data: {
    environment: 'production',
    region: 'us-east-1',
    version: '2.4.0',
    debug: false,
  },
})

API response details

API response

const response = await fetchUserDetails(userId)

return block.object({
  title: 'User Profile',
  description: `ID: ${userId}`,
  data: {
    name: response.name,
    email: response.email,
    role: response.role,
    createdAt: response.createdAt,
    status: response.status,
  },
})

Error details

Error details

return block.object({
  title: 'Error Details',
  description: 'An error occurred while processing the request',
  data: {
    code: 'ERR_VALIDATION',
    message: 'Invalid email format',
    field: 'email',
    timestamp: new Date().toISOString(),
  },
})

Order summary

Order summary

return block.object({
  title: 'Order Summary',
  data: {
    orderId: 'ORD-2024-001',
    customer: 'John Doe',
    items: 5,
    subtotal: '$120.00',
    tax: '$12.00',
    total: '$132.00',
    status: 'Processing',
  },
})

Combine with layout

Combine with layout

return block.layout({
  columns: 12,
  children: [
    {
      element: block.object({
        title: 'Billing Address',
        data: billingAddress,
      }),
      colSpan: 6,
    },
    {
      element: block.object({
        title: 'Shipping Address',
        data: shippingAddress,
      }),
      colSpan: 6,
    },
  ],
})

On this page