Feed

The <smart-feed> component renders a vertical timeline of activity events with optional title, description, per-event icon/avatar, link, timestamp, description, nested comments, an empty state, an optional comment-submit slot, and a bottom footer slot. It follows the Base + Standard + Wrapper pattern with an InjectionToken-based extension mechanism. The abstract FeedBaseComponent defines the shared API — optional IFeedOptions and cssClass (alias class). FeedStandardComponent is a barebones placeholder concrete implementation. FeedComponent is the public wrapper that renders FeedStandardComponent by default and accepts a custom replacement via FEED_STANDARD_COMPONENT_TOKEN.


Usage

<smart-feed [options]="options" />

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

FeedComponent (<smart-feed>)

Main wrapper component. Renders FeedStandardComponent by default. When FEED_STANDARD_COMPONENT_TOKEN is provided, renders the injected component via NgComponentOutlet.

FeedStandardComponent (<smart-feed-standard>)

Barebones placeholder concrete implementation. Renders a wrapper <div> containing an optional <h3 class="title">, optional <p class="description">, and a <ol role="list"> with one <li class="event"> per event. Each event renders the icon/avatar (icon template wins over avatar URL), an optional <time class="timestamp">, the title (rendered as <a class="title"> if href is provided, otherwise <span class="title">), an optional description, and a nested <ul class="comments"> with one <li class="comment"> per comment (avatar, author name, optional timestamp, content). When events list is empty, the optional emptyTpl is rendered inside <div class="empty">. An optional commentSubmitTpl renders inside <div class="comment-submit">. A bottom footerTpl renders inside <div class="footer">. The external cssClass is applied to the root wrapper. It does not include any visual styling — it exists solely as the default structural placeholder until a custom implementation is registered through the token.

FeedPresetComponent (<smart-feed-preset>)

Styled variation that extends FeedBaseComponent and is a drop-in replacement for FeedStandardComponent. Register it for FEED_STANDARD_COMPONENT_TOKEN to restyle every <smart-feed> (or every preset at once with provideSmartPresets()), or use the <smart-feed-preset> selector directly. It renders the Preline timeline look in vanilla Tailwind: a vertical rail (drawn with an after: pseudo-element, hidden on the last item) with a per-event circular marker, a left-hand side timestamp column, the event title (rendered as a link when href is set), an event description, and nested comments shown as Preline-style author rows. The marker chooses iconTpl first, then avatarUrl (image), then a default dot. Comments render the author avatar when authorAvatarUrl is set, otherwise an initials fallback derived from the first letter of authorName. The emptyTpl, commentSubmitTpl, and footerTpl slots are honored. All classes are smart:-prefixed Tailwind with explicit dark: variants; the class recipes are internal (not exported from @smartsoft001/angular).

The preset declares cssClass without the class alias, so bind [cssClass] when you use the <smart-feed-preset> selector directly; class on <smart-feed> reaches it through the wrapper.

FeedBaseComponent (abstract)

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

API

Inputs

InputTypeDefaultDescription
optionsInputSignal<IFeedOptions | undefined>-Header, events and slots
classInputSignal<string>''Classes on the root element (cssClass input, alias class)

IFeedOptions

FieldTypeDefaultDescription
titlestring-Heading above the feed.
descriptionstring-Text under the heading.
eventsIFeedEvent[][]The events, in the order shown.
emptyTplTemplateRef<unknown>-Rendered instead of the list when there are no events.
commentSubmitTplTemplateRef<unknown>-A slot below the feed, e.g. a comment form.
footerTplTemplateRef<unknown>-A slot at the end.
variantSmartFeedVariant-Not read by the built-in implementations; available to a custom implementation.

SmartFeedVariant is 'simple' | 'with-comments' | 'multiple-types'.

IFeedEvent

FieldTypeDefaultDescription
idstring-Track key of the event.
titlestringrequiredEvent title; a link when href is set.
descriptionstring-Event text.
timestampstring-Display text for the time (e.g. "2h ago").
iconTplTemplateRef<unknown>-Marker icon; wins over avatarUrl.
avatarUrlstring-Marker avatar.
hrefstring-Makes the title a link.
commentsIFeedComment[]-Comments listed under the event.
ariaLabelstring-Accessible name of the event.
typestring-Not read by the built-in implementations; available to a custom implementation.

IFeedComment

FieldTypeDefaultDescription
idstring-Track key of the comment.
authorNamestringrequiredAuthor shown with the comment (initials fallback in the preset).
authorAvatarUrlstring-Author avatar.
contentstringrequiredComment text.
timestampstring-Display text for the time.

Both the standard and the preset read every field except IFeedOptions.variant and IFeedEvent.type; a section is rendered only when its template/string is provided. Within an event, iconTpl takes precedence over avatarUrl when both are set.

FEED_STANDARD_COMPONENT_TOKEN

InjectionToken that allows replacing the default FeedStandardComponent with a custom implementation. Provide a Type<FeedBaseComponent> to override; the wrapper passes options and the class on.

Extending the base class

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

import {
  FEED_STANDARD_COMPONENT_TOKEN,
  FeedBaseComponent,
  FeedComponent,
  IFeedOptions,
} from '@smartsoft001/angular';

const COLLAPSED_COUNT = 2;

@Component({
  selector: 'docs-custom-feed',
  template: `
    <div [class]="containerClasses()">
      @if (options()?.title) {
        <h3 class="docs-feed__title">{{ options()?.title }}</h3>
      }

      <ol class="docs-feed__list">
        @for (event of visibleEvents(); track event.id ?? $index) {
          <li class="docs-feed__event">
            @if (event.timestamp) {
              <time class="docs-feed__time">{{ event.timestamp }}</time>
            }
            <span class="docs-feed__label">{{ event.title }}</span>
          </li>
        }
      </ol>

      @if (hasMore()) {
        <button
          type="button"
          class="docs-feed__more"
          (click)="expanded.set(true)"
        >
          Show all
        </button>
      }
    </div>
  `,
  encapsulation: ViewEncapsulation.None,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CustomFeedComponent extends FeedBaseComponent {
  // A custom implementation is free to add its own state on top of the
  // options the wrapper forwards.
  expanded = signal(false);

  private events = computed(() => this.options()?.events ?? []);

  visibleEvents = computed(() =>
    this.expanded() ? this.events() : this.events().slice(0, COLLAPSED_COUNT),
  );

  hasMore = computed(() => this.events().length > this.visibleEvents().length);

  containerClasses = computed(() => {
    const classes = ['docs-feed'];
    const extra = this.cssClass();
    if (extra) classes.push(extra);
    return classes.join(' ');
  });
}

@Component({
  selector: 'docs-feed-custom-example',
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [FeedComponent],
  // The token swaps the standard feed for the custom one everywhere below
  // this component, so consumers keep writing `<smart-feed>`.
  providers: [
    { provide: FEED_STANDARD_COMPONENT_TOKEN, useValue: CustomFeedComponent },
  ],
  template: `<smart-feed [options]="options" />`,
})
export class FeedCustomExampleComponent {
  options: IFeedOptions = {
    title: 'Application activity',
    events: [
      {
        id: 'applied',
        title: 'Applied to Front End Developer',
        timestamp: 'Sep 20',
      },
      {
        id: 'screening',
        title: 'Advanced to phone screening',
        timestamp: 'Sep 22',
      },
      {
        id: 'interview',
        title: 'Completed phone screening',
        timestamp: 'Sep 28',
      },
    ],
  };
}

Source

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

SmartFeed renders an activity feed: an ordered list of events, each with a marker (iconTpl, else avatarUrl), a timestamp, a title (a link when href is set), a description and nested comments. emptyTpl replaces the list when there are no events, and commentSubmitTpl / footerTpl add content below it. SmartFeedPreset draws the timeline rail.


Usage

import { IFeedOptions, SmartFeed } from '@smartsoft001/react';

const options: IFeedOptions = {
  title: 'Activity',
  events: [
    { title: 'Applied to Front End Developer', timestamp: 'Sep 20' },
    {
      title: 'Advanced to phone screening by Bethany Blake',
      timestamp: 'Sep 22',
      comments: [
        { authorName: 'Chelsea Hagon', content: 'Looks great, approved.' },
      ],
    },
    { title: 'Completed interview with Martha Gardner', timestamp: 'Sep 28' },
  ],
};

export function FeedUsageExample() {
  return <SmartFeed options={options} />;
}

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
SmartFeedcomponentRenders the implementation registered as components.feed on SmartProvider, SmartFeedStandard by default.
SmartFeedPresetcomponentStyled feed / timeline variation (preset).
SmartFeedStandardcomponentThe default feed rendering: an ordered list of events (icon template > avatar, timestamp, title as a link when href is set, description, nested comments), the emptyTpl when there are no events, then the commentSubmitTpl and footerTpl slots.

The preset's class helpers (FEED_ROOT, FEED_HEADING_WRAP, FEED_HEADING_TEXT, FEED_DESCRIPTION, FEED_ITEM, FEED_TIMESTAMP_SIDE, FEED_TIMESTAMP_TEXT, FEED_MARKER_RAIL, FEED_MARKER_INNER, FEED_DOT, FEED_AVATAR, FEED_BODY, FEED_EVENT_TITLE, FEED_EVENT_TITLE_LINK, FEED_EVENT_DESCRIPTION, FEED_COMMENT_BUTTON, FEED_COMMENT_AVATAR, FEED_COMMENT_INITIALS, FEED_COMMENT_CONTENT, FEED_COMMENT_TIME, FEED_EMPTY, FEED_COMMENT_SUBMIT, FEED_FOOTER) are exported too, for a custom implementation that wants the preset look.

Props and Types

SmartFeedProps

PropTypeDefaultDescription
options?IFeedOptions—Header, events and slots.
className?string—Classes on the root element.

IFeedOptions

FieldTypeDefaultDescription
title?string—Heading above the feed.
description?string—Text under the heading.
events?IFeedEvent[][]The events, in the order shown.
variant?SmartFeedVariant—Declared (simple, with-comments, multiple-types); the standard and preset renderings do not vary by it.
commentSubmitTpl?ReactNode—A slot below the feed, e.g. a comment form.
emptyTpl?ReactNode—Rendered instead of the list when there are no events.
footerTpl?ReactNode—A slot at the end.

IFeedEvent

FieldTypeDefaultDescription
id?string—Key of the event.
titlestringrequiredEvent title; a link when href is set.
description?string—Event text.
timestamp?string—Display text for the time (e.g. "2h ago").
iconTpl?ReactNode—Marker icon; wins over avatarUrl.
avatarUrl?string—Marker avatar.
href?string—Makes the title a link.
type?string—Declared for your own use; not read by the renderings.
comments?IFeedComment[]—Comments listed under the event.
ariaLabel?string—Accessible name of the event.

IFeedComment

FieldTypeDefaultDescription
id?string—Key of the comment.
authorNamestringrequiredAuthor shown with the comment (initials fallback in the preset).
authorAvatarUrl?string—Author avatar.
contentstringrequiredComment text.
timestamp?string—Display text for the time.
  • SmartFeedVariant: 'simple' \| 'with-comments' \| 'multiple-types'

Replacing the Implementation

SmartFeed renders the component registered under the 'feed' key of SmartProvider's components, and SmartFeedStandard when nothing is registered there. Every SmartFeed below the provider then renders the registered component, which receives the same props.

SmartFeedPreset is the styled (preset) implementation: register it under the 'feed' key of SmartProvider's components, render it directly in place of SmartFeed, 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 { useState } from 'react';

import {
  cn,
  IFeedOptions,
  SmartFeed,
  SmartFeedProps,
  SmartProvider,
} from '@smartsoft001/react';

const COLLAPSED_COUNT = 2;

export function CustomFeed({ options, className }: SmartFeedProps) {
  // A custom implementation is free to add its own state on top of the
  // options SmartFeed forwards.
  const [expanded, setExpanded] = useState(false);

  const events = options?.events ?? [];
  const visibleEvents = expanded ? events : events.slice(0, COLLAPSED_COUNT);

  return (
    <div className={cn('docs-feed', className)}>
      {options?.title && <h3 className="docs-feed__title">{options.title}</h3>}

      <ol className="docs-feed__list">
        {visibleEvents.map((event, index) => (
          <li key={event.id ?? index} className="docs-feed__event">
            {event.timestamp && (
              <time className="docs-feed__time">{event.timestamp}</time>
            )}
            <span className="docs-feed__label">{event.title}</span>
          </li>
        ))}
      </ol>

      {events.length > visibleEvents.length && (
        <button
          type="button"
          className="docs-feed__more"
          onClick={() => setExpanded(true)}
        >
          Show all
        </button>
      )}
    </div>
  );
}

// A module constant: a new object on every render would change the context.
const components = { feed: CustomFeed };

const options: IFeedOptions = {
  title: 'Application activity',
  events: [
    {
      id: 'applied',
      title: 'Applied to Front End Developer',
      timestamp: 'Sep 20',
    },
    {
      id: 'screening',
      title: 'Advanced to phone screening',
      timestamp: 'Sep 22',
    },
    {
      id: 'interview',
      title: 'Completed phone screening',
      timestamp: 'Sep 28',
    },
  ],
};

export function FeedCustomExample() {
  // Every SmartFeed below the provider renders CustomFeed.
  return (
    <SmartProvider components={components}>
      <SmartFeed options={options} />
    </SmartProvider>
  );
}

Styling

  • SmartFeedStandard is an unstyled ordered list with class hooks; SmartFeedPreset draws a vertical rail with markers (icon > avatar > dot), a timestamp column and author rows for comments, with smart:dark: variants.

Source

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