GooseUI

Components

Promo Banner

New

Floating promotional banner for campaigns and sales. It is a non-modal <dialog> rendered on the server: the close button is a <form method="dialog">, so it works without JavaScript. The marquee and the entry animation are pure CSS. A small client script runs only when you pass storageKey, onClose or onCtaClick: it remembers the dismissal and calls the callbacks.

Browser Support

<dialog>

Displays the promotional banner.

Your browser:
@starting-style

Animates the banner entrance.

Your browser:
transition-behavior

Animates the banner exit.

Your browser:

Preview

Installation

npx shadcn@latest add @gooseui/promo-banner
pnpm dlx shadcn@latest add @gooseui/promo-banner
yarn dlx shadcn@latest add @gooseui/promo-banner
bunx --bun shadcn@latest add @gooseui/promo-banner

The marquee keyframes ship inside the component, nothing to add to globals.css. The marquee pauses on hover and stops for reduced motion.

Usage

import { PromoBanner } from "@/components/ui/promo-banner"

export default function Page() {
  return (
    <PromoBanner
      title="Winter Campaign"
      headline="START THE NEW YEAR WITH A BANG!"
      price={229}
      originalPrice={1444}
      ctaText="Get Bundle"
      ctaHref="/docs"
      marqueeText="3 DAYS LEFT • FIRST 100 ONLY"
      storageKey="promo-winter"
    />
  )
}

Examples

Positions

Choose where the banner appears on screen

<PromoBanner position="top-left" />
<PromoBanner position="top-right" />
<PromoBanner position="bottom-left" />
<PromoBanner position="bottom-right" /> // default

Custom Gradients

The gradient takes colors from theme tokens, so it follows the active theme. Pass any Tailwind classes to change it

<PromoBanner
  gradientFrom="from-foreground"
  gradientTo="to-[color-mix(in_oklab,var(--foreground)_40%,var(--primary))]"
/>

With localStorage

Remember when the user closes the banner. An inline script hides a dismissed banner before the first paint, so it does not flash.

<PromoBanner
  storageKey="promo-winter"
  delay={3000} // show after 3 seconds
/>

Using Provider

Global banner management with context. The provider and the hook are client code.

import { Button } from "@/components/ui/button"

import { PromoBannerProvider, usePromoBanner } from "@/components/ui/promo-banner"

// In layout or app
<PromoBannerProvider>
  <App />
</PromoBannerProvider>

// Anywhere in your app
function Component() {
  const { show, hide } = usePromoBanner()

  return (
    <Button onClick={() => show({
      headline: "Flash Sale!",
      price: 99,
      originalPrice: 199,
    })}>
      Show Promo
    </Button>
  )
}

Props

PropTypeDefaultDescription
headlinestringrequiredMain headline text
pricenumber-Current price
titlestring"Special Offer"Small title above headline
originalPricenumber-Original price (crossed out)
currencystring"$"Currency symbol
ctaTextstring"Get Now"CTA button text
ctaHrefstring"#"CTA button link
marqueeTextstring-Scrolling text at bottom
position"bottom-right" | "bottom-left" | "top-right" | "top-left""bottom-right"Banner position
gradientFromstring"from-foreground"Gradient start color class
gradientTostring"to-[color-mix(in_oklab,var(--foreground)_55%,var(--primary))]"Gradient end color class
storageKeystring-localStorage key for persistence
delaynumber0Delay before showing (ms)
imagesstring[]-Product image URLs
defaultOpenbooleantrueRender the banner open
showPatternbooleanfalseDiagonal lines on the background
labels{ banner?: string; close?: string }-Accessible names of the banner and the close button
onClose() => void-Close callback, client components only
onCtaClick() => void-CTA click callback, client components only