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.

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

With no slot content at all, it renders as an empty container without errors; the sections of empty slots are hidden automatically.

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.

API ​

oas-comment ​

Attributes ​

AttributeDescriptionTypeDefault
alignTime/actions alignment: left (default) / right (logical properties, flips in RTL)——

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.