The narrow strip of workspaces and places at a chat app's edge, and the same places as a phone's tab bar.
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Avatar } from "./ui/uicontext/components/Glyph.ts"import { WorkspaceRail } from "./ui/uicontext/components/kit/WorkspaceRail.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, radius } from "./ui/uicontext/components/tokens.stylex.ts"const styles = stylex.create({ frame: { blockSize: 420, inlineSize: "fit-content", overflow: "hidden", borderWidth: 1, borderStyle: "solid", borderColor: color.line, borderRadius: radius.lg },})// Two workspaces, then the app's places: a number only for DMs, a dot for activity that isn't for youexport const ChatRail = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.frame)).children(WorkspaceRail(h, { label: "Workspaces and places", workspaces: [ { id: "northwind", name: "Northwind Labs", href: "#northwind", mark: "NL" }, { id: "brava", name: "Studio Brava", href: "#brava", mark: "SB", count: 2 }, ], workspace: "northwind", places: [ { id: "home", label: "Home", href: "#home", icon: "home" }, { id: "dms", label: "DMs", href: "#dms", icon: "dms", count: 3 }, { id: "activity", label: "Activity", href: "#activity", icon: "activity", unread: true }, { id: "saved", label: "Saved", href: "#saved", icon: "saved" }, ], current: "home", footer: Avatar(h, { id: "maya", name: "Maya Chen" }, 32), }))Installation
pnpm dlx shadcn@latest add checkfu/uicontext/workspace-railUsage
import { TabBar, WorkspaceRail } from "./ui/uicontext/components/kit/WorkspaceRail.ts"const places = [ { id: "home", label: "Home", href: "/", icon: "home" as const }, { id: "dms", label: "DMs", href: "/dms", icon: "dms" as const, count: 3 }, { id: "activity", label: "Activity", href: "/activity", icon: "activity" as const, unread: true },]// the rail on a wide screen, the same places as tabs on a phoneexport const AppRail = <M>(h: Html.H<M>, current: string) => [ WorkspaceRail(h, { label: "Northwind Labs", places, current }), TabBar(h, { label: "Sections", places, current }),]Examples
Phone tabs
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { TabBar } from "./ui/uicontext/components/kit/WorkspaceRail.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, radius } from "./ui/uicontext/components/tokens.stylex.ts"const styles = stylex.create({ frame: { inlineSize: "min(100%, 24rem)", overflow: "hidden", borderWidth: 1, borderStyle: "solid", borderColor: color.line, borderRadius: radius.lg },})// On a phone the places sit along the bottom, over the home indicator; 99+ past a hundredexport const PhoneTabs = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.frame)).children(TabBar(h, { label: "Sections", current: "activity", places: [ { id: "home", label: "Home", href: "#home", icon: "home" }, { id: "dms", label: "DMs", href: "#dms", icon: "dms", count: 1284 }, { id: "activity", label: "Activity", href: "#activity", icon: "activity", count: 5 }, { id: "you", label: "You", href: "#you", icon: "you" }, ], }))API reference
WorkspaceRailView function
Options
| Name | Type | Description |
|---|---|---|
labelrequired | string | The rail's accessible name |
workspaces | RailWorkspace[] | — |
workspace | string | The workspace you're in |
placesrequired | RailPlace[] | — |
current | string | The place you're in |
footer | View.Input | Under the places: the reader's avatar, a create button |
TabBarView function
Options
| Name | Type | Description |
|---|---|---|
labelrequired | string | — |
placesrequired | RailPlace[] | — |
current | string | — |
Accessibility
- The rail and the tab bar are navigation landmarks of links; the current place has
aria-current. - A count or a dot is read with the place's name: “DMs, 3 new”, “Activity, unread”.