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

# Banner

A full-width band across the top of the app or a page for one message that stays until it is no longer true, such as a trial ending, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `Banner`.

## When to use

- A full-width band across the top of the app or a page for one message that stays until it is no longer true, such as a trial ending.
- Also called: announcement bar.

## 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 Banner on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-banner.json --yes
```

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

## Usage

```tsx
import { Banner, BannerIcon, BannerTitle, BannerDescription, BannerAction } from '@/components/ui/goop/banner';
import { useState, useEffect } from 'react';
import { AppFrame, AppFramePanel } from '@/components/goop/patterns/app-frame';
import { Button } from '@/components/ui/goop/button';
import { TopBar, TopBarRow, TopBarGroup, TopBarTitle } from '@/components/ui/goop/top-bar';

function TrialBanner() {
  const [shown, setShown] = useState(true);
  useEffect(() => {
    if (sessionStorage.getItem('banner:trial-ends') !== null) setShown(false);
  }, []);
  return (
    <AppFrame>
      <AppFramePanel
        header={
          <>
            <Banner
              open={shown}
              variant="warning"
              onDismiss={() => {
                sessionStorage.setItem('banner:trial-ends', 'closed');
                setShown(false);
                document.getElementById('page-title')?.focus();
              }}
            >
              <BannerIcon />
              <BannerTitle>Your trial ends in 3 days</BannerTitle>
              <BannerDescription>Add a payment method to keep your projects.</BannerDescription>
              <BannerAction>
                <Button variant="outline" size="sm">
                  Add payment method
                </Button>
              </BannerAction>
            </Banner>
            <TopBar role="banner">
              <TopBarRow>
                <TopBarGroup>
                  <TopBarTitle id="page-title" tabIndex={-1}>
                    Projects
                  </TopBarTitle>
                </TopBarGroup>
              </TopBarRow>
            </TopBar>
          </>
        }
      >
        <p>Three projects are due this week.</p>
      </AppFramePanel>
    </AppFrame>
  );
}
```

- Fits: overview, settings: header.
- One banner at a time per surface. A message about one section or record is `Alert`; the result of an action `Toast`; a choice to make now `AlertDialog`. In the app: `header={<><Banner …/><TopBar role="banner">…</TopBar></>}`; in a Card, a Sheet or a Dialog, its first child. Never size it. On `primary` the action is the outline Button or a Link.
- height, width, padding, gap, corner, border, background, text, motion: add no class for these.

## API reference

### Options

- `variant: default | info | success | warning | destructive | primary = default`
- `open?: boolean` — Whether the strip is shown (shown when left out).
- `onDismiss?: () => void` — Called when the close is pressed; given, the close is drawn.
- `dismissLabel?: string = 'Dismiss'` — The close's spoken name, before the title's words: "Dismiss" unless given.

### Parts

- `BannerIcon` — The kind's pack icon, 16 px, at the start, centred on the first line; icon?: IconName — A pack icon name in place of the kind's
- `BannerTitle` — The message's few words, in the medium weight, before the message on the same line; wraps, never cut
- `BannerDescription` — The message, after the title on the same line where it fits; shown whole, never cut
- `BannerAction` — The caller's action after the words — the theme's small `Button` (`size="sm"`; on `primary` `variant="outline"`) or its `Link` — centred on the first line; on a phone under the words

- Class recipes (cva): bannerVariants (Banner)
- data-slot values (to select a part by): banner, banner-action, banner-body, banner-content, banner-description, banner-fold, banner-icon, banner-inset, banner-title

## Accessibility

- hover, active, focus-visible: the browser's own (:hover, :active, :focus-visible): write nothing
- expanded: the attribute data-state=open
- open: the attribute data-state=open

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

- [App frame](/themes/trail/components/app-frame): The window every page of the app sits in, with the navigation at its side and the top bar over the page.
- [Button](/themes/trail/components/button): A button with words that runs an action, in several looks and sizes.
- [Top bar](/themes/trail/components/top-bar): The bar across the top of a page in the app frame, with its title, tabs and actions.
- [Progress](/themes/trail/components/progress): A bar for work under way, its amount known or not.
