πŸŽ… Ship faster with premium components πŸŽ…
Search documentation v1.2.0

Seasonal Banner

Thematic banners enhanced with particle effects

Source Report Issue
Command docs
How to add this block to your project
npm run add SeasonalBanner

Use the SeasonalBanner component to display a promotional or thematic banner enhanced with particle effects (e.g. for Christmas, Halloween, New Year). They can:

Preview
Unlock code
How to use the SeasonalBanner component in Astro
<SeasonalBanner
text="Get 20% off for the holidays!"
href="/landing-page"
/>

The SeasonalBanner component expects a text and a href prop. By default, this will render a banner with an animated gradient background. The component is based off of the Banner component, meaning you can also pass BannerProps to the component.

Types

The component comes with a type prop that expect a preset type from the Confetti component. The banner comes with 33 predefined presets. This way, you can quickly set up banners for various events, such as for New Year, Halloween, or Easter.

Unlock code
How to use a preset
<SeasonalBanner
text="Get 20% off for the holidays!"
href="/landing-page"
type="newYear"
/>
Unlock code
How to use a preset
<SeasonalBanner
text="Take 20% off this Halloween season!"
href="/landing-page"
type="halloween"
/>

Colors

In case you don’t want to use a preset just a simply gradient, you can also set the following three props to match your brand:

Custom colors
Unlock code
How to set text and background colors
<SeasonalBanner
text="Get 20% off for the holidays!"
textColor="#FFF"
rgbBgColorFrom="255 70 140"
rgbBgColorTo="255 120 200"
/>

Configuring Colors with CSS

If you want to keep style-specific configuration in one place, you can also configure the above props through the following CSS variables:

Unlock code
How to configure colors in CSS
html body {
--w-seasonal-banner-text-color: var(--w-color-primary-20);
--w-seasonal-banner-bg-from: 17 17 17;
--w-seasonal-banner-bg-to: 0 0 0;
}

Customizing Confetti

To customize the behavior of particles, you can pass a confetti prop to the component. Here you can fully customize colors, shapes, and physics properties using a ConfettiProps object. For example:

Unlock code
How to customize particles
<SeasonalBanner
text="Get 20% off for the holidays!"
confetti={{
amount: 150
gravity: 0.008
terminalVelocity: 1.5
turbulence: 0
colors: ['#FFF', '#F0F8FF', '#E6F3FF']
size: 0.1
speed: 0.8
}}
/>
The particles are only animated when they are visible. Out of viewport banners become static to improve page performance.

API

Unlock code
Component API reference
type SeasonalBannerProps = {
text: string
href: string
target?: '_self'
| '_blank'
| '_parent'
| '_top'
| '_unfencedTop'
type?: keyof typeof confettiPresets
confetti?: Omit<ConfettiProps, 'canvas'>
textColor?: string
rgbBgColorFrom?: string
rgbBgColorTo?: string
} & BannerProps
PropPurpose
text Sets the text on the banner.
href Sets the link on the banner.
target Sets the target of the link.
type Sets the type of the banner. If no type is provided, a gradient background will be used.
confetti Pass ConfettiProps to customize the behavior of particles. This will override the type prop.
textColor Sets the color of the text. Automatically set for each type.
rgbBgColorFrom Pass an RGB triplet to set the starting color of the background.
rgbBgColorTo Pass an RGB triplet to set the ending color of the background.
className Pass additional CSS classes for the banner.