matter.work
Building Apps / The SDK

Panels

Open pages of your app beside its page, alone or in tabs, and let Matter slide them in and take them back.

Every page in Matter is a row of panels: a board, then the task you opened beside it, then that task’s thread, and on. Your app’s pages can work the same way through matter.panels. A page opens another page of your app beside it; Matter draws the panel’s header or its tabs, slides the row as panels open and close, and takes them back with its Back arrow and Escape, just as it does for its own. Your app draws what’s inside each one.

Panels, not modals

Keep a list or board on the page and open an item’s detail beside it with matter.panels.open(path, { title }), rather than in a modal or an expanding row.

Panels need Matter 0.4.6 or newer: set minMatterVersion to match. They work in pages, not in your worker or tools.

Opening a Panel#

Pass a path on your app’s origin. The panel opens beside the page that asked, in view on the right:

A list that opens each deal beside it
row.addEventListener('click', () => {
  void matter.panels.open(`/deals/${deal.id}`, { title: deal.title })
})
  • Opening from the app’s page while a panel is already beside it shows the new page in that panel, rather than opening another. Clicking row after row of a list swaps what’s beside it.
  • Opening from a panel goes a column deeper: the row slides left, the app’s page goes out of view, and the panel you opened from sits on the left with a Back arrow.
  • Anything that was past the page that asked goes.
  • width is 'narrow', 'medium' (the default) or 'wide'. The member can drag the line between panels, and Matter keeps their width for your app. The panels past the first take the same width, or the rest of the row.
  • transient: true closes the panel on Escape or a press on empty space outside it, as Matter’s detail panels close. A press on a link, button, field or anything with a pointer cursor doesn’t count, so clicking another row still swaps what’s beside it. Use it for a quick look, not a place to work. A task you open beside the app’s page is always transient. Since Matter 0.4.11; older versions keep the panel open.

Each panel is a page of your app in a view of its own, so it loads your app as the app’s page does. It can read and write, watch live reads and open panels of its own.

Tabbed Panels#

A tabbed panel shows several pages of your app under one strip of tabs, which Matter draws like its own. Open one with its tabs, or add a page to the tabbed panel beside the page that asks:

Files open as tabs beside the list
await matter.panels.open({
  tabs: [{ path: '/files/brief', title: 'Brief' }, { path: '/files/budget', title: 'Budget' }],
  active: 0,
})

// Adds a tab, or brings forward the tab already at that path.
await matter.panels.openTab('/files/notes')

A tab’s label is its title, else its page’s document.title. Members switch and close tabs themselves; closing the last tab closes the panel. Each tab keeps its page while it’s open, so switching back to it is instant.

App tabs behave like Matter’s own. Members drag them to reorder, and pin a tab from its icon or its context menu; pinned tabs lead the strip and stay open. Other tabs close once they’ve been out of view and unused for as long as the member’s Close unused tabs setting allows (an hour, unless they’ve changed it). Pass pinned: true to open a tab already pinned, for a page that shouldn’t close on its own:

A tab that stays
await matter.panels.openTab('/inbox', { title: 'Inbox', pinned: true })

New Tabs#

Give a group a newTab handler and its strip gets Matter’s New tab button. Pressing it calls the handler in the page that opened the group, which says what the tab is: a path, or a tab with a title. Return nothing to open nothing.

A new file each time
await matter.panels.open({
  tabs: [{ path: '/files/brief', title: 'Brief' }],
  newTab: async () => {
    const id = await matter.table('Files').insert({ title: 'Untitled' })
    return { path: `/files/${id}`, title: 'Untitled' }
  },
})

openTab(path, { newTab }) gives the group it opens into a handler the same way. The handler lives in that page, so a group whose page has reloaded since makes no new tabs until it’s opened again.

Tab Status#

A tab’s page says what it’s doing in its head, as it gives its title. While <meta name="matter-status" content="working"> is there, its tab shows Matter’s spinner, as a thread tab does while its agent works; content="unread" shows it unread. Take the tag away to clear it. In React 19, render it from the component doing the work, and React keeps it in the head while that component shows it:

A tab that spins while it syncs
function Sync({ running }: { running: boolean }) {
  return running ? <meta name="matter-status" content="working" /> : null
}

Tabs That Last#

The tabs beside your app’s page last, as a thread page’s tabs do: leave the app and open it again, and they’re back as they were. A single panel beside the page doesn’t come back, as a board doesn’t reopen the task it last showed.

A page holding work that closing would lose, like an unsaved draft, should say so, as a terminal running a command does in Matter. Its tab then stays open however long it goes unused:

Keeping a draft’s tab open
editor.on('change', () => void matter.panels.keepOpen(true))
editor.on('save', () => void matter.panels.keepOpen(false))

Tasks, Threads, Docs and Rows#

A panel can show one of Matter’s own instead of a page of your app, just as Matter shows it beside its own pages:

A deal’s task, beside the deal
await matter.panels.open({ task: deal.values.Task.id })
await matter.panels.open({ thread: threadId })
await matter.panels.open({ doc: docId })
await matter.panels.open({ row: deal.id, table: 'deals' })
  • A task opens in Matter’s task panel. Its threads open past it, and their tabs past them, as they do on a board.
  • A thread opens with its transcript and composer; the browsers and files its agent opens go past it.
  • A doc opens as it does in a thread’s tabs, for reading and editing.
  • A table row opens in Matter’s row panel, where the member sees and edits every field as they would in the table. Name its table by id, key or name, so a row of a large table that isn’t on this computer can load. On the phone it opens as the row’s page. Since Matter 0.5.27.
  • The member sees only what they can see in Matter. stack lists these panels as { id, task }, { id, thread }, { id, doc } or { id, row }.

Where a Page Is#

matter.panels.current says where this page is: null on the app’s page, else its column (1 beside the app’s page, 2 past that), its id, the path it opened at, and whether it’s shown. matter.panels.stack lists the panels open beside the app’s page. Both are there before your code runs. Listen for changes to highlight the row whose panel is open:

Highlighting the open deal
matter.panels.onChange(({ stack }) => {
  const open = stack[0]?.path
  for (const row of rows) row.classList.toggle('selected', open === `/deals/${row.dataset.id}`)
})

Closing and Going Back#

  • matter.panels.back() goes back a column, as the Back arrow does. Beside the app’s page, it closes the panel.
  • matter.panels.close() closes this panel and those past it; in a tab, it closes the tab. On the app’s page, it closes every panel, as closeAll() does.
  • matter.panels.setTitle(title) changes this panel’s title, or its tab’s label.
  • Escape goes back, as it does in Matter’s own panels, unless your page used it: call event.preventDefault() when Escape closes something of yours, like a menu.

A page out of view can’t open or close panels: those calls fail with not_shown.

Client-Side Routing#

When a panel shows another page in its place, it loads that page. If your app has a client-side router, show the page yourself instead, so nothing reloads:

Showing the next deal in place
matter.panels.onNavigate((path) => router.navigate(path))

How They Move#

Your pages show in frames of Matter’s own page, so they move with their panels as Matter’s own do, live, and never load again for it. Keep your pages’ backgrounds transparent (see Look & Feel) so the window shows through every panel, as it does through Matter’s own.