---
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/"
---

# Top bar

The 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.

Free. Its export: `TopBar`.

## Try it

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.

```sh
npx shadcn@4.23.1 add @goop/meadow-top-bar
```

```text
Add the Goop Top bar to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
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

### Parts

- `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.

```tsx
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, with `asChild`, the one element it becomes), in place of `icon`; 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'

### TopBarButton

The bar's worded action, the theme's 28 px Button.

```tsx
import { TopBarButton } from '@/components/ui/goop/top-bar';
```

### Options

- variant?: 'primary' | 'ghost' = 'ghost' — `ghost` (the default) a quiet action, `primary` the solid main action.
- Also takes: type?: 'button' | 'submit' | 'reset'; onClick?: (event: MouseEvent) => void; disabled?: boolean; loading?: boolean = false; loadingLabel?: string = 'Loading'

### TopBarTitleMenu

The page's name as a button that opens its menu, inside a heading.

```tsx
import { TopBarTitleMenu } from '@/components/ui/goop/top-bar';
```

### Options

- headingLevel?: 1 | 2 | 3 | 4 | 5 | 6 = 2 — The heading's level: 2 (the default) as `TopBarTitle`'s.
- Also takes: type?: 'button' | 'submit' | 'reset'; onClick?: (event: MouseEvent) => void; disabled?: boolean; aria-label?: string

## Keyboard

- 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
- 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: `TopBarCrumbs` and a `TopBarTitle` (or a `TopBarTitleMenu`) in the start group, the controls in the end group (`TopBarAction`s, a `ToggleGroup` with `variant="outline"` and `fit` as the segmented control, one `TopBarButton 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.

Shortened to fit: the data-slot values.

## Related

- [Toggle group](/themes/meadow/components/toggle-group): A row of toggle buttons that act together, one or several pressed, such as a list's filters or a view switch.
- [Page header](/themes/meadow/components/page-header): The title block that opens a page, with its page-level actions.
- [Section header](/themes/meadow/components/section-header): The title row over one block inside a page, with an optional count, description and actions, such as a settings section.
- [Toolbar](/themes/meadow/components/toolbar): A row of controls (a view's choice menus and its actions).
