Banner
ProNewA 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
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
Props
| Prop | Type | Default |
|---|---|---|
| title* | stringThe headline, e.g. "25% OFF". | — |
| eyebrow | stringShort line above the headline, e.g. the name of the sale. | — |
| text | React.ReactNodeSupporting 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. | — |
| image | stringPhoto or illustration. | — |
| imageAlt | stringAlt text for the picture. Leave it out when the picture is decoration. | "" |
| video | stringA 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. | — |
| coupon | stringCoupon code in a dashed pill. Pressing it copies the code. | — |
| onCopy | (code: string) => voidCalled with the code after it has been copied. | — |
| action | BannerActionCall 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" |
| delay | numberMilliseconds before the floating banner appears. | 0 |
| dismissible | booleanShows the close button. On by default for the floating layout. | — |
| onDismiss | () => voidCalled after the banner has closed. | — |
| label | stringAccessible name of the banner. Defaults to the headline. | — |
| className | string | — |
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.