Action Panel

The <smart-action-panel> component renders a standalone panel with a heading, description and one or more actions (buttons or links). It is typically used to surface a small "card" of contextual settings (e.g. Manage subscription, Update your email, Renew automatically). It follows the Base + Standard + Wrapper pattern with an InjectionToken-based extension mechanism. The abstract ActionPanelBaseComponent defines the shared API — options (IActionPanelOptions), cssClass (alias class), and the actionClick output. ActionPanelStandardComponent is a barebones placeholder using native <section>, <h3>, <p>, <a>, and <button> elements. ActionPanelComponent is the public wrapper that renders ActionPanelStandardComponent by default and accepts a custom replacement via ACTION_PANEL_STANDARD_COMPONENT_TOKEN.


Usage

<smart-action-panel [options]="options" (actionClick)="onActionClick($event)" />

@if (lastAction(); as action) {
  <p>Last action: {{ action }}</p>
}

The preview renders the code above in an application that registers every preset (provideSmartPresets(), see Installation) and the English translations; without the presets, a component that has one renders its standard implementation instead, for most components unstyled markup.

Components

ActionPanelComponent (<smart-action-panel>)

Main wrapper. Delegates to ActionPanelStandardComponent by default. When ACTION_PANEL_STANDARD_COMPONENT_TOKEN is provided, renders the injected component via NgComponentOutlet, passes it the inputs and re-emits its actionClick.

ActionPanelStandardComponent (<smart-action-panel-standard>)

Barebones placeholder using native HTML. Renders an outer wrapper with cssClass, a <section class="action-panel"> containing an optional <h3>{{ options.title }}</h3>, an optional description (string options.description rendered as <p class="description"> or options.descriptionTpl rendered via NgTemplateOutlet), an optional <div class="content"> slot from options.contentTpl, and an optional <div class="actions"> row of <button class="action variant-{variant}"> (or <a> when action.href is provided) per options.actions entry that emits { actionId } via actionClick. It does not vary its markup by options.layout.

ActionPanelBaseComponent (abstract)

Abstract base directive. Exposes:

  • options: InputSignal<IActionPanelOptions | undefined>
  • cssClass: InputSignal<string> (alias class)
  • actionClick: OutputEmitterRef<IActionPanelActionClick>

IActionPanelActionClick = { actionId: string }.

API

Inputs

InputTypeDefaultDescription
optionsInputSignal<IActionPanelOptions | undefined>-Panel configuration
classInputSignal<string>''External CSS classes (alias for cssClass)

Outputs

OutputTypeDescription
actionClickOutputEmitterRef<IActionPanelActionClick>Emitted when a button-type action is clicked

IActionPanelOptions

FieldTypeDefaultDescription
titlestringundefinedHeading of the panel.
descriptionstringundefinedText under the heading.
layoutSmartActionPanelLayout'simple'Preset only: one of the eight arrangements of ActionPanelPresetComponent. The standard does not vary its markup by layout.
actionsIActionPanelAction[][]The buttons / links of the panel.
descriptionTplTemplateRef<unknown>undefinedReplaces description with a template.
contentTplTemplateRef<unknown>undefinedExtra content placed in the panel (a toggle, an input, a card).

IActionPanelAction

FieldTypeDefaultDescription
idstringrequiredReported as actionId by actionClick.
labelstringundefinedText of the button / link.
hrefstringundefinedRenders the action as a link instead of a button (no actionClick).
variant'primary' | 'secondary' | 'ghost' | 'link'undefinedLook of the action. The standard only adds the class variant-<variant> (variant-primary by default for buttons, variant-link for links). The preset renders primary as a solid button and every other value, or none, as an outline button; in the with-link layout every action looks like a link.
iconTplTemplateRef<unknown>undefinedIcon rendered before the label.

SmartActionPanelLayout is 'simple' | 'with-link' | 'right-button' | 'top-right-button' | 'with-toggle' | 'with-input' | 'well' | 'payment-method'.

ACTION_PANEL_STANDARD_COMPONENT_TOKEN

InjectionToken that replaces the default ActionPanelStandardComponent with a custom implementation: provide a Type<ActionPanelBaseComponent> under ACTION_PANEL_STANDARD_COMPONENT_TOKEN. Every <smart-action-panel> in that injector renders it, gets the wrapper's inputs (class included) and re-emits its actionClick.

Extending the base class

import {
  ChangeDetectionStrategy,
  Component,
  ViewEncapsulation,
} from '@angular/core';

import {
  ActionPanelBaseComponent,
  ActionPanelComponent,
  ACTION_PANEL_STANDARD_COMPONENT_TOKEN,
  IActionPanelOptions,
} from '@smartsoft001/angular';

@Component({
  selector: 'docs-custom-action-panel',
  template: `
    <section class="docs-action-panel" [class]="cssClass()">
      @if (options()?.title) {
        <h3 class="docs-action-panel__title">{{ options()!.title }}</h3>
      }
      @if (options()?.description) {
        <p class="docs-action-panel__description">
          {{ options()!.description }}
        </p>
      }
      @for (action of options()?.actions ?? []; track action.id) {
        <button
          type="button"
          class="docs-action-panel__action"
          (click)="actionClick.emit({ actionId: action.id })"
        >
          {{ action.label }}
        </button>
      }
    </section>
  `,
  encapsulation: ViewEncapsulation.None,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CustomActionPanelComponent extends ActionPanelBaseComponent {}

@Component({
  selector: 'docs-action-panel-custom-example',
  imports: [ActionPanelComponent],
  providers: [
    {
      provide: ACTION_PANEL_STANDARD_COMPONENT_TOKEN,
      useValue: CustomActionPanelComponent,
    },
  ],
  template: `<smart-action-panel [options]="options" />`,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ActionPanelCustomExampleComponent {
  options: IActionPanelOptions = {
    title: 'Transfer ownership',
    description: 'Move this project to another workspace member.',
    actions: [
      { id: 'transfer', label: 'Transfer' },
      { id: 'cancel', label: 'Cancel' },
    ],
  };
}

Preset

ActionPanelPresetComponent (<smart-action-panel-preset>) extends ActionPanelStandardComponent and restyles the panel as a bordered card (rounded-xl border bg-white p-4 shadow-2xs sm:p-6 + dark twin). Title uses text-base font-semibold text-gray-900, description text-sm text-gray-500; descriptionTpl overrides the description text.

Register it under ACTION_PANEL_STANDARD_COMPONENT_TOKEN ({ provide: ACTION_PANEL_STANDARD_COMPONENT_TOKEN, useValue: ActionPanelPresetComponent }) to restyle every <smart-action-panel>, register every preset at once with provideSmartPresets(), or use the <smart-action-panel-preset> selector directly. Used directly, it takes the extra classes as class or [cssClass].

All eight SmartActionPanelLayout values are realized through a @switch (default simple):

  • simple / with-input / payment-method — title, description, content slot, then actions stacked below.
  • with-link — actions rendered as text-blue-600 hover:underline links.
  • right-button — flex row, content left, actions right, vertically centered.
  • top-right-button — actions in the title row, right-aligned.
  • with-toggle — content slot placed beside the text (flex row), actions below.
  • well — content and actions wrapped in an inset bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 panel.

Actions map by variant: primary → solid bg-blue-600 text-white, any other value or none → outline border-gray-200 bg-white text-gray-800 + dark. href actions render as <a>, the rest as <button> emitting actionClick with the action id. DOM hooks: data-role of panel/title/description/content/actions/well, plus per-action data-role="action" with data-action-id; the panel also carries data-layout.

Gaps: with-toggle / with-input / payment-method only position the content slot — the interactive control (toggle switch, input, card list) is supplied by the caller via contentTpl.

Source

The component lives in packages/shared/angular/src/lib/components/action-panel and is documented for Claude Code by the angular-components-action-panel skill.

SmartActionPanel renders a call-to-action panel: a title, a description (or a descriptionTpl node), an optional content slot (contentTpl, e.g. a toggle or an input) and a row of actions. Actions with href render as links, the others as buttons that report onActionClick({ actionId }). options.layout picks one of eight arrangements, styled by SmartActionPanelPreset.


Usage

import { useState } from 'react';

import {
  IActionPanelActionClick,
  IActionPanelOptions,
  SmartActionPanel,
} from '@smartsoft001/react';

const options: IActionPanelOptions = {
  layout: 'right-button',
  title: 'Manage subscription',
  description: 'Change your plan or cancel at the end of the billing period.',
  actions: [{ id: 'change-plan', label: 'Change plan', variant: 'primary' }],
};

export function ActionPanelUsageExample() {
  const [lastAction, setLastAction] = useState<string | null>(null);

  const onActionClick = ({ actionId }: IActionPanelActionClick) =>
    setLastAction(actionId);

  return (
    <>
      <SmartActionPanel options={options} onActionClick={onActionClick} />
      {lastAction && <p>Last action: {lastAction}</p>}
    </>
  );
}

The preview renders the code above in an application that registers every preset (SMART_PRESET_COMPONENTS on SmartProvider, see Installation) and the English translations; without the presets, a component that has one renders its standard implementation instead, for most components unstyled markup.

Exports

All from @smartsoft001/react.

ExportKindWhat it is
SmartActionPanelcomponentRenders the implementation registered as components['action-panel'] on SmartProvider, SmartActionPanelStandard by default.
SmartActionPanelPresetcomponentStyled action-panel variation (preset).
SmartActionPanelStandardcomponentThe default action panel: a section.action-panel with the title, the description (or options.descriptionTpl), options.contentTpl and the actions.

The preset's class helpers (getActionPanelCardClasses, getActionPanelTitleClasses, getActionPanelDescriptionClasses, getActionPanelWellClasses, getActionPanelActionClasses) are exported too, for a custom implementation that wants the preset look.

Props and Types

SmartActionPanelProps

PropTypeDefaultDescription
options?IActionPanelOptions—The panel's content and layout.
className?string—Classes on the root element: the div around section.action-panel (standard), the card (preset).
onActionClick?(event: IActionPanelActionClick) => void—Called when an action without href is clicked.

IActionPanelOptions

FieldTypeDefaultDescription
title?string—Heading of the panel.
description?string—Text under the heading.
layout?SmartActionPanelLayout'simple'One of the eight SmartActionPanelLayout arrangements; the standard implementation does not vary its markup by layout, the preset does.
actions?IActionPanelAction[][]The buttons / links of the panel.
descriptionTpl?ReactNode—Replaces description with a node.
contentTpl?ReactNode—Extra content placed in the panel (a toggle, an input, a card).

IActionPanelActionClick

Passed to onActionClick when a button action is clicked.

FieldTypeDefaultDescription
actionIdstringrequiredThe id of the clicked action.

IActionPanelAction

FieldTypeDefaultDescription
idstringrequiredReported as actionId by onActionClick.
label?string—Text of the button / link.
href?string—Renders the action as a link instead of a button (no onActionClick).
variant?'primary' | 'secondary' | 'ghost' | 'link'—Look of the action. The standard only adds the class variant-<variant> (variant-primary by default for buttons, variant-link for links). The preset renders primary as a solid button and every other value, or none, as an outline button; in the with-link layout every action looks like a link.
iconTpl?ReactNode—Icon rendered with the label.
  • SmartActionPanelLayout: 'simple' \| 'with-link' \| 'right-button' \| 'top-right-button' \| 'with-toggle' \| 'with-input' \| 'well' \| 'payment-method'

Replacing the Implementation

SmartActionPanel renders the component registered under the 'action-panel' key of SmartProvider's components, and SmartActionPanelStandard when nothing is registered there. Every SmartActionPanel below the provider then renders the registered component, which receives the same props.

SmartActionPanelPreset is the styled (preset) implementation: register it under the 'action-panel' key of SmartProvider's components, render it directly in place of SmartActionPanel, or spread SMART_PRESET_COMPONENTS on the provider to register every preset at once (see the react-provider skill). Pass components as a stable object (a module constant or a memoised value), or the context changes on every render.

A custom implementation takes SmartActionPanelProps and calls onActionClick for its buttons:

import {
  IActionPanelOptions,
  SmartActionPanel,
  SmartActionPanelProps,
  SmartProvider,
} from '@smartsoft001/react';

export function CustomActionPanel({
  options,
  className,
  onActionClick,
}: SmartActionPanelProps) {
  return (
    <section
      className={['docs-action-panel', className].filter(Boolean).join(' ')}
    >
      {options?.title && (
        <h3 className="docs-action-panel__title">{options.title}</h3>
      )}
      {options?.description && (
        <p className="docs-action-panel__description">{options.description}</p>
      )}
      {(options?.actions ?? []).map((action) => (
        <button
          key={action.id}
          type="button"
          className="docs-action-panel__action"
          onClick={() => onActionClick?.({ actionId: action.id })}
        >
          {action.label}
        </button>
      ))}
    </section>
  );
}

// A module constant: a new object on every render would change the context.
const components = { 'action-panel': CustomActionPanel };

const options: IActionPanelOptions = {
  title: 'Transfer ownership',
  description: 'Move this project to another workspace member.',
  actions: [
    { id: 'transfer', label: 'Transfer' },
    { id: 'cancel', label: 'Cancel' },
  ],
};

export function ActionPanelCustomExample() {
  return (
    <SmartProvider components={components}>
      <SmartActionPanel options={options} />
    </SmartProvider>
  );
}

Styling

  • SmartActionPanelStandard renders a section.action-panel with the title, description, content and actions in one arrangement; SmartActionPanelPreset renders a bordered card and re-composes the parts per layout (row, split, well, ...), with smart:dark: variants.
  • className is appended to the root element.

Source

The component lives in packages/shared/react/src/lib/components/action-panel and is documented for Claude Code by the react-components-action-panel skill.