Directory
- Welcome
Pop Banner Component
The Pop Banner component provides a flexible way to display temporary messages or notifications to users. It supports multiple positions, auto-dismiss functionality, and customizable content.
Key Features
-
Flexible Positioning: Left, right, or center alignment options
-
Auto-dismiss: Optional timeout for automatic hiding
-
Customizable Content: Supports any HTML content
-
Animated: Smooth show/hide transitions
Basic Usage
Create a basic pop banner with default settings:
<PopBanner> <p>This is a pop banner message!</p></PopBanner>
Variants
Default Center Position
A centered pop banner with default styling
<PopBanner> <p>A centered pop banner with default styling</p></PopBanner>
Left-Aligned with Timeout
This banner will auto-dismiss after 5 seconds
<PopBanner position="left" timeout={5000}> <p>This banner will auto-dismiss after 5 seconds</p></PopBanner>
Pop Banner Component Props API
Prop | Type | Default | Description |
---|---|---|---|
position | 'left' | 'right' | 'center' | center | Position of the banner on the screen |
timeout | number | undefined | Time in milliseconds before auto-dismissing |
showCloseButton | boolean | true | Whether to show the close button |
PopBanner Functions API
The Pop Banner component exposes methods for programmatic control:
// Show the bannerdocument.querySelector('pop-banner').toggle(true);// Hide the bannerdocument.querySelector('pop-banner').toggle(false);// Toggle the bannerdocument.querySelector('pop-banner').toggle();
Event Handling
The Pop Banner component emits custom events that you can listen to:
// Listen for the 'show' eventdocument.querySelector('pop-banner').addEventListener('show', () => { console.log('Banner is visible');});
Common Use Cases
Limited Time Launch Sale
Add dynamic pop banners to your website with our AstroJS starter template. Get started now!
GET 60% OFF!