---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# The app's frame with its places in a bar across the top

The frame's top-nav option

The `top-nav` option of `docs/screen-frame.md`: copy the file below whole in place of that recipe's `frame.tsx` (same path, the same `router.ts` beside it). For an app of a few places, each with many fields: the places stand in one bar across the top (AppFrame `arrangement="top-nav"`, the Pro template `app-frame-arrangements`), the app's name at its start and the signed-in person's menu at its end; on a phone the bar's places fold into its menu button, whose sheet holds them. It exports what the sidebar frame does (`ScreenFrame`, `ScreenTopBar`, `FrameAccount`, `hasPage`), so every screen recipe sits in it unchanged, but for a screen's own sidebar group (`more`: the inbox's queues, the chat's chats), which has no sidebar to stand in: keep the sidebar frame for those. With the account recipe, give its menu's trigger `variant="avatar"` (`<AccountMenuTrigger variant="avatar" …>`), the avatar alone at the bar's end.

```tsx top-nav // src/screens/frame.tsx: the frame every screen sits in, its places in a bar across the top import { createContext, type ReactNode, useContext, useState } from 'react'; import { ArrangedAppFrame, ArrangedAppFrameRail, ArrangedAppFrameTrigger, } from '@/components/goop/patterns/app-frame-arrangements'; import { ColorModeToggle } from '@/components/ui/goop/color-mode-toggle'; import { NavigationMenu, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, } from '@/components/ui/goop/navigation-menu'; import { TopBar, TopBarGroup, TopBarRow, TopBarTitle } from '@/components/ui/goop/top-bar'; import type { IconName } from '@/lib/goop/trail/glyph'; import { SAMPLE_BRAND } from '@/lib/goop/trail/sample-brand'; import { hrefOf, useRoute } from './router';

// ---- the app's pages: swap them for yours const NAVIGATION = [ { words: 'Overview', path: '/', icon: 'home' }, { words: 'Inbox', path: '/inbox', icon: 'inbox' }, { words: 'Issues', path: '/issues', icon: 'circle-dot' }, { words: 'Work', path: '/board', icon: 'columns-3' }, { words: 'Schedule', path: '/schedule', icon: 'calendar' }, { words: 'Visits', path: '/visits', icon: 'calendar-plus' }, { words: 'Assistant', path: '/chat', icon: 'message' }, { words: 'Settings', path: '/settings', icon: 'settings' }, ] as const;

// ---- the frame /** A place in the bar: a page of yours, its route and its pack icon (the command palette's, if you add one). */ export type FrameRow = { words: string; path: string; icon: IconName };

/** Whether the app's pages hold a route: a link to one from elsewhere (the account menu's Settings) asks first. */ export const hasPage = (path: string): boolean => NAVIGATION.some((page: FrameRow) => page.path === path);

/** The signed-in person's menu every frame under it draws at the bar's end: given once, in App.tsx. */ const AccountSlot = createContext<ReactNode>(null);

/** Gives every screen's frame under it the signed-in person's menu: `<FrameAccount account={<SignedInMenu />}>`. */ export function FrameAccount({ account, children }: { account: ReactNode; children: ReactNode }) { return <AccountSlot value={account}>{children}</AccountSlot>; }

/** The place a route belongs to, the longest that holds it: `/issues/FW-121` is under Issues; none outside them all. */ function pageOf(route: string, rows: readonly FrameRow[]): string | undefined { const holding = rows.filter((page) => page.path === '/' ? route === '/' : route === page.path || route.startsWith(`${page.path}/`), ); return holding.sort((a, b) => b.path.length - a.path.length)[0]?.path; }

/** * The frame every screen sits in: the bar across the top (the app's name, its places, the signed-in person's menu), * the screen's template (or AppFramePanel) under it; `account`, that menu (FrameAccount's when not given); * `scroll="panel"` keeps a reply box pinned; `counts`, a place's count by its route (`{ '/inbox': 3 }`), where * something waits on the person. The place marked is the route's; `current` names it only for a route under none. */ export function ScreenFrame({ current, account, scroll, counts, children, }: { current?: string; account?: ReactNode; scroll?: 'page' | 'panel'; counts?: Readonly<Partial<Record<string, number>>>; children: ReactNode; }) { const here = pageOf(useRoute(), NAVIGATION) ?? current; const given = useContext(AccountSlot); const end = account ?? given; return ( <ArrangedAppFrame arrangement="top-nav" scroll={scroll}> <ArrangedAppFrameRail> <div className="flex w-full min-w-0 items-center gap-2"> <span className="shrink-0 ps-2 me-2 text-base leading-auto font-medium text-foreground"> {SAMPLE_BRAND.name} </span> <Places here={here} counts={counts} /> {end ? <div className="flex shrink-0 items-center">{end}</div> : null} </div> </ArrangedAppFrameRail> {children} </ArrangedAppFrame> ); }

/** The places in the bar, the one shown marked; on a phone in the menu button's sheet, which a press closes. */ function Places({ here, counts }: { here?: string; counts?: Readonly<Partial<Record<string, number>>> }) { const [open, setOpen] = useState(false); return ( <div className="flex min-w-0 grow"> <NavigationMenu aria-label="Main" menuLabel="Menu" menuOpen={open} onMenuOpenChange={setOpen}> <NavigationMenuList> {NAVIGATION.map((page: FrameRow) => ( <NavigationMenuItem key={page.path}> <NavigationMenuLink href={hrefOf(page.path)} active={page.path === here} onClick={() => setOpen(false)} > {page.words} {counts?.[page.path] ? ( <> {' '} <span className="text-xs text-muted-foreground tabular-nums">{counts[page.path]}</span> </> ) : null} </NavigationMenuLink> </NavigationMenuItem> ))} </NavigationMenuList> </NavigationMenu> </div> ); }

/** A screen's top bar, for its template's or its panel's `header`: the title and the light and dark switch. */ export function ScreenTopBar({ title }: { title: ReactNode }) { return ( <TopBar role="banner"> <TopBarRow> <TopBarGroup> <ArrangedAppFrameTrigger /> <TopBarTitle>{title}</TopBarTitle> </TopBarGroup> <TopBarGroup align="end"> <ColorModeToggle /> </TopBarGroup> </TopBarRow> </TopBar> ); }

```

```
