Display.list

List

Displays a list of items with optional titles, descriptions, and images. This is useful for summarizing objects, search results, or previews in a structured format.

ctx.ui.display.list({ data, render });

Config


data
T[]

An array of data items to display. Each item will be passed to the render function.


render
(data: any) => { title?: string; description?: string; image?: { url: string; alt?: string; fit?: 'cover' | 'contain' } }

A function that receives each data item and returns a display configuration for the list item.

List item properties

Each object returned from render can include the following fields:


title
string

Optional title to display for the item.


description
string

Optional description text for the item.


image
{ url: string; alt?: string; fit?: "cover" | "contain" }

Optional image to display alongside the item. fit controls how the image is resized within its container.

Usage

Lists are useful for visualizing collections of structured data, such as search results, product listings, or summaries.

ctx.ui.page({
  title: "List example",
  content: [
    ctx.ui.display.list({
      data: [
        { name: "Apple", info: "Red fruit", img: "/apple.png" },
        { name: "Banana", info: "Yellow fruit", img: "/banana.png" },
      ],
      render: (item) => ({
        title: item.name,
        description: item.info,
        image: { url: item.img, alt: item.name, fit: "contain" },
      }),
    }),
  ],
});