Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Banner

ProNew

A promotional banner with picture, headline, text, coupon and call to action; a wide strip, a tall card or a small card floating in a corner.

Installation

pnpm dlx shadcn@latest add @viewport/banner

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
title*string

The headline, e.g. "25% OFF".

—
eyebrowstring

Short line above the headline, e.g. the name of the sale.

—
textReact.ReactNode

Supporting text under the headline.

—
details{ label: string; value: string }[]

Short facts under the text as label and value pairs, e.g. the date and place of an event.

—
imagestring

Photo or illustration.

—
imageAltstring

Alt text for the picture. Leave it out when the picture is decoration.

""
videostring

A video file (mp4/webm) playing muted and looped behind the content when `media` is `cover`. Paused under reduced motion; `image` is its poster. Decorative, never the only carrier of information.

—
couponstring

Coupon code in a dashed pill. Pressing it copies the code.

—
onCopy(code: string) => void

Called with the code after it has been copied.

—
actionBannerAction

Call to action.

—
layout"strip" | "card" | "floating"

`strip` is a wide banner with the picture beside the text; `card` is a tall one with the picture under it; `floating` is a small card pinned to a corner with a close button.

"strip"
media"end" | "start" | "cover"

Where the picture goes: after the text, before it, or behind it as a `cover`. Defaults to `start` for the floating layout and `end` otherwise.

—
divider"waves" | "fade" | "none"

How the picture meets the text: layered `waves`, a soft `fade`, or a straight cut. Defaults to `waves` for the strip and `fade` otherwise.

—
align"center" | "start"

Text alignment. Defaults to `center` for the strip and `start` otherwise.

—
theme"dark" | "light" | "blue" | "night" | "sand"

Color theme. `light` follows your light and dark tokens; the others keep their colors in both.

"dark"
colors{ background?: string; text?: string; accent?: string; accentText?: string; wave?: string }

Overrides for single colors of the theme. Any CSS color.

—
position"bottom-right" | "bottom-left" | "top-right" | "top-left"

Corner used by the floating layout.

"bottom-right"
anchor"viewport" | "parent"

What the floating banner pins to: the viewport, or the nearest positioned ancestor.

"viewport"
delaynumber

Milliseconds before the floating banner appears.

0
dismissibleboolean

Shows the close button. On by default for the floating layout.

—
onDismiss() => void

Called after the banner has closed.

—
labelstring

Accessible name of the banner. Defaults to the headline.

—
classNamestring—

Accessibility

  • The banner is a region named by its headline, which is a real heading; the action is a link or a button.
  • The coupon is a button named “Copy code BFSALE25” and reports “copied to clipboard”, or the code itself if copying fails, through a status.
  • The floating banner has a Close button and also closes with Escape while focus is inside it.
  • The picture is decoration unless you pass `imageAlt`. Under reduced motion the text and picture appear in place and the ribbons hold still.