Skip to content

TopBanner

The TopBanner component displays a prominent announcement banner at the very top of the page, typically for important notices or calls-to-action.

  • Type: Layout Component
  • Category: Announcement
  • Complexity: Simple
  • File: src/components/TopBanner.astro
  • Dismissible - Users can close the banner (with JavaScript)
  • Call-to-Action - Optional link button
  • Sticky Positioning - Can stick to top on scroll
  • Configurable Colors - Typically uses brand colors
interface Props {
message: string;
link?: string;
linkText?: string;
backgroundColor?: string;
textColor?: string;
}
PropTypeDefaultDescription
messagestringRequiredAnnouncement text to display
linkstringundefinedOptional URL for CTA button
linkTextstringundefinedText for CTA button
backgroundColorstring'bg-blue-900'Tailwind background color class
textColorstring'text-white'Tailwind text color class
---
import TopBanner from '@/components/TopBanner.astro';
---
<TopBanner message="Important announcement here!" />
  • Background: Blue-900 (bg-blue-900)
  • Text: White with medium font weight
  • Padding: Vertical padding for comfortable reading
  • Responsive: Stacks on mobile, inline on desktop
  • Centered content with max-width
  • Flexbox for message and CTA alignment
  • Gap between elements
  1. Event Announcements

    <TopBanner
    message="Triennial Gathering 2026 - Register Now!"
    link="/events/triennial-2026"
    linkText="Details"
    />
  2. Membership Drives

    <TopBanner
    message="Become a member and join our community"
    link="/membership"
    linkText="Join Today"
    />
  3. Important Notices

    <TopBanner message="Website maintenance scheduled for Sunday 2AM-4AM CET" />
  • Color Contrast: Ensure sufficient contrast for readability
  • Link Semantics: Uses proper <a> tags for CTAs
  • Keyboard Navigation: All interactive elements are keyboard accessible
  • None (standalone component)
  • Selected pages where announcements are needed
  • Often included at the very top of BaseLayout.astro

View the complete implementation:

https://github.com/poncardasm/finan-website/blob/main/src/components/TopBanner.astro