Card Heading

The <smart-card-heading> component provides a small composable heading region for cards, with optional slots for avatar, title, description, meta, and actions. It can be used standalone or projected into the [cardHeader] slot of <smart-card> (with [hasHeader]="true"). It follows the Base + Standard + Wrapper pattern with an InjectionToken-based extension mechanism. The abstract CardHeadingBaseComponent defines the shared API — optional ICardHeadingOptions and cssClass (alias class). CardHeadingStandardComponent is a barebones placeholder concrete implementation. CardHeadingComponent is the public wrapper that renders CardHeadingStandardComponent by default and accepts a custom replacement via CARD_HEADING_STANDARD_COMPONENT_TOKEN.


Usage

<smart-card-heading [options]="options()" />
<p>Jobs created: {{ createdCount() }}</p>

<ng-template #actions>
  <smart-button [options]="createButton">Create new job</smart-button>
</ng-template>

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

CardHeadingComponent (<smart-card-heading>)

Main wrapper component. Renders CardHeadingStandardComponent by default. When CARD_HEADING_STANDARD_COMPONENT_TOKEN is provided, renders the injected component via NgComponentOutlet and passes it options and class.

CardHeadingStandardComponent (<smart-card-heading-standard>)

Barebones placeholder concrete implementation. Renders a wrapper <div> with an optional avatar slot, a content area containing <h3> (title) + <p class="description"> (description) + optional meta slot, and an optional actions slot. Each section is rendered only when its corresponding template/string is provided. The external cssClass is applied to the wrapper. It does not include Tailwind UI styling — it exists solely as the default structural placeholder until a custom implementation is registered through the token.

CardHeadingBaseComponent (abstract)

Abstract base directive for extending custom card-heading implementations. Exposes options as an InputSignal<ICardHeadingOptions | undefined> and cssClass as an InputSignal<string> (with alias class).

API

Inputs

InputTypeDefaultDescription
optionsInputSignal<ICardHeadingOptions | undefined>-Optional configuration (title, description, slot templates)
classInputSignal<string>''External CSS classes (alias for cssClass)

ICardHeadingOptions

FieldTypeDefaultDescription
titlestringundefinedThe heading text.
descriptionstringundefinedText under the title.
avatarTplTemplateRef<unknown>undefinedAn avatar or image.
actionsTplTemplateRef<unknown>undefinedButtons or a menu.
metaTplTemplateRef<unknown>undefinedMeta information (date, tags, read time); the preset wraps it in a <dl> (author, stacked).
presentation{ variant?: 'author' | 'stacked' | 'overlay' | 'outline' }undefinedPreset only: variant picks the look ('author' by default). The standard ignores it.

All properties are optional. The default CardHeadingStandardComponent renders every slot except presentation; a section is rendered only when its template/string is provided.

CARD_HEADING_STANDARD_COMPONENT_TOKEN

InjectionToken that allows replacing the default CardHeadingStandardComponent with a custom implementation. Provide a Type<CardHeadingBaseComponent> to override; the wrapper passes it options and class.

Extending the base class

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

import {
  CardHeadingBaseComponent,
  CardHeadingComponent,
  CARD_HEADING_STANDARD_COMPONENT_TOKEN,
  ICardHeadingOptions,
} from '@smartsoft001/angular';

/**
 * A custom card heading built on `CardHeadingBaseComponent`.
 *
 * The base contributes the `options` and `class` inputs; the implementation
 * owns the markup, including where the optional `TemplateRef` slots of
 * `ICardHeadingOptions` are projected.
 */
@Component({
  selector: 'docs-custom-card-heading',
  template: `
    <div [class]="containerClasses()">
      <div class="docs-card-heading__content">
        @if (options()?.title) {
          <h3 class="docs-card-heading__title">{{ options()!.title }}</h3>
        }
        @if (options()?.description) {
          <p class="docs-card-heading__description">
            {{ options()!.description }}
          </p>
        }
      </div>
      @if (options()?.actionsTpl) {
        <div class="docs-card-heading__actions">
          <ng-container [ngTemplateOutlet]="options()!.actionsTpl!" />
        </div>
      }
    </div>
  `,
  imports: [NgTemplateOutlet],
  encapsulation: ViewEncapsulation.None,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CustomCardHeadingComponent extends CardHeadingBaseComponent {
  // The consumer's `class` on <smart-card-heading> arrives as `cssClass`.
  containerClasses = computed(() =>
    ['docs-card-heading', this.cssClass()].filter(Boolean).join(' '),
  );
}

/**
 * Registering the implementation against `CARD_HEADING_STANDARD_COMPONENT_TOKEN`
 * makes every `<smart-card-heading>` in this injector render it instead of the
 * standard variation.
 */
@Component({
  selector: 'docs-card-heading-custom-example',
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [CardHeadingComponent],
  providers: [
    {
      provide: CARD_HEADING_STANDARD_COMPONENT_TOKEN,
      useValue: CustomCardHeadingComponent,
    },
  ],
  template: `
    <smart-card-heading
      [options]="options"
      [class]="'docs-card-heading--demo'"
    />
  `,
})
export class CardHeadingCustomExampleComponent {
  options: ICardHeadingOptions = {
    title: 'Applicant information',
    description: 'Personal details and application.',
  };
}

HyperUI preset

CardHeadingPresetComponent (<smart-card-heading-preset>) is a HyperUI-styled drop-in replacement for the standard component. It extends CardHeadingStandardComponent, is OnPush + ViewEncapsulation.None, and restyles the heading into one of four card looks selected by options.presentation.variant. All utilities are smart:-prefixed with explicit smart:dark:* variants. Content flows from the shared ICardHeadingOptions slots; the root element carries data-role="card" and per-variant zones expose data-role hooks (avatar, title, description, meta, actions, plus title-hover for the outline variant).

The extra classes (class on <smart-card-heading>, or class / [cssClass] on <smart-card-heading-preset>) are merged into the root card classes.

VariantLookSlots used
authorBordered, rounded card; avatar to the side, meta <dl> (default)title, description, avatarTpl, metaTpl, actionsTpl
stackedLarge top image, title + description stacked underneathtitle, description, avatarTpl, metaTpl, actionsTpl
overlayFull-bleed image on a black backdrop, content revealed on hovertitle, description, avatarTpl, metaTpl (eyebrow), actionsTpl
outlineDashed offset border, title flips to description/action on hovertitle, description, avatarTpl, actionsTpl

presentation.variant defaults to author (also the fallback for an unknown value).

Register the preset

Provide CardHeadingPresetComponent under CARD_HEADING_STANDARD_COMPONENT_TOKEN to restyle every <smart-card-heading>, or register every preset at once with provideSmartPresets().

Gaps (out of scope)

HyperUI card templates 5–9 are not implemented — they need domain fields absent from ICardHeadingOptions:

  • Property card — price, address, list of numeric specs (beds/baths/area).
  • Profile with social + project links — dedicated social-icon and project-link collections (dark profile card).
  • Shaped image — a decorative clip-path/image-shape treatment with no content-driven data channel.
  • Podcast post — episode number, duration, and audio/player metadata.
  • Forum post — author, reply count, tag list, and activity timestamps.

Adding any of these would require extending ICardHeadingOptions (e.g. structured stats, links, or badges collections) before a faithful preset variant can be built.

Source

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

SmartCardHeading renders the heading block of a card: a title and description, plus ReactNode slots for an avatar, meta information and actions, each rendered only when given. SmartCardHeadingStandard is unstyled and ignores options.presentation; SmartCardHeadingPreset renders one of four looks chosen by options.presentation.variant (author, the default, stacked, overlay, outline).


Usage

import { useState } from 'react';

import {
  ICardHeadingOptions,
  SmartButton,
  SmartCardHeading,
} from '@smartsoft001/react';

export function CardHeadingUsageExample() {
  const [createdCount, setCreatedCount] = useState(0);

  const options: ICardHeadingOptions = {
    title: 'Job postings',
    description: 'Open roles across all teams, sorted by posting date.',
    actionsTpl: (
      <SmartButton
        options={{ click: () => setCreatedCount((count) => count + 1) }}
      >
        Create new job
      </SmartButton>
    ),
  };

  return (
    <>
      <SmartCardHeading options={options} />
      <p>Jobs created: {createdCount}</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
SmartCardHeadingcomponentRenders the implementation registered as components['card-heading'] on SmartProvider, SmartCardHeadingStandard by default.
SmartCardHeadingPresetcomponentHyperUI-styled card heading variation (preset).
SmartCardHeadingStandardcomponentThe default card heading rendering: the avatar, the title, description and meta, and the actions of options, each only when given.

The preset's class helper getCardHeadingContainerClasses and its CardHeadingVariant type ('author' | 'stacked' | 'overlay' | 'outline') are exported too, for a custom implementation that wants the preset look.

Props and Types

SmartCardHeadingProps

PropTypeDefaultDescription
options?ICardHeadingOptions—The content slots and the presentation.
className?string—Classes on the root element.

ICardHeadingOptions

FieldTypeDefaultDescription
title?string—The heading text.
description?string—Text under the title.
avatarTpl?ReactNode—An avatar or image node.
actionsTpl?ReactNode—Buttons or a menu.
metaTpl?ReactNode—Meta information (date, tags, read time).
presentation?{ variant?: 'author' | 'stacked' | 'overlay' | 'outline'; }—variant picks the preset look ('author' by default); ignored by the standard rendering.

Replacing the Implementation

SmartCardHeading renders the component registered under the 'card-heading' key of SmartProvider's components, and SmartCardHeadingStandard when nothing is registered there. Every SmartCardHeading below the provider then renders the registered component, which receives the same props.

SmartCardHeadingPreset is the styled (preset) implementation: register it under the 'card-heading' key of SmartProvider's components, render it directly in place of SmartCardHeading, 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.

import {
  ICardHeadingOptions,
  SmartCardHeading,
  SmartCardHeadingProps,
  SmartProvider,
} from '@smartsoft001/react';

/**
 * A custom card heading built on `SmartCardHeadingProps`: the implementation
 * owns the markup, including where the optional slots of
 * `ICardHeadingOptions` are rendered.
 */
export function CustomCardHeading({
  options,
  className,
}: SmartCardHeadingProps) {
  return (
    <div className={['docs-card-heading', className].filter(Boolean).join(' ')}>
      <div className="docs-card-heading__content">
        {options?.title && (
          <h3 className="docs-card-heading__title">{options.title}</h3>
        )}
        {options?.description && (
          <p className="docs-card-heading__description">
            {options.description}
          </p>
        )}
      </div>
      {options?.actionsTpl && (
        <div className="docs-card-heading__actions">{options.actionsTpl}</div>
      )}
    </div>
  );
}

// Registered under 'card-heading', it renders every <SmartCardHeading> below
// the provider. A module constant: a new object on every render would change
// the context.
const components = { 'card-heading': CustomCardHeading };

const options: ICardHeadingOptions = {
  title: 'Applicant information',
  description: 'Personal details and application.',
};

export function CardHeadingCustomExample() {
  return (
    <SmartProvider components={components}>
      <SmartCardHeading options={options} className="docs-card-heading--demo" />
    </SmartProvider>
  );
}

Styling

  • SmartCardHeadingStandard is unstyled markup; SmartCardHeadingPreset carries the four presentations with smart:dark: variants (overlay places the text over the avatar image, so give that slot an image).
  • className is appended to the root element.

Source

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