Page frames, breadcrumbs and empty states for simple screens.
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { AppFrame, Crumbs, EmptyState, NavItem, NavSection, Page } from "./ui/uicontext/components/Layout.ts"import { sx } from "./ui/uicontext/components/Sx.ts"const styles = stylex.create({ frame: { inlineSize: "100%", blockSize: 360 } })// a whole small app: a sidebar of links, and a page with its header bar and bodyexport const SmallApp = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.frame)).children( AppFrame(h, { sidebar: [ NavSection(h, { children: [ NavItem(h, { href: "#inbox", label: "Inbox", icon: "✉", active: false }), NavItem(h, { href: "#projects", label: "Projects", icon: "▦", active: true }), ], }), NavSection(h, { title: "Teams", children: [NavItem(h, { href: "#design", label: "Design", icon: "◐", active: false })], }), ], page: [ Page(h, { header: Crumbs(h, ["Northwind Freight", "Projects"]), body: [EmptyState(h, { title: "No projects yet", hint: "Projects you create or join show here." })], }), ], }), )Installation
pnpm dlx shadcn@latest add checkfu/uicontext/layoutUsage
import { Crumbs, EmptyState, Page } from "./ui/uicontext/components/Layout.ts"export const ProjectsPage = <M>(h: Html.H<M>) => Page(h, { header: Crumbs(h, ["Northwind Freight", "Projects"]), body: [EmptyState(h, { title: "No projects yet", hint: "Projects you create or join show here." })], })API reference
AppFrameView function
Options
| Name | Type | Description |
|---|---|---|
sidebarrequired | View.Children | What runs down the left of the window, usually NavSections of NavItems. |
pagerequired | View.Children | The current page, drawn in the inset panel. |
NavItemView function
Options
| Name | Type | Description |
|---|---|---|
hrefrequired | string | Where the link goes. |
labelrequired | string | The link's text. |
iconrequired | string | A short mark before the label, such as an emoji or a character. |
activerequired | boolean | Whether this link is the current page; it's highlighted and announced as current. |
NavSectionView function
Options
| Name | Type | Description |
|---|---|---|
title | string | A small heading over the group. Leave it out for an untitled group. |
childrenrequired | View.Children | The group's links. |
PageView function
Options
| Name | Type | Description |
|---|---|---|
headerrequired | View.Children | What the header bar shows, such as Crumbs and actions. |
bodyrequired | View.Children | The page's content, under the header. |
style | Style | StyleX styles for the page, applied after its own. |
EmptyStateView function
Options
| Name | Type | Description |
|---|---|---|
titlerequired | string | What's missing, in a few words: "No projects yet". |
hint | string | What will fill it, or what to do next. |
Accessibility
- The page sits in a
mainlandmark and each page is asectionwith aheader. - A sidebar link to the current page is
aria-current="page", and the›between crumbs is hidden from screen readers.