Banner for Astro
Astro announcement containers with optional dismissal and stored visibility.
Usage
import { Banner, BannerContainer } from "@/components/ui/banner"
<Banner>
<BannerContainer>
<p class="text-sm font-medium">Banner Title</p>
<p class="text-sm opacity-90">Banner Description</p>
</BannerContainer>
</Banner>
BannerContainer renders a close button by default. Set showClose={false} to
hide it.
<Banner>
<BannerContainer showClose={false}>
<p class="text-sm font-medium">Banner Title</p>
<p class="text-sm opacity-90">Banner Description</p>
</BannerContainer>
</Banner>
Examples
Installation
bunx --bun shadcn@latest add @gnostic/bannernpx shadcn@latest add @gnostic/bannerpnpm dlx shadcn@latest add @gnostic/bannerCopy the files
src/components/ui/banner/banner-container.astrosrc/components/ui/banner/banner.astrosrc/components/ui/banner/types.tssrc/components/ui/banner/index.ts
Set mode="inverted" to swap the banner colors. Controls inside the banner
inherit those colors.
Notes
- The default banner spans its available width.
- Set
variant="floating"for a bar with an inset surface.
API Reference
Read the installed source for the complete prop types.
When to use Banner
Place a Banner near the top of the page for a service notice or current announcement. Use the default or floating layout to suit the page shell, then add message and action parts through slots.
Keyboard and behavior
A dismissal control needs a clear accessible name. If you use storageKey, the client behavior can retain the dismissed state; change the key when the notice itself changes. Important information must also remain available elsewhere after dismissal.
Theme and layout
Check long text beside the action at a narrow width. Shared background and border tokens keep the banner consistent with the page, but a persistent banner must not cover a focused control or heading.