Learn
Curated pages
A designed page about one item, with tabs of views, that the person can read one view at a time or lay out side by side.
On this page
A free layout starts empty, or from a preset, and the person builds it. That suits work where the layout is the work: exploring data, comparing records.
Much work is about one item at a time: a customer, a case, a loan application. For that, a page someone designed is better. It shows the right views in the right order, and the person can still lay them out their own way. Jali calls this a curated page. Both run on the same instance. The difference is where the person controls the layout: from the panes in a free layout, from a tab strip on a curated page.
definePage describes the page
Link to this section: definePage describes the pagedefinePage, from jali-layout/page, makes the curated page's definition. Pass it to createJali as page, beside your kinds. An app that never imports jali-layout/page ships none of a page's code.
import { LayoutIcon, LifebuoyIcon, ShoppingCartIcon, UserIcon } from "@phosphor-icons/react";import { pane, row } from "jali-layout";import { definePage, type PageView } from "jali-layout/page";import { customer, customerOrders, customerOverview, customerTickets } from "./customer";import { customers } from "./data";// The page's views, in tab order. A view says whether its pane gives way first when room runs out.const roles: PageView[] = [ { id: "overview", label: "Overview", priority: "supporting", icon: LayoutIcon }, { id: "profile", label: "Customer", priority: "primary", icon: UserIcon }, { id: "orders", label: "Orders", priority: "supporting", icon: ShoppingCartIcon }, { id: "tickets", label: "Tickets", priority: "supporting", icon: LifebuoyIcon },];// What each view shows for one customer. Another customer swaps these in place.const bind = (id: number) => ({ overview: customerOverview({ customer: id }), profile: customer({ id }), orders: customerOrders({ customer: id }), tickets: customerTickets({ customer: id }),});// Split view's designed layout: every view is in it, and Overview starts hidden.const build = (id: number) => { const refs = bind(id); return row( { id: "page" }, ...roles.map((r) => pane(refs[r.id as keyof typeof refs], { id: r.id, role: r.id, priority: r.priority, hidden: r.id === "overview", }), ), );};// The list beside the page, and the header above its tabs.function Rail({ item, showItem }: { item: number; showItem: (item: number) => void }) { return ( <nav aria-label="Customers"> {customers.map((c) => ( <button key={c.id} aria-current={c.id === item} onClick={() => showItem(c.id)}> {c.name} </button> ))} </nav> );}function Header({ item }: { item: number }) { return ( <header> <h1>{customers.find((c) => c.id === item)?.name}</h1> </header> );}export const customerPage = definePage({ id: "customer", name: "Customer", itemNoun: "customer", roles, home: "overview", build, bind, firstItem: 7, Rail, Header,});rolesare the page's views, in tab order. Each has an id, a label, an icon, and a priority. A role's pane in the layout has the role's id as its node id.bind(item)says what each view shows for one item. Choosing another item from the list swaps every view's object in place.build(item)is the designed layout for Split view. Every role is in it; the ones that should not show at first are listed inoverlay.hidden.homeis the view Single view opens on.Headersits above the tabs, andRail, optional, is the list of items at the left. Both are your components.RailgetsshowItem(item)to switch items. Leave it out when the page has nothing to list, such as a report reached by a link: the header, tabs and panes then take the whole width.
An item id is a number or a string, such as a UUID or a slug. A link carries it as text; when firstItem is a number, you get numbers back.
When a view's object comes from your data
Link to this section: When a view's object comes from your databind answers at once: it runs inside every page action (choosing an item, Reset, a link arriving, Back), and each of those returns its result and writes the address straight away. So bind names objects; it doesn't fetch them. Most views need only the item's id (orderList({ customer: item })), and each pane loads its own data, with its own loading and error states.
When a view shows another object that only your data knows (the borrower of an application, say), read those ids before you call createJali, keep them, and let bind look them up:
import { createJali, type ObjectRef } from "jali-layout";import { definePage, type Page } from "jali-layout/page";// Your app's: the page as written, its kinds, and the borrower ids read ahead.declare const loanPage: Page<number>;declare const application: (params: { id: number }) => ObjectRef;declare const member: (params: { id: number }) => ObjectRef;declare function loadBorrowers(): Promise<Map<number, number>>;const borrowerOf = await loadBorrowers(); // application id → borrower idconst page = definePage({ ...loanPage, bind: (item: number) => ({ application: application({ id: item }), borrower: member({ id: borrowerOf.get(item) ?? 0 }), }),});const jali = createJali({ panes, page });Until they are read, show your own loading screen in place of <JaliRoot>. If the list of items grows while the page is open, read the new ids before you call showItem. Loan review, among the examples, does this.
Opening the page
Link to this section: Opening the pageWhile a page is open, <JaliView> renders it: your rail, your header, the tabs, and the panes. <PageBar> holds the mode switch, Back to the page and Reset; put it in your own top bar.
import { createJali } from "jali-layout";import { customer, customerOrders, customerOverview, customerTickets, order } from "./customer";import { customerPage } from "./customer-page";import { listOnly } from "./layouts";import { ticketList } from "./ticket-list";export const jali = createJali({ panes: [customerOverview, customer, customerOrders, customerTickets, order, ticketList], page: customerPage, layout: listOnly,});// A link with ?page=customer opens the page. Open it from code, a menu or ⌘K ("Open Customer") otherwise.if (!jali.get().page) jali.page.open({ item: 7 });A link opens a page with ?page=customer&item=7&tab=orders. Without one, open it with jali.page.open(), or from ⌘K ("Open Customer"). jali.page.leave() goes back to the free layout. A page-only app (a page and no presets or layout) needs neither: it starts on its page. jali.page exists, and is typed, only when createJali was given a page.
Single view: one view at a time
Link to this section: Single view: one view at a timeSingle view is the default. It shows one view, chosen from the tabs, like any web app. The pane has no header of its own, because the selected tab already names it.
Clicking a tab swaps the view in place; nothing moves. A link inside a view opens as a peek, since there is no second pane for it to open into, and the announcement says how to open links beside.
Split view: views side by side
Link to this section: Split view: views side by sideIn Split view, the tabs become a palette of views that the person lays out with full freedom.
- Drag a tab into the panes. An edge places the view beside that pane; the centre adds it to that pane's tabs.
- ⌥-click a tab (Alt-click) to open it beside the view in use. Holding ⌥ over a tab draws where it would go, and that preview is exactly what the click does.
- Click a tab to bring the view on screen. If it is on screen, it is focused. If it is behind another tab, that tab is chosen. If it is not on screen, it takes the place and the size of the view in use, and that view goes back to the tabs.
- Close a view and it goes back to the tabs. Each view exists once.
Why a click never reshapes: a click is the lightest thing a person does. If it added a pane and pushed the others aside, every click would rearrange the screen. Adding a view is always a deliberate gesture: a drag or ⌥-click.
The first switch to Split view starts from the page's design. Switching back to Single view keeps the split layout exactly, and switching again restores it. Dragging a tab out of Single view switches to Split view for you, when the view may be placed beside the one on screen. Where your allow turns open off for it, the drag and ⌥-click are refused, and no drop target, preview or hint offers them. Choosing Split view itself is always allowed. In code, jali.page.setMode("single" | "split").
Views never fold into each other's tabs
Link to this section: Views never fold into each other's tabsWhen there is no room for a view the person places, the least recently used views go back to the page's tabs, supporting views before the primary one. The announcement names them. A view never folds into a tab group inside a pane, because that would repeat the page's tabs inside a pane.
Following links: opened panes
Link to this section: Following links: opened panesIn Split view, following a link opens a pane after the page's views, marked with a tint and an "Opened" tag. Opened panes stay in one region at the right, so the designed layout stays readable.
Nothing the person placed gives way to an opened pane. If there is no room beside, the opened pane becomes the shown tab of the pane the link was in, at that pane's size. If even that needs more room, views go back to the page's tabs; none folds.
Back to the page (in <PageBar>, or ⌘K) closes every opened pane. The views stay as they are now. What the person did to them during the investigation (a resize, a pin, where they put them) is kept. An opened pane never took their room, so if nothing else changed, they are back exactly as before the first link. Undo (⌘K ⌘Z) reopens only the opened panes, each in its place.
Choosing another item swaps every view in place and closes the opened panes, because they belonged to the item before.
What is whose
Link to this section: What is whose- The mode and the split layout belong to the person. They are kept on their device, through the storage port, without the opened panes. Reset puts the layout back to the design.
- A link carries content only: the item, the view in use and the opened panes. The same link opens in each reader's own layout. A link with opened panes opens in Split view, since Single view cannot show them.
People who only look
Link to this section: People who only lookSome people should read a page without opening panes from it, such as a support agent beside an account manager. Turn open off for them with allow (see Choose what people can do with panes): createJali({ allow: { open: false } }). Their links open as a peek, in Single view and Split view alike, and they can still switch views and use Split view. Your app decides from the person's role; Jali never offers a way to change it.