ngx-prompt-kit

Message

A row in a chat thread. Pairs an avatar with content; supports plain text or markdown, plus a row of inline actions.

Examples

Basic conversation

A back-and-forth exchange. User messages align right, assistant messages align left with an avatar.

Could you summarize the latest commit log into release notes?
AI I can help with that — pull the commit range and I'll group them into features, fixes, and chores.

With markdown

Set [markdown]=true on the content to render headings, lists, code, and emphasis.

Give me the v0.1.0 changelog as markdown.
AI

v0.1.0

  • Refactored the auth middleware
  • Added session.refresh() helper
  • Fixed an off-by-one in pagination

Want me to group by author next time?

With actions

MessageActions and MessageAction add interactive controls below an assistant message — copy, regenerate, thumbs up/down.

Explain the difference between signal() and computed().
AI signal() holds writable state. computed() derives a read-only value from one or more signals; it re-evaluates lazily when its dependencies change.

Upgrading to v22.1

The major version tracks the Angular major it targets, so breaking component changes ship in minors. This one needs a template edit.

pk-message and pk-message-actions were removed in favour of Spartan's own message primitives, which provide the alignment context the surrounding slots rely on. Generate them with ng g @spartan-ng/cli:ui message, then swap the wrappers:

<!-- before -->
<pk-message class="justify-end">…</pk-message>
<pk-message-actions>…</pk-message-actions>

<!-- after -->
<div hlmMessage align="end">…</div>
<div hlmMessageFooter>…</div>

pk-message-content, pk-message-avatar and pk-message-action are unchanged — keep using them inside hlmMessage.

Installation

Add the message component (and the cn() utility) to your project.

ng generate ngx-prompt-kit:message

Component API

HlmMessage (spartan)

PropTypeDefaultDescription
align"start" | "end" "start" Row direction. Use "end" for user messages. Replaces PkMessage.

PkMessageAvatar

PropTypeDefaultDescription
srcstringAvatar image URL (required).
altstringAlt text for the image (required).
fallbackstringInitials shown if the image fails.
classstringExtra classes for the avatar.

PkMessageContent

PropTypeDefaultDescription
contentstringThe text content. Optional — you can also project markup via ng-content.
markdownboolean false Render content as markdown via pk-markdown.
classstringExtra classes for the bubble.

HlmMessageFooter (spartan)

PropTypeDefaultDescription
Action row; auto-aligns for align="end". Replaces PkMessageActions.

PkMessageAction

PropTypeDefaultDescription
tooltipstringTooltip label shown on hover (required).
side"top" | "bottom" | "left" | "right" "top" Tooltip placement.
classstringExtra classes applied to the tooltip content.