Skip to content

Discussion for Angular

AngularData display

A threaded comments and forum control: a comment box and replies nested to any depth, @mentions in every composer (Mention Input, people supplied by the host or taken from the discussion), a configurable character count that blocks posting over the limit, delete with an inline confirmation (a deleted comment with replies stays as a placeholder), edit of own comments, and the author, avatar, and a relative timestamp on every comment and reply with the absolute date and time on hover and focus. Visual indentation stops at maxIndent while the nesting stays semantic; threads collapse and expand, replies can load lazily, and top-level comments sort oldest or newest first. The host owns persistence through cancelable events.

  • Replies at any depthReply to any comment, however deep. Indentation stops at maxIndent and deeper replies say who they answer, so threads stay readable on phones.
  • Mentions everywhereEvery comment and reply box is a Mention Input: @ suggests people from your directory or from the discussion itself.
  • Character count that blocksSet maxLength and every box shows a counter; posting over the limit is blocked and the error is announced.
  • Delete without breaking threadsAn inline confirmation, then a 'This comment was deleted' placeholder when replies exist, or removal when they do not.
  • Who and whenAuthor, avatar, and a relative time on every comment, with the absolute date in a <time> element, time-zone and holiday aware.
  • Big threads stay lightDeep threads start collapsed, top-level comments and replies page in with Show more, and replies can load lazily from your server.

Behavior, design tokens, and limitations are described on the Discussion page; this page covers the Angular API.

import { Component } from '@angular/core';
import { instant } from '@absoluteui/core';
import type { DiscussionComment, DiscussionPostDetail } from '@absoluteui/components/discussion';
import { AuiDiscussion } from '@absoluteui/angular/discussion';
@Component({
selector: 'app-comments',
imports: [AuiDiscussion],
template: `<aui-discussion label="Comments" [currentUser]="me" [comments]="comments" [maxLength]="500" (posted)="save($event)"></aui-discussion>`,
})
export class CommentsComponent {
readonly me = { id: 'u1', name: 'Ana' };
readonly comments: DiscussionComment[] = [
{ id: '1', parentId: null, author: { id: 'u2', name: 'Ben' }, text: 'Office closed on Friday.', createdAt: instant(Date.UTC(2026, 10, 20, 9)) },
];
save(detail: DiscussionPostDetail): void {
console.log(detail.comment.text);
}
}
Terminal window
npm install @absoluteui/angular @absoluteui/components @absoluteui/core @absoluteui/theme

Setup with provideAbsoluteUI() is covered in Getting started. Styles are included with the component.

import { AuiDiscussion } from '@absoluteui/angular/discussion';

Defaults for every instance: provideAbsoluteUIConfig({ components: { discussion: { ... } } }) (see Configuration).

Class AuiDiscussion; template reference #ref="auiDiscussion".

Server rendering: Renders on the server; the browser re-creates it after hydration.

Input Type Default Description
label string Required. Visible title and accessible name of the discussion.
comments readonly DiscussionComment[] '[]' Comments: { id, parentId, author: { id, name, avatar? }, text, mentions?, createdAt, editedAt?, deleted?, replyCount? }.
currentUser DiscussionAuthor | null null The signed-in user; null makes the discussion read-only (no composer, no reply).
maxLength number Maximum characters per comment (1..100000); longer text is blocked from posting, not truncated.
showCounter boolean 'true when maxLength is set' Show the character counter on every composer; requires maxLength.
triggers readonly MentionTrigger[] '@ suggesting the people in the discussion' Mention triggers and providers of every composer (Mention Input).
allowReplies boolean true Show Reply on comments.
canEdit (comment: DiscussionComment) => boolean) | nul 'own comments' Whether the current user may edit a comment (deleted comments never).
canDelete (comment: DiscussionComment) => boolean) | nul 'own comments' Whether the current user may delete a comment.
loadReplies (comment: DiscussionComment, context: DiscussionLoadContext) => Promise<readonly DiscussionComment[]>) | nul null Loads replies of a comment whose replyCount exceeds its loaded replies; context { signal, loaded }.
status DiscussionStatus 'ready' loading shows a spinner, error a message with Retry (aui-retry).
errorText string Message shown with status error.
emptyTitle string Empty state title.
emptyDescription string Empty state description.
placeholder string Placeholder of the new-comment box.
rows number '3' Rows of every composer (1..20).
businessCalendar BusinessCalendarEngine | null null Names holidays and non-working days in absolute dates.
now Instant Reference time of relative timestamps; default now, refreshed every minute.
icons Partial<DiscussionIcons> Icon slot overrides.
maxIndent number '4' Levels that indent (1..10); deeper replies show Replying to <name>.
collapseDepth number '3' Replies of comments at this depth or deeper start collapsed (1..50; top-level is depth 0).
pageSize number '20' Top-level comments shown at first and per Show more comments (1..500).
repliesPageSize number '5' Replies shown per thread at first and per Show more replies (1..200).
showAvatars boolean true Show avatars.
headingLevel number '3' Heading level of the title (2..6).
composerPosition "bottom" | "top" 'top' Where the new-comment box sits.
timezone string 'UTC' IANA timezone of timestamps.
locale string 'en-US' Locale of labels, numbers, and dates.
Model Type Change output Description
[(sort)] DiscussionSort (sortChange) Order of top-level comments (replies are always oldest first).
Output Payload Description
(posted) DiscussionPostDetail A top-level comment was posted: { comment }; prevent it to add nothing and keep the text. Re-emits aui-post.
(replied) DiscussionReplyDetail A reply was posted: { comment, parent }. Re-emits aui-reply.
(edited) DiscussionEditDetail An edit was saved: { id, text, mentions, previous }; prevent it to keep the previous text. Re-emits aui-edit.
(deleted) DiscussionDeleteDetail A delete was confirmed: { comment, placeholder } (placeholder: the comment has replies and stays as deleted). Re-emits aui-delete.
(expandToggled) DiscussionExpandDetail A thread was expanded or collapsed: { id, expanded }. Re-emits aui-expand.
(retried) {} Retry in the error state. Re-emits aui-retry.
(mentioned) MentionInputMentionDetail From the composers (Mention Input): a mention was inserted: { mention }. Re-emits aui-mention.

Call them through a viewChild query or a template reference.

Method Description
addComment(comment: DiscussionComment): void Add a comment or replace the one with the same id; comments by others are announced.
updateComment(id: string, patch: Partial<Omit<DiscussionComment, "id" | "parentId">>): void Merge fields into a comment.
removeComment(id: string): void Remove a comment (no event): a placeholder when it has replies, otherwise gone with deleted ancestors left without replies.
expand(id: string): void Show a thread’s replies (loading them when needed).
collapse(id: string): void Hide a thread’s replies.
reply(id: string): void Open and focus the reply box of a comment.
focusComment(id: string): void Reveal and focus a comment.
focus(): void Focus the new-comment box (or the first comment when read-only).

Pattern: A labelled region with nested lists of articles (one list per reply level, so the nesting is semantic at every depth); every action is a native button in the Tab order, the composers are labelled multi-line text fields with mention suggestions (Mention Input, combobox-style listbox), and thread toggles are disclosure buttons. The WAI-ARIA tree pattern was not used because comments contain interactive content (buttons, links, text fields), which tree items must not.

The Angular component renders the framework-neutral component, so its keyboard support, roles, WCAG 2.2 criteria, budgets, and import cost apply unchanged: see Discussion: Accessibility and performance.