npx shadcn@4.23.1 add @goop/trail-top-barTop bar
FreeThe bar across the top of a page in the app frame, with its title, tabs and actions, for React and Tailwind CSS. Free, MIT.
What an agent sees
- TopBarRowOne row of the bar
- TopBarGroupA group of a row
- 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 quiet worded action, a 28 px ghost pill button holding a ButtonIcon and words
- TopBarActionAn icon-only control in the bar, ringed (the default) or quiet
- TopBarTabsThe bar's view pills, a tab list inside the caller's Tabs holding TabsTriggers
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>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.
npx shadcn@4.23.1 add @goop/trail-top-barAdd the Goop Top bar to this project. The install steps are at https://goop.so/docs/install.mdUsage
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
| 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 |
| 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
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| 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.
- How the theme moves, and how to move your own parts the same way: Motion.
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.