Skip to content

Comment ​

A purely presentational comment block container that assembles the author avatar, name, time, content, and actions via slots; nested child comments are automatically indented. It ships a built-in input row (Enter submits / Shift+Enter for a newline) and a resolved state (muted + strikethrough); comment data is always owned by the host and written back to drive rendering.

Basic Usage ​

Single comment

AAlice3 minutes ago

This component supports a purely presentational comment structure; interactions are provided by the host via the actions slot.

ReplyLike

Nested Child Comments ​

Nested replies (auto-indent)

BBobYesterday 18:20

Parent comment: I agree with this design; child comments are automatically indented with a guide line.

ReplyCCarolYesterday 19:02

Child comment: nest oas-comment via the default slot, with no depth limit.

Reply

Empty State ​

Empty comment (input row off)

With no slot content at all, it renders as an empty container without errors; the sections of empty slots are hidden automatically. The built-in input row can be turned off with inputtable="false", which is done here to avoid a lone composer.

Font Size ​

Font size follows the outer context (inherited) by default; override with the CSS variable --oas-comment-font (e.g. 18px).

Alignment ​

Time / actions alignment (align)

AAlice3 minutes ago

Default alignment: time and actions are left-aligned (align defaults to left).

ReplyLike
BBob10 minutes ago

align="right": the time is pushed to the right and the whole action group is right-aligned.

ReplyLike

align="left" | "right" controls the alignment of the time and actions. It is pure CSS (logical properties, so it flips automatically in RTL).

Quote and Reply Target ​

quote / reply slots (reply-to scenario)

CCarolYesterday 19:02Reply to @Bob
"Can we revisit the wrapping strategy of this design on narrow screens?"

Agreed — one more scenario: the action area should keep a minimum gap when it wraps on narrow screens.

ReplyLike

slot="reply" shows the reply target (e.g. "Reply to @someone") and slot="quote" shows the quoted original text. Both use a restrained style (secondary text + a left color bar) and hide automatically when empty.

Reply Interaction ​

Editor composition (reply with an input)

DDave1 hour ago

The component itself does not handle editing: click "Reply" to expand an input, and the host inserts the child comment into the default slot on submit.

Reply

Demonstrates dynamic slot composition of oas-comment + oas-textarea + oas-button: the submitted <oas-comment> goes into the default slot and is automatically indented with a guide line.

Built-in Input Row ​

The component ships with an input row (textarea + submit button): Enter submits, Shift+Enter inserts a newline; Enter during IME composition does not submit, and empty text is silently ignored. On submit it dispatches oas-submit (detail { text }, bubbles + composed).

Data-driven write-back: the component never appends list items internally — the host listens for oas-submit, appends the text to its own data source, and renders the new entry (into the default slot). The input row can be turned off with inputtable="false" (shown by default).

Submit loop (host appends data)

GDiscussionToday's topic

Type anything in the composer below and press Enter — the demo writes the submission back into the default slot; appended child comments also carry a resolve trigger.

The host listens for oas-submit to append a child comment and show a toast; clicking a resolve trigger dispatches oas-resolve (detail { id, resolved }), written back by the host to the resolved attribute.

Resolved State ​

resolvable (boolean presence attribute, off by default) shows a resolve / unresolve trigger; resolved (boolean presence attribute) renders the resolved style — strikethrough on the content, muted text for the entry (token-based, adapts to dark mode), plus a "Resolved" badge on the author row. Clicking the trigger dispatches oas-resolve (detail { id, resolved }); the component never flips the state itself — the host writes the data back and syncs the item's resolved attribute.

Resolved / open (click to toggle, host writes back)

EEve10 minutes ago

Open: click "Mark as resolved" and the host writes `resolved` back onto this entry.

FFrankYesterday 18:02

Resolved: strikethrough content, muted entry, and a "Resolved" badge on the author row; click "Unmark resolution" to switch back.

API ​

oas-comment ​

Attributes ​

AttributeDescriptionTypeDefault
alignTime/actions alignment: left (default) / right (logical properties, flips in RTL)——
comment-idEntry id: passed back in the oas-resolve event detail (decoupled from the DOM id, same family naming as message-id; falls back to an empty string)string—
inputtableBuilt-in input row switch (on by default): set inputtable="false" explicitly to hide it. Enter submits, Shift+Enter inserts a newline; Enter during IME composition does not submit; empty text is silently ignoredstringtrue
resolvableResolve trigger switch (boolean presence attribute, off by default — zero visual change): when present, a resolve/unresolve trigger appears in the actions row; the row also shows when the actions slot is empty because of the built-in triggerboolean—
resolvedResolved state (boolean presence attribute): strikethrough on the content, muted entry text, and a "Resolved" badge on the author row (token-based, adapts to dark mode). Data-driven — the host writes data back and syncs this attribute; the component never flips it internallyboolean—

Methods ​

MethodSignatureDescription
submitsubmit(): booleanSubmits the current composer text; returns false and dispatches nothing when the text is empty or the composer is hidden

Events ​

EventDescription
oas-resolveDispatched when a resolve/unresolve trigger is clicked. detail { id, resolved } — id is the comment-id attribute value (empty string by default), resolved is the target resolution state (true = mark resolved / false = unmark); the component never flips resolved internally — the host writes data back and syncs the item attribute
oas-submitDispatched when the built-in input row is submitted (Enter or the submit button). detail { text } — the trimmed text; empty text is not dispatched; the component never appends list items internally — the host writes data back to drive rendering (data-driven write-back)

Slots ​

NameDescription
defaultNested oas-comment child comments, automatically indented
actionsAction area (reply / like, etc., provided by the host)
authorAuthor name
avatarAuthor avatar (can hold an oas-avatar)
contentComment content
quoteQuote area (before content, secondary text + left accent border)
replyReply target area (under the author line, for "reply to @someone")
timeTime

CSS Variables ​

CSS VariableDefault
--oas-comment-fontinherit

Parts: ::part(comment) root, ::part(main) main body, ::part(avatar), ::part(body) content column (containing the ::part(head) header row), ::part(author) / ::part(time) / ::part(reply) / ::part(quote) / ::part(content) / ::part(actions), ::part(children) child comment container.

Released under the MIT OR Apache-2.0 License.