Comment

Comment

Comment is the Rust-only comment block: a header carrying an optional avatar, an optional author and an optional timestamp, a body of text, an optional actions row and an optional nested block. It is the card a thread's single message is drawn in.

This page documents a legacy migration surface. Comment is one of the components that settled in the Rust crate before the component pages existed, and the design system has no Vue twin for it — packages/vue/src ships no HkComment, so nothing in the Vue barrel exports one and the shared stylesheet mirror that the other pages describe has no counterpart here. The component is documented so that a Rust host can keep using it and so that the eventual replacement has an explicit contract to migrate from; treat its shape as frozen, not as the house pattern for new comment UI.

  • The block is a still: content is text, and the parts around it (actions, nested) are elements the host builds, so a collapse control or a "load replies" trigger is the host's markup, not the component's. Its sheet is written in the --hi-* variable family and nothing here binds it to a theme provider: on a host that only wires the --color-* family the card keeps its layout but takes no ink from the surrounding theme.
  • A comment's author handle is usually a HkCopyBadge in actions, and a figure quoted in the body can be a HkPrice or a HkShareBar.
  • A live count beside a thread (a rolling reply total, say) is HkRollingNumber; this block carries no numbers of its own.

Import

rust
1
2
use hikari_components::*;          // Comment, CommentProps
use hikari_components::prelude::*; // rsx!, VNode

Comment is a plain function, Comment(CommentProps { … }); inside rsx! the element form is Comment { … } and every prop may be omitted. content is the one field without a default, and its own Default is the empty string, so an omitted body renders an empty content row rather than nothing.

Author, avatar and timestamp

avatar is an image URL and becomes an <img> with the fixed alt text "Avatar"; it is rendered only when present. author and datetime are two text spans stacked in the meta column — the component does not parse the timestamp, so pass it already formatted and already localized. With no avatar the header shows the meta column alone; with neither author nor timestamp the header is an empty row, so pass at least one of the two.

Rust
Avatar
Ada2 hours ago
The export finished — the totals match the ledger.

Content, actions and nesting

content is rendered as text in its own row, wraps on word boundaries and keeps line breaks to 1.6. actions is an element slot rendered under the body — a row of buttons, a copy badge, a link — and nested is an element slot rendered under that inside the block, indented and ruled on the inline-start edge: mount one child Comment there for a one-level reply. Depth below that is the host's markup, not the component's.

class is appended to the container's class list and style is written onto the container, so a host can theme a single instance without forking the sheet.

Rust
Avatar
Ada2 hours ago
The export finished — the totals match the ledger.
Grace1 hour ago
Re-checked the third page, it agrees.

API

Rust

Props — Comment

PropTypeDefaultDescription
authorOption<String>None—
avatarOption<String>None—
contentString""—
datetimeOption<String>None—
actionsOption<Element>None—
nestedOption<Element>None—
classString""—
styleString""—

Accessibility

  • The structure is heading-free: the author is a <span>, not a heading, so a thread of comments adds no outline entries to the page. If a message needs to be a landmark, the host wraps it.
  • The avatar is an <img> with the constant alt text "Avatar" — it names nothing. When the avatar is the only thing identifying the author, put the name in author as well.
  • actions and nested are plain containers: focus order, names and roles all come from the elements the host puts inside them.
  • The timestamp is static text; the component never announces updates. For a "new reply" notice, put a live region in the host, not here.
  • Nothing in the block is interactive on its own, so it adds no stop to the Tab order.

Related components

  • HkCopyBadge — the interactive tag, typically the author handle in actions.
  • HkShareBar — the proportion row, when a message quotes a breakdown.
  • HkPrice — a money figure quoted in the body.
  • HkRollingNumber — a live figure beside a thread.
  • HkQrCode — a scan target shared in a message.