Split View

View as Markdown

A list beside the open row's detail, one at a time with Back on a narrow screen.

Renewal terms for next year

Priya Raman · 09:42

Hi, Thanks for the call yesterday. Attached are the renewal terms we discussed: 50 seats on the annual plan, with the onboarding credit carried over. Could you sign by Friday so finance can close the quarter? Priya

When to use

A list beside the open row's detail, one at a time with Back on a narrow screen. Use Resizable Panels instead when people size the panes themselves.

Usage

import { SplitView } from "./ui/uicontext/components/SplitView.ts"
export const Mail = <M>(h: Html.H<M>, open: boolean, closed: M) =>	SplitView(h, { listLabel: "Inbox", detailLabel: "Message", backLabel: "Inbox", open, onBack: closed, list: h.ul.children(), detail: h.article.children() })

Examples

One at a time

In a box under 640px wide, a row opens in place of the list, with Back to return.

API reference

Options

SplitView options
NameTypeDescription
listrequiredView.ContentThe rows; each opens its detail.
detailrequiredView.Content | nullThe open row's detail, or what shows before one is open.
openrequiredbooleanA row is open: narrow, the detail shows in place of the list.
onBackrequiredMessageBack to the list, narrow. Close the open row here.
backLabelrequiredstringWhere Back goes, named: "Inbox". The button reads "Back to Inbox".
listLabelrequiredstringNames the list's region: "Inbox".
detailLabelrequiredstringNames the detail's region: "Message".
listWidthstringThe list's width beside the detail; "minmax(16rem, 22rem)" by default.
styleStyle—

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/split-view

Source