npx shadcn@4.23.1 add @goop/meadow-top-barTop bar
FreeThe bar across the top of a page, with its breadcrumbs and title at its start and its page-level controls at its end, for React and Tailwind CSS. Free, MIT.
What an agent sees
- TopBarRowOne row of the bar
- TopBarGroupA group of a row
- TopBarCrumbsThe trail of places above the page, before its title
- TopBarCrumbOne ancestor page in
TopBarCrumbs - TopBarTitleThe page's name
- TopBarTitleMenuThe page's name as a button that opens its menu, inside a heading
- TopBarToggleA 28 px toggle in the bar, an icon alone named with aria-label, or an icon with words
- TopBarButtonThe bar's worded action, the theme's 28 px Button
- TopBarActionAn icon-only control in the bar (back, forward, a panel's toggle)
- TopBarTabsThe bar's row of views, a tab list inside the caller's Tabs holding TabsTriggers
import { TopBarTitleMenu, TopBarToggle, TopBarTabs } from '@/components/ui/goop/top-bar';
import { useState } from 'react';
import { ToggleGroup, ToggleGroupItem } from '@/components/ui/goop/toggle-group';
import {
TopBar,
TopBarAction,
TopBarButton,
TopBarCrumb,
TopBarCrumbs,
TopBarGroup,
TopBarRow,
TopBarTitle,
} from '@/components/ui/goop/top-bar';
function ScheduleBar({ onStep, onNew }: { onStep: (by: -1 | 1) => void; onNew: () => void }) {
const [view, setView] = useState('week');
return (
<TopBar>
<TopBarRow>
<TopBarGroup>
<TopBarCrumbs>
<TopBarCrumb href="/schedule">Schedule</TopBarCrumb>
</TopBarCrumbs>
<TopBarTitle>Week of 16 Nov</TopBarTitle>
</TopBarGroup>
<TopBarGroup align="end">
<TopBarAction icon="chevron-left" aria-label="Previous week" onClick={() => onStep(-1)} />
<TopBarAction icon="chevron-right" aria-label="Next week" onClick={() => onStep(1)} />
<ToggleGroup variant="outline" fit aria-label="Calendar view" value={view} onValueChange={setView}>
<ToggleGroupItem value="day">Day</ToggleGroupItem>
<ToggleGroupItem value="week">Week</ToggleGroupItem>
</ToggleGroup>
<TopBarButton variant="primary" onClick={onNew}>
New event
</TopBarButton>
</TopBarGroup>
</TopBarRow>
</TopBar>
);
}Press the sidebar toggle, the worded action, the icon action or a view tab; switch the action’s look, add the tabs’ row, make the title long; pick the list’s bar or the bar whose title opens a menu; narrow the window to a phone. Nothing opens: each press is only written under the bar.
When to use
- The bar across the top of a page, with its breadcrumbs and title at its start and its page-level controls at its end.
- Also called: header or navbar.
Installation
Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Top bar on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing.
npx shadcn@4.23.1 add @goop/meadow-top-barAdd the Goop Top bar to this project. The install steps are at https://goop.so/docs/install.mdUsage
import { TopBarTitleMenu, TopBarToggle, TopBarTabs } from '@/components/ui/goop/top-bar';
import { useState } from 'react';
import { ToggleGroup, ToggleGroupItem } from '@/components/ui/goop/toggle-group';
import {
TopBar,
TopBarAction,
TopBarButton,
TopBarCrumb,
TopBarCrumbs,
TopBarGroup,
TopBarRow,
TopBarTitle,
} from '@/components/ui/goop/top-bar';
function ScheduleBar({ onStep, onNew }: { onStep: (by: -1 | 1) => void; onNew: () => void }) {
const [view, setView] = useState('week');
return (
<TopBar>
<TopBarRow>
<TopBarGroup>
<TopBarCrumbs>
<TopBarCrumb href="/schedule">Schedule</TopBarCrumb>
</TopBarCrumbs>
<TopBarTitle>Week of 16 Nov</TopBarTitle>
</TopBarGroup>
<TopBarGroup align="end">
<TopBarAction icon="chevron-left" aria-label="Previous week" onClick={() => onStep(-1)} />
<TopBarAction icon="chevron-right" aria-label="Next week" onClick={() => onStep(1)} />
<ToggleGroup variant="outline" fit aria-label="Calendar view" value={view} onValueChange={setView}>
<ToggleGroupItem value="day">Day</ToggleGroupItem>
<ToggleGroupItem value="week">Week</ToggleGroupItem>
</ToggleGroup>
<TopBarButton variant="primary" onClick={onNew}>
New event
</TopBarButton>
</TopBarGroup>
</TopBarRow>
</TopBar>
);
}- Fits: account, frame, inbox, record, settings (their recipes).
- height, width, padding, gap, corner, background, text, motion: add no class for these.
API reference
| Part | What it is |
|---|---|
| TopBarRow | One row of the bar |
| TopBarGroup | A group of a row; align?: 'start' | 'end' = 'start' — start (the default): the growing group at the row's start; end: the group of controls at its end |
| TopBarCrumbs | The trail of places above the page, before its title |
| TopBarCrumb | One ancestor page in TopBarCrumbs; takes asChild; also takes href?: string |
| TopBarTitle | The page's name; takes asChild |
| TopBarTitleMenu | The page's name as a button that opens its menu, inside a heading; its props: top-bar--title-menu.md |
| TopBarToggle | A 28 px toggle in the bar, an icon alone named with aria-label, or an icon with words; also takes pressed?: boolean; defaultPressed?: boolean; onPressedChange?: (pressed: boolean) => void; disabled?: boolean |
| TopBarButton | The bar's worded action, the theme's 28 px Button; its props: top-bar--button.md |
| TopBarAction | An icon-only control in the bar (back, forward, a panel's toggle); name it with aria-label; its props: top-bar--action.md |
| TopBarTabs | The bar's row of views, a tab list inside the caller's Tabs holding TabsTriggers; name it with aria-label; also takes variant?: 'default' | 'ghost' | 'segmented' | 'outline' = 'default'; size?: 'sm' | 'md' = 'md'; action?: ReactNode |
TopBarAction
An icon-only control in the bar (back, forward, a panel's toggle); name it with aria-label.
import { TopBarAction } from '@/components/ui/goop/top-bar';Options
- variant?: 'ghost' | 'outline' = 'ghost' —
ghost(the default): the quiet button, no fill until the pointer's wash;outline(the other theme's value) the theme's outline icon button, the card fill inside a 1 px grey edge, for a standing control. - icon?: IconName — A pack icon name, drawn by the button itself.
- children?: ReactNode — The button's own
IconButtonIcon(or, withasChild, the one element it becomes), in place oficon; one of the two is required. - Also takes: type?: 'button' | 'submit' | 'reset'; onClick?: (event: MouseEvent) => void; disabled?: boolean; aria-label: string; tooltip?: string | false; tooltipKeys?: readonly string[]; loading?: boolean = false; loadingLabel?: string = 'Loading'
Keyboard
| Key | What it does |
|---|---|
| Tab | Walk the crumbs, the title's menu button and the bar's controls in order; the bar holds no stop of its own |
| Enter Space | On the title's menu button: open the page's menu; on a control: the control's own |
| Enter | On a crumb: go to that page |
Accessibility
- The part itself answers the keys above.
- hover: the browser's own (:hover): write nothing
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| expanded | the attribute data-state=open |
| open | the attribute data-state=open |
| disabled | the prop disabled |
Motion
- The part sets its own motion: add no transition or animation of your own.
Responsive behaviour
- One bar per page, spanning its panel:
TopBarCrumbsand aTopBarTitle(or aTopBarTitleMenu) in the start group, the controls in the end group (TopBarActions, aToggleGroupwithvariant="outline"andfitas the segmented control, oneTopBarButton variant="primary"for the main action, last). On a phone keep the title, the main action and at most two icon controls; leave the segmented control to a menu.
Notes for AI
Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.