Skip to main content
cngx-src documentation

CngxBannerOutlet

ComponentPrimaryOnPushNo encapsulationv0.1.0WCAG AA

projects/ui/feedback/banner/banner-outlet.ts

Import#

import { CngxBannerOutlet } from '@cngx/ui/feedback'

Description#

Banner outlet - renders the global banner stack at the top of the page.

Place once in the app shell, above <router-outlet>. Requires provideFeedback(withBanners()).

Banners present at first render appear without animation to avoid layout jump on page load.

<cngx-banner-outlet />
<router-outlet />

https://cngxjs.github.io/cngx/examples/#/ui/feedback/banner/async-action https://cngxjs.github.io/cngx/examples/#/ui/feedback/banner/dedup-update https://cngxjs.github.io/cngx/examples/#/ui/feedback/banner/system-banners

Metadata#

Dependencies#

CngxBannerinject()service

Relationships

Default visuals for CngxBannerOutlet. The host carries .cngx-banner-outlet and is sticky-top with z-index: 900 so it sits below modal surfaces but above page content; empty outlets collapse. Each banner renders as .cngx-banner with __icon, __body, __message, __error, __action, and __dismiss children. Uses its own --cngx-banner-* namespace (not shared with --cngx-alert-*) so banners can be themed independently even though the severity-tint palette is visually identical.

State modifiers

  • --animate - 200ms enter slide-down (off under prefers-reduced-motion)
  • --pending - opacity dim + pointer-events: none

Variants

Severity classes pin four tokens each (bg / border / icon / accent):

  • --info - info palette
  • --success - success palette
  • --warning - warning palette
  • --error - error palette

Slots

  • .cngx-banner__icon - severity glyph
  • .cngx-banner__default-icon - SVG fallback when no custom icon is projected
  • .cngx-banner__message - body copy
  • .cngx-banner__error - inline-error sub-line; color delegates to --cngx-color-danger
  • .cngx-banner__action - projected action button tinted by --cngx-banner-accent (padding-based hit-target, no min-size floor so the button does not stand taller than the banner)
  • .cngx-banner__dismiss - dismiss control

Inheritance

  • --cngx-banner-error-color -> --cngx-color-danger

Dark mode

Three hooks swap every severity triplet plus the action-hover overlay (alpha-on-black flips to alpha-on-white):

  • prefers-color-scheme: dark
  • [data-color-scheme="dark"]
  • .dark class

Pair with

  • @cngx/themes/material/feedback-theme - Material 3 surface palette shared with CngxAlert and CngxAlertStack

Index#

Layout

--cngx-banner-z-index#<number>
Default value 900

Stacking-context order - sticky-top banner sits below modal surfaces but above page content.

--cngx-banner-gap#<length>
Default value 12px

Gap between icon, body, action, and dismiss slots.

--cngx-banner-padding#*
Default value 10px 16px

Padding shorthand inside each banner.

--cngx-banner-icon-size#<length>
Default value 20px

Default icon size when no custom icon is projected.

Surface

--cngx-banner-bg#<color>
Default value oklch(0.98 0.005 250)

Background - neutral by default; severity rules override.

--cngx-banner-color#*
Default value currentColor

Text color - defaults to currentColor.

--cngx-banner-border-color#<color>
Default value transparent

Border color - neutral by default; severity rules override.

--cngx-banner-icon-color#*
Default value currentColor

Icon color override - defaults to currentColor and is pinned by each severity rule.

--cngx-banner-accent#*
Default value currentColor

Accent color used by the action button border / foreground. Pinned by each severity rule.

Motion

--cngx-banner-enter-duration#<time>
Default value 200ms

Duration of the slide-down enter animation.

--cngx-banner-enter-offset#*
Default value 100%

Vertical offset the banner translates from while entering.

Variant / Info

--cngx-banner-info-bg#<color>
Default value oklch(0.96 0.025 250)

Background tint of the info severity.

--cngx-banner-info-border#<color>
Default value oklch(0.85 0.07 250)

Border color of the info severity.

--cngx-banner-info-icon#<color>
Default value oklch(0.62 0.2 250)

Icon color of the info severity.

Variant / Success

--cngx-banner-success-bg#<color>
Default value oklch(0.96 0.04 145)

Background tint of the success severity.

--cngx-banner-success-border#<color>
Default value oklch(0.85 0.1 145)

Border color of the success severity.

--cngx-banner-success-icon#<color>
Default value oklch(0.65 0.15 145)

Icon color of the success severity.

Variant / Warning

--cngx-banner-warning-bg#<color>
Default value oklch(0.97 0.04 80)

Background tint of the warning severity.

--cngx-banner-warning-border#<color>
Default value oklch(0.86 0.1 80)

Border color of the warning severity.

--cngx-banner-warning-icon#<color>
Default value oklch(0.72 0.18 70)

Icon color of the warning severity.

Variant / Error

--cngx-banner-error-bg#<color>
Default value oklch(0.96 0.025 25)

Background tint of the error severity.

--cngx-banner-error-border#<color>
Default value oklch(0.85 0.08 25)

Border color of the error severity.

--cngx-banner-error-icon#<color>
Default value oklch(0.62 0.22 25)

Icon color of the error severity.

Typography

--cngx-banner-font-size#*
Default value 0.9375rem

Font-size of the body message.

--cngx-banner-line-height#*
Default value 1.5

Line-height of the body message.

State / Error

--cngx-banner-error-font-size#*
Default value 0.875rem

Font-size of the inline-error sub-line.

--cngx-banner-error-color#<color>
Default value oklch(0.62 0.22 25)

Text color of the inline-error sub-line. Falls back to --cngx-color-danger.

State / Action

--cngx-banner-action-bg#<color>
Default value transparent

Background of the action button.

--cngx-banner-action-radius#<length>
Default value 4px

Corner radius of the action button.

--cngx-banner-action-padding#*
Default value 4px 10px

Padding shorthand of the action button.

--cngx-banner-action-min-size#<length>
Default value 44px

Minimum hit-target size of the action button (≥ 44 px).

--cngx-banner-action-font-size#*
Default value 0.875rem

Font-size of the action button label.

--cngx-banner-action-font-weight#<number>
Default value 600

Font-weight of the action button label.

--cngx-banner-action-hover-bg#<color>
Default value oklch(0 0 0 / 0.04)

Background tint applied on hover of the action button.

State / Pending

--cngx-banner-pending-opacity#<number>
Default value 0.85

Opacity multiplier applied while the banner is pending.