Discussion
Introduction
Section titled “Introduction”A threaded comments and forum control. People write a comment, reply to any comment at any depth, @mention each other in every box, edit their own comments, and delete them after an inline confirmation. Every comment and reply shows the author, an avatar, and a relative timestamp (“5 minutes ago”, “Yesterday”) with the absolute date and time on hover and focus. A configurable character count blocks posting over the limit. Indentation stops at maxIndent so deep threads stay readable on phones, 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.
Use it for
- Comments on a record (an announcement, a leave request, a document, a ticket).
- Forum or Q&A threads where people reply to replies.
- Review discussions where people mention each other.
Use something else for
- A linear conversation or an assistant: use Chat.
- An activity history without replies: use Timeline.
- A single free-text note: use Textarea or Mention Input.
Anatomy
<div class="aui-discussion" role="region" aria-labelledby="title"> <div class="aui-discussion__header"> <div class="aui-discussion__heading"><h3 class="aui-discussion__title" id="title">Comments</h3><span class="aui-discussion__count">8 comments</span></div> <div class="aui-discussion__sort">Toggle Group: Oldest | Newest</div> </div> <div class="aui-discussion__composer">Mention Input (counter, error) <div class="aui-discussion__composer-actions"><button>Comment</button></div></div> <div class="aui-discussion__status">Spinner | error text + Retry</div> (status loading / error) <div class="aui-discussion__empty">Empty State</div> (no comments) <ul class="aui-discussion__thread" role="list"> <li class="aui-discussion__item" data-depth="0"> <article class="aui-discussion__comment" tabindex="-1" aria-label="Comment by Grace Hopper, Yesterday"> <div class="aui-discussion__avatar">Avatar</div> <div class="aui-discussion__main"> <div class="aui-discussion__meta"> <span class="aui-discussion__author">Grace Hopper</span> <span class="aui-discussion__replying">Replying to Ada Lovelace</span> (depth >= maxIndent) <time class="aui-discussion__time" datetime="..." tabindex="0"><span>Yesterday</span><span class="aui-discussion__time-absolute">Friday, 20 November 2026 at 09:30</span></time> <span class="aui-discussion__edited">(edited)</span> </div> <p class="aui-discussion__text">Thanks <span class="aui-discussion__mention">@Ada Lovelace</span>, see <a>https://...</a></p> <div class="aui-discussion__actions" role="group" aria-label="Comment actions">Reply, Edit, Delete</div> </div> </article> <div class="aui-discussion__slot">reply box | edit box | delete confirmation</div> <button class="aui-discussion__toggle" aria-expanded="true" aria-controls="r1">Hide replies</button> <ul class="aui-discussion__replies" id="r1" role="list"> li ... <li class="aui-discussion__extra"><button>Show 7 more replies</button></li></ul> </li> </ul> <button class="aui-discussion__more">Show more comments (40)</button></div>Live example
Section titled “Live example”Use the bar above each frame to switch theme, density, direction, and locale.
Showcase: Discussion
Section titled “Showcase: Discussion”A fully featured live example. Change its options, use it with the keyboard, and watch the event log. The bar above the frame switches theme, density, direction, and locale.
Showcase source
// Discussion showcase: comments on a company announcement, answered by a simulated server.// A seeded thread six levels deep (deeper than the indentation cap), mentions with a people// directory, a deleted comment kept as a placeholder because it has replies, replies loaded lazily,// a character limit, and every post, reply, edit, and delete saved with a realistic delay. The// server can be told to reject the next save; the comment is then rolled back. Nothing leaves the page.import { instant, plainDate } from '@absoluteui/core';import { createBusinessCalendar } from '@absoluteui/components/business-calendar';import { Discussion, type DiscussionComment, type DiscussionDeleteDetail, type DiscussionEditDetail, type DiscussionPostDetail, type DiscussionReplyDetail,} from '@absoluteui/components/discussion';import type { MentionSuggestion } from '@absoluteui/components/mention-input';import { action, choice, createShowcase, hostIn, toggle, wait } from './kit.js';
const sc = createShowcase({ title: 'Discussion', description: 'Comments on a company announcement. Reply at any depth, type @ to mention someone, edit or delete your own comments (Ada Lovelace), and watch the character counter. Saves go to a simulated server.', simulated: true,});
const people = { ada: { id: 'ada', name: 'Ada Lovelace' }, grace: { id: 'grace', name: 'Grace Hopper' }, alan: { id: 'alan', name: 'Alan Turing' }, kat: { id: 'kat', name: 'Katherine Johnson' }, linus: { id: 'linus', name: 'Linus Pauling' }, rosalind: { id: 'rosalind', name: 'Rosalind Franklin' },};const DIRECTORY: readonly MentionSuggestion[] = Object.values(people).map((p) => ({ id: p.id, label: p.name, description: p.id === 'ada' ? 'You' : 'People team' }));
const now = Date.now();const ago = (minutes: number): ReturnType<typeof instant> => instant(now - minutes * 60_000);const mention = (text: string, person: { id: string; name: string }) => { const start = text.indexOf(`@${person.name}`); return { id: person.id, label: person.name, trigger: '@', start, end: start + person.name.length + 1 };};
const t2 = 'Thanks @Grace Hopper. Does the new desk booking apply to part-time staff?';const seeded: DiscussionComment[] = [ { id: 'c1', parentId: null, author: people.grace, text: 'The office moves to the new building on 4 January. Desk booking opens next week: https://example.com/desks', createdAt: ago(60 * 30) }, { id: 'c2', parentId: 'c1', author: people.ada, text: t2, mentions: [mention(t2, people.grace)], createdAt: ago(60 * 29) }, { id: 'c3', parentId: 'c2', author: people.grace, text: 'Yes, booking works per day.', createdAt: ago(60 * 28) }, { id: 'c4', parentId: 'c3', author: people.alan, text: 'Can we book a whole week at once?', createdAt: ago(60 * 5), editedAt: ago(60 * 4) }, { id: 'c5', parentId: 'c4', author: people.grace, text: 'Not yet, it is on the roadmap.', createdAt: ago(90) }, { id: 'c6', parentId: 'c5', author: people.ada, text: 'A recurring booking would help the finance team too.', createdAt: ago(45) }, { id: 'c7', parentId: 'c6', author: people.kat, text: 'Agreed. Every Tuesday and Thursday for us.', createdAt: ago(20) }, { id: 'c8', parentId: null, author: people.linus, text: '', deleted: true, createdAt: ago(60 * 26) }, { id: 'c9', parentId: 'c8', author: people.rosalind, text: 'The comment above was removed, but this answer keeps its place in the thread.', createdAt: ago(60 * 25) }, { id: 'c10', parentId: null, author: people.kat, text: 'Is there parking at the new building?', createdAt: ago(60 * 3), replyCount: 3 }, { id: 'c11', parentId: null, author: people.ada, text: 'I will collect questions for the Friday Q&A. Reply here.', createdAt: ago(8) },];
/** The simulated server: the comments it has stored. */const server = new Map(seeded.map((c) => [c.id, c]));let failNext = false;const LAZY: readonly DiscussionComment[] = [ { id: 'p1', parentId: 'c10', author: people.grace, text: 'Yes, 40 spaces on level -1.', createdAt: ago(150) }, { id: 'p2', parentId: 'c10', author: people.alan, text: 'Are there chargers for electric cars?', createdAt: ago(120) }, { id: 'p3', parentId: 'c10', author: people.grace, text: 'Six chargers, bookable like desks.', createdAt: ago(100) },];
async function save(kind: string): Promise<void> { await wait(500 + Math.random() * 400); if (failNext) { failNext = false; throw new Error(`${kind} rejected`); }}
const host = hostIn(sc.stage);const discussion = Discussion.create(host, { label: 'Comments on: Office move', currentUser: people.ada, comments: seeded, maxLength: 280, // The seeded thread is six levels deep: show all of it (deeper threads still collapse). collapseDepth: 10, timezone: 'Europe/London', businessCalendar: createBusinessCalendar({ holidays: [{ date: plainDate(2026, 12, 25), name: 'Christmas Day', yearly: true }, { date: plainDate(2027, 1, 1), name: "New Year's Day", yearly: true }] }), triggers: [{ char: '@', label: '@ for people', provider: async (query, { signal }) => { await wait(150, signal); const q = query.toLowerCase(); return DIRECTORY.filter((p) => p.label.toLowerCase().includes(q)); }, }], loadReplies: async (comment, { signal }) => { sc.log('server', `GET /comments/${comment.id}/replies`); await wait(700, signal); return LAZY.filter((c) => c.parentId === comment.id); },});sc.listen(host, ['aui-post', 'aui-reply', 'aui-edit', 'aui-delete', 'aui-expand', 'aui-sort', 'aui-mention'], 'discussion');
// Optimistic saves: the component shows the change at once; a rejected save rolls it back.const persist = (kind: string, apply: () => void, rollback: () => void): void => { apply(); save(kind).then( () => { sc.log('server', `${kind} saved`); }, (error: unknown) => { rollback(); sc.log('server', error instanceof Error ? error.message : String(error)); }, );};host.addEventListener('aui-post', (e) => { const { comment } = (e as CustomEvent<DiscussionPostDetail>).detail; persist('POST comment', () => server.set(comment.id, comment), () => { server.delete(comment.id); discussion.removeComment(comment.id); });});host.addEventListener('aui-reply', (e) => { const { comment } = (e as CustomEvent<DiscussionReplyDetail>).detail; persist('POST reply', () => server.set(comment.id, comment), () => { server.delete(comment.id); discussion.removeComment(comment.id); });});host.addEventListener('aui-edit', (e) => { const { id, text, mentions, previous } = (e as CustomEvent<DiscussionEditDetail>).detail; persist('PATCH comment', () => server.set(id, { ...previous, text, mentions }), () => { server.set(id, previous); discussion.updateComment(id, { text: previous.text, mentions: previous.mentions ?? [], editedAt: previous.editedAt ?? null }); });});host.addEventListener('aui-delete', (e) => { const { comment } = (e as CustomEvent<DiscussionDeleteDetail>).detail; const snapshot = discussion.comments; persist('DELETE comment', () => server.delete(comment.id), () => { server.set(comment.id, comment); discussion.update({ comments: snapshot }); });});
// Option bar: every control changes the discussion live.choice(sc, 'Character limit', [{ value: '280', label: '280' }, { value: '80', label: '80' }, { value: '1000', label: '1000' }], '280', (v) => { discussion.update({ maxLength: Number(v) });});choice(sc, 'Indentation levels', [{ value: '4', label: '4' }, { value: '2', label: '2' }, { value: '6', label: '6' }], '4', (v) => { discussion.update({ maxIndent: Number(v) });});choice(sc, 'Composer', [{ value: 'top', label: 'Top' }, { value: 'bottom', label: 'Bottom' }], 'top', (v) => { discussion.update({ composerPosition: v });});toggle(sc, 'Avatars', true, (on) => { discussion.update({ showAvatars: on });});toggle(sc, 'Signed in', true, (on) => { discussion.update({ currentUser: on ? people.ada : null });});toggle(sc, 'Reject next save', false, (on) => { failNext = on; sc.log('server', on ? 'the next save will be rejected' : 'saves succeed');});action(sc, 'New comment from Grace', () => { const text = 'Reminder: the Q&A is on Friday at 15:00.'; discussion.addComment({ id: `g${String(Date.now())}`, parentId: 'c11', author: people.grace, text, createdAt: instant(Date.now()) }); sc.log('server', 'push: new reply from Grace Hopper');});action(sc, 'Reload', () => { discussion.update({ status: 'loading' }); void wait(800).then(() => { discussion.update({ status: 'ready', comments: [...server.values()] }); sc.log('server', `GET /comments (${String(server.size)})`); });});Comments with replies, mentions, and a character limit
Section titled “Comments with replies, mentions, and a character limit”import { instant } from '@absoluteui/core';import { Discussion, type DiscussionPostDetail, type DiscussionReplyDetail, type DiscussionDeleteDetail } from '@absoluteui/components/discussion';
const ada = { id: 'ada', name: 'Ada Lovelace' };const grace = { id: 'grace', name: 'Grace Hopper' };const host = document.createElement('div');document.body.append(host);Discussion.create(host, { label: 'Comments', currentUser: ada, maxLength: 500, comments: [ { id: '1', parentId: null, author: grace, text: 'The new leave policy starts in January.', createdAt: instant(Date.UTC(2026, 10, 20, 9, 30)) }, { id: '2', parentId: '1', author: ada, text: 'Thanks @Grace Hopper!', mentions: [{ id: 'grace', label: 'Grace Hopper', trigger: '@', start: 7, end: 20 }], createdAt: instant(Date.UTC(2026, 10, 20, 10)) }, ],});
// The host persists; the component has already added the comment optimistically.host.addEventListener('aui-post', (event) => { const { comment } = (event as CustomEvent<DiscussionPostDetail>).detail; void fetch('/api/comments', { method: 'POST', body: JSON.stringify(comment) });});host.addEventListener('aui-reply', (event) => { const { comment } = (event as CustomEvent<DiscussionReplyDetail>).detail; void fetch('/api/comments', { method: 'POST', body: JSON.stringify(comment) });});host.addEventListener('aui-delete', (event) => { const { comment } = (event as CustomEvent<DiscussionDeleteDetail>).detail; void fetch(`/api/comments/${encodeURIComponent(comment.id)}`, { method: 'DELETE' });});Wait for the server before showing a comment
Section titled “Wait for the server before showing a comment”import { instant } from '@absoluteui/core';import { Discussion, type DiscussionPostDetail, type DiscussionComment } from '@absoluteui/components/discussion';
const host = document.createElement('div');document.body.append(host);const discussion = Discussion.create(host, { label: 'Ticket discussion', currentUser: { id: 'u1', name: 'Ana' } });
host.addEventListener('aui-post', (event) => { const { comment } = (event as CustomEvent<DiscussionPostDetail>).detail; // Prevented: nothing is added and the text stays in the box until the server answers. event.preventDefault(); void fetch('/api/comments', { method: 'POST', body: JSON.stringify({ text: comment.text, mentions: comment.mentions }) }) .then((response) => response.json() as Promise<{ id: string; createdAt: number }>) .then((saved) => { const stored: DiscussionComment = { ...comment, id: saved.id, createdAt: instant(saved.createdAt) }; discussion.addComment(stored); discussion.composer?.reset(); });});Load replies when a thread is expanded
Section titled “Load replies when a thread is expanded”import { instant } from '@absoluteui/core';import { Discussion, type DiscussionComment } from '@absoluteui/components/discussion';
const host = document.createElement('div');document.body.append(host);Discussion.create(host, { label: 'Forum thread', currentUser: { id: 'u1', name: 'Ana' }, comments: [{ id: 't1', parentId: null, author: { id: 'u2', name: 'Ben' }, text: 'How do I export payslips?', createdAt: instant(Date.UTC(2026, 10, 18, 8)), replyCount: 42 }], loadReplies: async (comment, { signal, loaded }) => { const response = await fetch(`/api/comments/${encodeURIComponent(comment.id)}/replies?offset=${String(loaded)}&limit=20`, { signal }); const rows = (await response.json()) as { id: string; author: { id: string; name: string }; text: string; createdAt: number }[]; return rows.map((r): DiscussionComment => ({ id: r.id, parentId: comment.id, author: r.author, text: r.text, createdAt: instant(r.createdAt) })); },});People from the directory and holiday-aware dates
Section titled “People from the directory and holiday-aware dates”import { plainDate } from '@absoluteui/core';import { createBusinessCalendar } from '@absoluteui/components/business-calendar';import { Discussion } from '@absoluteui/components/discussion';
const host = document.createElement('div');document.body.append(host);Discussion.create(host, { label: 'Leave request discussion', currentUser: { id: 'u1', name: 'Ana' }, timezone: 'Europe/Berlin', businessCalendar: createBusinessCalendar({ holidays: [{ date: plainDate(2026, 12, 25), name: 'Christmas Day', yearly: true }] }), triggers: [{ char: '@', label: '@ for people', provider: async (query, { signal }) => { const response = await fetch(`/api/people?q=${encodeURIComponent(query)}`, { signal }); return (await response.json()) as { id: string; label: string }[]; }, }],});Newest first and deeper indentation everywhere
Section titled “Newest first and deeper indentation everywhere”import { configureAbsoluteUI } from '@absoluteui/core';
configureAbsoluteUI({ components: { discussion: { sort: 'newest', maxIndent: 5, collapseDepth: 4 } } });Install and start
Section titled “Install and start”npm install @absoluteui/components @absoluteui/core @absoluteui/themeRegistry setup, the theme stylesheet, and the Content Security Policy are covered in Installation.
import { Discussion } from '@absoluteui/components/discussion';import '@absoluteui/components/button/style.css';import '@absoluteui/components/avatar/style.css';import '@absoluteui/components/mention-input/style.css';import '@absoluteui/components/toggle-group/style.css';import '@absoluteui/components/empty-state/style.css';import '@absoluteui/components/spinner/style.css';import '@absoluteui/components/discussion/style.css';First use
Section titled “First use”import { Discussion } from '@absoluteui/components/discussion';import '@absoluteui/components/button/style.css';import '@absoluteui/components/avatar/style.css';import '@absoluteui/components/mention-input/style.css';import '@absoluteui/components/toggle-group/style.css';import '@absoluteui/components/empty-state/style.css';import '@absoluteui/components/spinner/style.css';import '@absoluteui/components/discussion/style.css';
const host = document.querySelector<HTMLElement>('#comments');if (host) Discussion.create(host, { label: 'Comments', currentUser: { id: 'u1', name: 'Ana' }, maxLength: 280 });More usage
import { instant } from '@absoluteui/core';import { Discussion, type DiscussionPostDetail } from '@absoluteui/components/discussion';
const host = document.querySelector<HTMLElement>('#comments');if (host) { Discussion.create(host, { label: 'Comments', currentUser: { id: 'u1', name: 'Ana' }, maxLength: 500, comments: [{ id: '1', parentId: null, author: { id: 'u2', name: 'Ben' }, text: 'Office closed on Friday.', createdAt: instant(Date.now() - 3_600_000) }], }); host.addEventListener('aui-post', (event) => { const { comment } = (event as CustomEvent<DiscussionPostDetail>).detail; void fetch('/api/comments', { method: 'POST', body: JSON.stringify(comment) }); });}Using Angular? See Discussion for Angular.
API reference
Section titled “API reference”Factory
Section titled “Factory”Discussion.create(host: HTMLElement, options: DiscussionOptions): DiscussionGlobal configuration key: discussion (see Configuration).
Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
label |
string |
Visible title and accessible name of the discussion. Required. | |
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) | null |
"own comments" |
Whether the current user may edit a comment (deleted comments never). |
canDelete |
((comment: DiscussionComment) => boolean) | null |
"own comments" |
Whether the current user may delete a comment. |
loadReplies |
((comment: DiscussionComment, context: DiscussionLoadContext) => Promise<readonly DiscussionComment[]>) | null |
"null" |
Loads replies of a comment whose replyCount exceeds its loaded replies; context { signal, loaded }. |
status |
'ready' | 'loading' | 'error' |
"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. | |
sort |
'oldest' | 'newest' |
"oldest" |
Order of top-level comments (replies are always oldest first). Globally configurable. |
maxIndent |
number |
4 |
Levels that indent (1..10); deeper replies show Replying to <name>. Globally configurable. |
collapseDepth |
number |
3 |
Replies of comments at this depth or deeper start collapsed (1..50; top-level is depth 0). Globally configurable. |
pageSize |
number |
20 |
Top-level comments shown at first and per Show more comments (1..500). Globally configurable. |
repliesPageSize |
number |
5 |
Replies shown per thread at first and per Show more replies (1..200). Globally configurable. |
showAvatars |
boolean |
true |
Show avatars. Globally configurable. |
headingLevel |
number |
3 |
Heading level of the title (2..6). Globally configurable. |
composerPosition |
'top' | 'bottom' |
"top" |
Where the new-comment box sits. Globally configurable. |
timezone |
string |
"UTC" |
IANA timezone of timestamps. Globally configurable. Inherited from common configuration. |
locale |
string |
"en-US" |
Locale of labels, numbers, and dates. Globally configurable. Inherited from common configuration. |
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
host |
HTMLElement |
The host element. |
comments |
readonly DiscussionComment[] |
Every comment in the model (frozen copies), including deleted placeholders. |
composer |
MentionInput | null |
The new-comment box, or null without a current user. |
options |
Readonly<DiscussionOptions> |
Current options. |
Methods
Section titled “Methods”| 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). |
update(options: Partial<DiscussionOptions>): void |
Merge and apply options. |
destroy(): void |
Abort loads; remove rendering, listeners, timers, and subscriptions. |
Events
Section titled “Events”| Event | Detail | Bubbles | Cancelable | Description |
|---|---|---|---|---|
aui-post |
DiscussionPostDetail |
Yes | Yes | A top-level comment was posted: { comment }; prevent it to add nothing and keep the text. |
aui-reply |
DiscussionReplyDetail |
Yes | Yes | A reply was posted: { comment, parent }. |
aui-edit |
DiscussionEditDetail |
Yes | Yes | An edit was saved: { id, text, mentions, previous }; prevent it to keep the previous text. |
aui-delete |
DiscussionDeleteDetail |
Yes | Yes | A delete was confirmed: { comment, placeholder } (placeholder: the comment has replies and stays as deleted). |
aui-expand |
DiscussionExpandDetail |
Yes | No | A thread was expanded or collapsed: { id, expanded }. |
aui-sort |
DiscussionSortDetail |
Yes | No | The user changed the sort order: { sort }. |
aui-retry |
{} |
Yes | No | Retry in the error state. |
aui-mention |
MentionInputMentionDetail |
Yes | No | From the composers (Mention Input): a mention was inserted: { mention }. |
Content areas
Section titled “Content areas”| Area | Description |
|---|---|
comments[].text |
Plain text (never HTML); mentions render as chips and http(s) URLs as links. |
CSS classes
Section titled “CSS classes”All rules live in the aui.components cascade layer, so application styles override them without specificity battles.
| Class | Purpose |
|---|---|
aui-discussion |
Host (role=region, flex column). |
aui-discussion--no-avatars | --composer-bottom |
State modifiers on the host. |
aui-discussion__header | __heading | __title | __count | __sort |
Title, comment count, and sort toggle group. |
aui-discussion__composer | __field | __composer-actions | __post |
New-comment box and its button. |
aui-discussion__status | __status--error | __status-text | __retry | __empty | __more |
Loading and error states, empty state, Show more comments. |
aui-discussion__thread | __replies | __replies--flat | __item | __item--deep |
Nested lists of comments; –flat stops the indentation. |
aui-discussion__comment | __comment--deleted | __comment--own | __avatar | __avatar--deleted | __main |
A comment (article). |
aui-discussion__meta | __author | __replying | __time | __time-relative | __time-absolute | __time--dismissed | __edited |
Author, replying-to, timestamp with its tooltip, edited marker. |
aui-discussion__text | __text--deleted | __mention | __link |
Comment text, mention chips, links. |
aui-discussion__actions | __action | __action--reply | --edit | --delete |
Comment actions. |
aui-discussion__slot | __inline | __inline--reply | --edit | __cancel | __submit | __confirm | __confirm-text | __confirm-delete | __confirm-cancel |
Reply and edit boxes and the delete confirmation. |
aui-discussion__toggle | __extra | __extra-error | __more-replies |
Show or hide replies, more replies, loading and error rows. |
Icon slots
Section titled “Icon slots”| Slot | Default icon |
|---|---|
reply |
reply (icon set) |
edit |
edit (icon set) |
delete |
trash |
expand |
chevron-down |
collapse |
chevron-up |
empty |
message (icon set) |
Design tokens
Section titled “Design tokens”Tokens this stylesheet reads (verified in CI). Override them in a theme or with the Theme Designer.
--aui-border-width | --aui-color-border | --aui-color-border-strong | --aui-color-error-fg | --aui-color-focus-ring | --aui-color-link | --aui-color-selected | --aui-color-selected-text | --aui-color-surface | --aui-color-surface-sunken | --aui-color-text | --aui-color-text-muted | --aui-focus-ring-offset | --aui-focus-ring-width | --aui-font-family-sans | --aui-font-size-md | --aui-font-size-sm | --aui-font-weight-medium | --aui-font-weight-semibold | --aui-line-height-normal | --aui-line-height-tight | --aui-radius-md | --aui-radius-pill | --aui-radius-sm | --aui-shadow-md | --aui-space-1 | --aui-space-2 | --aui-space-3 | --aui-space-5
TypeScript definitions
interface DiscussionAuthor { id: string; name: string; avatar?: string | null }interface DiscussionComment { id: string; parentId: string | null; author: DiscussionAuthor; text: string; mentions?: readonly MentionToken[]; createdAt: Instant; editedAt?: Instant | null; deleted?: boolean; replyCount?: number;}interface DiscussionLoadContext { readonly signal: AbortSignal; readonly loaded: number }interface DiscussionPostDetail { comment: DiscussionComment }interface DiscussionReplyDetail { comment: DiscussionComment; parent: DiscussionComment }interface DiscussionEditDetail { id: string; text: string; mentions: readonly MentionToken[]; previous: DiscussionComment }interface DiscussionDeleteDetail { comment: DiscussionComment; placeholder: boolean }interface DiscussionExpandDetail { id: string; expanded: boolean }interface DiscussionSortDetail { sort: 'oldest' | 'newest' }Accessibility and performance
Section titled “Accessibility and performance”Accessibility
Section titled “Accessibility”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.
Checked on every docs build: the showcase passes axe (WCAG 2.2 A and AA rules) in the default, dark, and high-contrast themes and right to left; the playground loads without errors and passes axe before and after every on/off option is switched, with no Content Security Policy violations.
Keyboard
Section titled “Keyboard”| Key | Context | Action |
|---|---|---|
| Tab / Shift+Tab | Discussion | Sort, the new-comment box and its button, then per comment: timestamp (shows the absolute date and time), links, Reply, Edit, Delete, Show or Hide replies, Show more. |
| Page Down / Page Up | Focus on a comment or one of its controls (not in a text field) | Move focus to the next or previous visible comment. |
| Ctrl+Enter / Cmd+Enter | Any composer | Post the comment, reply, or edit. |
| Escape | Reply or edit box (suggestions closed) | Cancel; focus returns to Reply or Edit. |
| Escape | Delete confirmation | Cancel; focus returns to Delete. |
| Escape | Focused timestamp | Hide its tooltip. |
| Arrow Up / Arrow Down, Enter or Tab, Escape | Mention suggestions open | Move, insert, close (Mention Input). |
| Enter / Space | Buttons | Activate. |
| Element | Role |
|---|---|
| host | region, named by the visible title |
| thread / replies | list (role=list keeps list semantics with list-style none), nested per reply level |
| comment | article, named ‘Comment by <name>, <time>’, ‘Reply by <name> to <parent>, <time>’, or ‘Deleted comment, <time>’ |
| actions | group (‘Comment actions’) of native buttons |
| sort | Toggle Group (group of toggle buttons with aria-pressed) |
| thread toggle | button with aria-expanded and aria-controls (the replies list) |
| delete confirmation | group named by its question (‘Delete this comment?’) |
| error state | alert |
| replies loading row | status |
ARIA attributes
Section titled “ARIA attributes”| Attribute | Element | Value |
|---|---|---|
aria-labelledby |
host and thread | the title |
aria-label |
comment article | author, parent author for replies, and relative time |
aria-expanded / aria-controls |
Show replies / Hide replies | the replies list |
aria-label |
Reply, Edit, Delete | ‘Reply to <name>’, ‘Edit comment by <name>’, ‘Delete comment by <name>’ |
aria-invalid / aria-describedby |
composer | set by Mention Input: error message and character counter |
Posting a reply or saving an edit focuses that comment; posting a top-level comment keeps focus in the cleared box. Deleting focuses the placeholder when one stays, else the next sibling, the comment before, or the parent. Cancel returns focus to the action that opened the panel; the delete confirmation focuses Cancel (the least destructive choice). Expanding a thread or showing more focuses the first newly shown comment.
WCAG 2.2 success criteria addressed
Section titled “WCAG 2.2 success criteria addressed”Automated test results: Accessibility and compliance.
Notes and known caveats
Section titled “Notes and known caveats”- Polite announcements: ‘Comment posted’, ‘Reply posted’, ‘Comment updated’, ‘Comment deleted’, and new comments added by others through addComment (‘New reply from Grace Hopper to Ada Lovelace’).
- Posting an empty or over-limit comment shows the error under the box and announces it assertively; the counter announces itself near the limit (Mention Input).
- The absolute date and time is a tooltip on hover and keyboard focus of the timestamp, dismissible with Escape and hoverable (WCAG 1.4.13); the text is also read with the timestamp.
- Indentation stops at maxIndent; the ‘Replying to <name>’ text and the article name keep the relationship available.
- Each timestamp is a tab stop (to reach the absolute date by keyboard).
- Manual screen-reader verification (NVDA, JAWS, VoiceOver) is pending.
Performance
Section titled “Performance”| Import cost | Minified | gzip | brotli | CSS brotli |
|---|---|---|---|---|
@absoluteui/components/discussion |
119.2 kB | 37.2 kB | 33.1 kB | 1.2 kB |
Measured at build time, including every AbsoluteUI module the component pulls in. No third-party runtime dependencies.
| Budget (enforced in CI) | Limit |
|---|---|
| Discussion.create with 1,000 comments (20 top-level rendered) | < 80 ms in headless Chromium |
| Posting a reply in a 1,000-comment discussion | < 16 ms (only changed comments are rebuilt) |
Tested scale: 50,000 comments in the model; the DOM holds the shown page of top-level comments (pageSize, default 20), the first repliesPageSize replies per expanded thread (default 5), and nothing below collapseDepth until expanded.
Only comments whose content changed are rebuilt; relative times refresh in place every minute. Collapsed threads and comments beyond the shown pages are not in the DOM. Reply counts and visibility are cached per model change.
Measured run times: Performance.
Details
Section titled “Details”States
Empty; loading; error with Retry; comments; thread collapsed or expanded; replies loading; replies failed with Retry; more replies or comments behind Show more; replying; editing; confirming delete; deleted placeholder; composer invalid (empty or over the limit); read-only.
State transitions
| From | Trigger | To |
|---|---|---|
| composer | Comment / Ctrl+Enter, valid | aui-post; the comment is added, the box cleared, unless prevented |
| composer | empty or over the limit | error shown and announced; nothing is posted |
| comment | Reply | reply box under it (focused) |
| reply box | Reply / Ctrl+Enter | aui-reply; reply added and focused |
| reply box | Cancel / Escape | closed; the text stays as a draft; focus on Reply |
| own comment | Edit, then Save | aui-edit; text replaced, “(edited)” shown |
| own comment | Delete, then Delete | aui-delete; placeholder (with replies) or removed |
| thread | Show / Hide replies | expanded (lazy load if needed) / collapsed; aui-expand |
Accessibility notes
- Polite announcements: “Comment posted”, “Reply posted”, “Comment updated”, “Comment deleted”, and comments from others added with
addComment. - Empty or over-limit posts show the error under the box and announce it assertively; the counter announces itself near the limit.
- The absolute date is a tooltip on hover and keyboard focus of the timestamp, dismissible with Escape (WCAG 1.4.13).
- Focus: a new reply or saved edit is focused; a top-level post keeps focus in the cleared box; a delete focuses the placeholder, or the next sibling, the comment before, or the parent; Cancel returns focus to the action that opened it; the delete confirmation focuses Cancel.
- The e2e axe run covers three themes and right-to-left; manual screen-reader verification is pending.
Responsive behavior
Fluid width. Each level indents by --aui-discussion-indent (half below 30rem) until maxIndent; deeper replies stop indenting and show “Replying to <name>”. Header and actions wrap.
Right-to-left
Logical properties throughout: indentation, the guide line, and the timestamp tooltip mirror; the reply icon mirrors.
Theming
Mention chips use component tokens in the contrast gate; text, links, and errors use global tokens. Forced colors outline mention chips and keep the guide line visible.
Global configuration
configureAbsoluteUI({ components: { discussion: { sort: 'newest', maxIndent: 5, collapseDepth: 4, pageSize: 30 } } });Component configuration
Instance options override configuration; configuration changes re-render existing discussions.
Timezones
Comments carry Instant timestamps shown in timezone (common config by default), never the machine’s zone. Relative text: “just now” (under 45 seconds), minutes, hours (today), “Yesterday”, a weekday within a week, then a date. The absolute text uses the full date and short time; with a business calendar it reads “Friday, 25 December 2026 at 10:00 (Christmas Day)” or “(non-working day)”.
Icons
reply (icon set reply), edit (icon set edit), delete (trash), expand (chevron-down), collapse (chevron-up), empty (icon set message). Composer icons are Mention Input’s.
Security
Comment text is untrusted: it is rendered as text nodes, mentions as text chips, and only http(s) and scheme-less URLs (isSafeHref) become links (rel="noopener noreferrer nofollow", new tab); other URLs stay text. Avatar images follow the Avatar URL policy. canEdit and canDelete only hide actions: the server must enforce who may edit or delete.
Data handling
No persistence, network access, or telemetry. The host stores comments through the events and methods. loadReplies runs only when a thread is expanded or “Show more replies” is chosen, and is aborted on collapse and destroy.
Supported data scale
50,000 comments in the model. The DOM holds the shown top-level page (20 by default), the first 5 replies of each expanded thread, and nothing below collapseDepth until expanded.
Edge cases
- A deleted comment without visible replies is not shown; when its last reply is removed, it disappears too.
- A thread whose replies are all still on the server (
replyCountwithout loaded replies) starts collapsed; expanding loads them. A load that adds nothing correctsreplyCount. - Opening another reply, edit, or delete panel closes the current one; an unsent reply is kept as a draft for that comment.
- Leading and trailing whitespace is trimmed on post; mention offsets follow.
- Deleting the comment being replied to or edited closes the panel.
Errors
| Code | Category | Cause |
|---|---|---|
DISCUSSION_OPTIONS |
configuration | Blank label; invalid or duplicate comments (id, parentId, author, text, createdAt, editedAt, deleted, replyCount, mentions that do not match the text); a parentId that is unknown or forms a cycle; invalid currentUser, maxLength, showCounter without maxLength, rows, triggers, hooks, status, strings, businessCalendar, or now. |
CFG_INVALID_VALUE / CFG_UNKNOWN_OPTION |
configuration | Invalid or unknown configuration. |
Invalid options throw before the host is modified; an invalid update() leaves the previous state intact. A failing loadReplies shows “Replies could not be loaded.” with Retry.
Known limitations
- Not virtualized: the DOM grows as readers page in comments and expand threads.
- Replies are always oldest first; sort applies to top-level comments.
- One reply, edit, or delete panel at a time.
- Each timestamp is a tab stop. Manual screen-reader verification is pending.
Unsupported scenarios
- Rich text, attachments, or reactions.
- Real-time presence and typing indicators (the host can call
addCommentas comments arrive). - Permission enforcement (server side).
(c) 2026 Kasadara Technology Solutions Pvt Ltd. AbsoluteUI is free to use under the AbsoluteUI Free Use License; it is not open source.