---
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 in the app frame, with its title, tabs and actions, 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 in the app frame, with its title, tabs and actions.
- 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/trail-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 { TopBar, TopBarRow, TopBarGroup, TopBarTitle, TopBarTitleMenu, TopBarToggle, TopBarButton, TopBarAction, TopBarTabs } from '@/components/ui/goop/top-bar';
import { ButtonIcon } from '@/components/ui/goop/button';

<TopBar>
  <TopBarRow>
    <TopBarGroup>
      <TopBarTitle>Inbox</TopBarTitle>
    </TopBarGroup>
    <TopBarGroup align="end">
      <TopBarButton>
        <ButtonIcon icon="plus" />
        New note
      </TopBarButton>
      <TopBarAction icon="adjustments-horizontal" aria-label="Display options" />
    </TopBarGroup>
  </TopBarRow>
</TopBar>
```

- Fits: frame (its recipe).
- height, width, padding, gap, border, 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
- `TopBarTitle` — The page's name; takes asChild
- `TopBarTitleMenu` — The page's name as a button that opens its menu, inside a heading; 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
- `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 quiet worded action, a 28 px ghost pill button holding a ButtonIcon and words; also takes type?: 'button' | 'submit' | 'reset'; onClick?: (event: MouseEvent) => void; disabled?: boolean; loading?: boolean = false; loadingLabel?: string = 'Loading'
- `TopBarAction` — An icon-only control in the bar, ringed (the default) or quiet; name it with aria-label; variant?: 'outline' | 'ghost' = 'outline' — `outline` (the default) the white ringed button at the row's end, `ghost` the quiet one with no fill; icon?: IconName — A pack icon name (an outline icon, or a filled one), 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'
- `TopBarTabs` — The bar's view pills, a tab list inside the caller's Tabs holding TabsTriggers; name it with aria-label; also takes action?: ReactNode; size?: 'sm' | 'md' = 'md'

- data-slot values (to select a part by): top-bar, top-bar-group, top-bar-row, top-bar-title, top-bar-title-menu

## Accessibility

- hover, active: the browser's own (:hover, :active): write nothing
- pressed: the attribute aria-pressed
- 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.

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

## Related

- [Button](/themes/trail/components/button): A button with words that runs an action, in several looks and sizes.
- [Page header](/themes/trail/components/page-header): The title block that opens a page, with its page-level actions.
- [Section header](/themes/trail/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/trail/components/toolbar): A row of controls over a list, such as a period select and its filter and view buttons.
