Skip to main content
cngx-src documentation

CngxPopoverAction

ComponentPrimaryOnPushNo encapsulationv0.1.0WCAG AA

projects/common/popover/popover-action.component.ts

Import#

import { CngxPopoverAction } from '@cngx/common/popover'

Description#

Action button for use inside cngx-popover-panel footer.

Two roles:

  • 'dismiss' - closes the panel on click (no async action).
  • 'confirm' - executes an async action, shows status templates, optionally auto-closes the panel on success.

Supports the same cngxPending/cngxSucceeded/cngxFailed templates as CngxActionButton, or use status() + @switch for full control.

Dismiss button

<cngx-popover-action role="dismiss">Cancel</cngx-popover-action>

Confirm with templates

<cngx-popover-action role="confirm" [action]="save" variant="primary">
  Save
  <ng-template cngxPending>Saving...</ng-template>
  <ng-template cngxSucceeded>Saved!</ng-template>
  <ng-template cngxFailed let-err>{{ err }}</ng-template>
</cngx-popover-action>

With @switch

<cngx-popover-action role="confirm" [action]="save" #act="cngxPopoverAction">
  @switch (act.status()) {
    @case ('pending')   { Saving... }
    @case ('success') { Done }
    @default            { Save }
  }
</cngx-popover-action>

https://cngxjs.github.io/cngx/examples/#/common/popover/popover-panel/content-states https://cngxjs.github.io/cngx/examples/#/common/popover/popover-panel/variants https://cngxjs.github.io/cngx/examples/#/common/popover/popover-panel/with-footer-actions

Metadata#

Host#

Relationships

Index#

Inputs#

input()

The async action to execute (only for role="confirm").

feedbackDuration#
input()

Duration in ms to show success/error feedback.

default 2000
role#"dismiss" | "confirm"
input()

Button role: 'dismiss' closes immediately, 'confirm' runs an async action.

default 'confirm'
input()

Visual variant for the button.

default 'secondary'

Instance Properties#

failedTpl#unknown
contentChild()ProtectedReadonly
contentChild(CngxFailed)
pendingTpl#unknown
contentChild()ProtectedReadonly
contentChild(CngxPending)
succeededTpl#unknown
contentChild()ProtectedReadonly
contentChild(CngxSucceeded)

Methods#

handleDismiss#void
Protected

Default visuals for CngxPopoverAction. The component host has display: contents and renders a <button> carrying .cngx-popover-action plus a variant modifier. Designed to live inside a cngx-popover-panel footer - it picks up the parent panel's --cngx-popover-panel-accent / -text via CSS inheritance so variant colors flow through automatically.

State modifiers

  • :hover - wash applied via --cngx-popover-action-hover-bg
  • :focus-visible - outline ring in --cngx-popover-panel-accent-text
  • :disabled / [aria-disabled="true"] - opacity 0.5, cursor: not-allowed

Variants

  • --primary - accent fill from the parent panel, white-on-accent
  • --danger - danger surface, white text
  • --ghost - transparent border, hover-only wash

Slots

  • .cngx-popover-action__sr-only - sibling announcement span; lives outside the @scope wrap, duplicates the canonical .cngx-sr-only utility for standalone use

Inheritance

  • --cngx-popover-action-* (padding, gap, radius, font, transition)
    • leaf tokens, no fallback chain
  • Primary variant fill: --cngx-popover-panel-accent -> --cngx-color-primary
  • Primary variant text: --cngx-popover-panel-accent-text (parent panel)
  • Danger variant fill: --cngx-color-danger
  • Outer border: --cngx-popover-panel-border (parent panel)

Dark mode

Three hooks flip the hover wash from a 4% black overlay to a 6% white overlay so the wash stays visible against the dark panel surface:

  • prefers-color-scheme: dark
  • [data-color-scheme="dark"] / .dark class
  • [data-color-scheme="light"] / .light class (explicit pin)

Pair with

  • @cngx/themes/material/popover-panel-theme - Material 3 button-on-surface palette

Index#

Layout

--cngx-popover-action-padding-block#<length>
Default value 6px

Block-axis padding of the action button.

--cngx-popover-action-padding-inline#<length>
Default value 14px

Inline-axis padding of the action button.

--cngx-popover-action-gap#<length>
Default value 6px

Gap between the action's icon and label slots.

--cngx-popover-action-radius#<length>
Default value 6px

Corner radius of the action button.

Typography

--cngx-popover-action-font-size#*
Default value 0.8125rem

Font-size of the action label.

--cngx-popover-action-font-weight#<number>
Default value 500

Font-weight of the action label.

Motion

--cngx-popover-action-transition#<time>
Default value 150ms

Transition duration for the hover / focus state changes.

State / Hover

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

Hover-state surface - neutral default + ghost variant share this token so a single dark-mode swap covers both. Light: 4% black wash; dark: 6% white wash.