ui · Primitive
Banner
@devalok/shilp-sutra/ui/bannerView in Storybook Hand-curated previews ship in rolling waves. See it live in Storybook →
Reference
Props
color: "info" | "success" | "warning" | "error" | "neutral"
actions: ReactNode (optional action slot for one or more buttons; wraps on narrow viewports)
onDismiss: () => void (optional, shows X button)
children: ReactNode (message text)
Defaults
color="info"
Example
<Banner color="warning" onDismiss={() => dismiss()}>
Scheduled maintenance on Sunday.
</Banner>
Composability
- Banner vs Alert vs Toast: Banner is full-width, top-of-page / top-of-region announcements (maintenance, quota, trial-expiring). Alert is inline in-flow. Toast is transient floating notifications. Pick by where the message lives in the visual hierarchy.
- actions slot: Pass one or more
<Button>elements — the container flex-wraps on narrow viewports so actions drop below the message rather than squeezing horizontally. - Role=alert announces assertively. Same constraint as Alert — don't stack multiple Banners.
- Dismissal timing:
onDismissfires AFTER the exit animation completes, not on click. Use it to remove the banner from state only after it's visually gone. - Works inside Shell layouts (TopBar / Sidebar / main content) — usually sits above main content, below the TopBar.
Gotchas
- Banner is full-width (spans container). Alert is inline.
- Renders role="alert" automatically
onDismissfires after the exit animation completes, not immediately on dismiss button click
Changes
v0.38.0
- Removed (BREAKING) deprecated singular
actionprop. Useactions={[...]}(plural).
v0.20.0
- Added
actionsprop (plural) for multiple action buttons with mobile-friendly flex-wrap - Deprecated
actionprop — useactionsinstead (both still work;actionstakes priority) - Changed Root layout uses
flex-wrapand children wrapper usesmin-w-0for better text truncation
v0.3.1
- Fixed BannerProps uses
Omit<HTMLAttributes, 'color'>to resolve TypeScript conflict with CVAcolorvariant
v0.3.0
- Changed (BREAKING)
variantprop renamed tocolorfor semantic intent
v0.1.0
- Added Initial release