Skip to content
Alea0.1
Pro
  1. Alea
  2. Components
  3. Data display
  4. Comment

Data display

Comment

Conversations: comments with author, relative time (full date on hover), badges, edited and restricted notes, saving and failed states, actions, nested replies, and a composer that grows and sends with ⌘Enter.

import { Comment, CommentComposer } from '@alea/ui';

Examples

Comment thread

Comments with relative times, badges, edits, a restricted note, nested replies, actions and a composer (⌘Enter sends).

Ana RivasAuthor

The new Tree is ready for review: data mode, cascading checkboxes, lazy loading and drag and drop.

Bruno Díaz· edited
Agreed. Can we keep the 4 px grid in the new cards?
Carla Mendes Only visible to your team
Yes, I updated the tokens.

Configurations

Every value of every property, side by side. Numbers match the legend below.

isEdited: false
isEdited: true
isHighlighted: false
isHighlighted: true
failed
saving
  1. EditedisEdited
  2. HighlightedisHighlighted
  3. Statestate

Anatomy

The parts of the component and the class that styles each one.

Tokens

The design tokens this component reads, with their value in the current theme. Override any of them to restyle it.

Color

  • --alea-accent-subtle…
  • --alea-border…
  • --alea-status-danger…
  • --alea-status-warning…
  • --alea-surface-raised…
  • --alea-text…
  • --alea-text-faint…
  • --alea-text-muted…

Space

  • --alea-space-1…
  • --alea-space-2…
  • --alea-space-3…
  • --alea-space-4…

Radius

  • --alea-radius-md…

Type

  • --alea-font-family-body…
  • --alea-font-size-2xs…
  • --alea-font-size-md…
  • --alea-font-size-sm…
  • --alea-font-size-xs…
  • --alea-font-weight-semibold…

Motion

  • --alea-motion-duration-slow…

Props

Comment props

One comment in a conversation: author, time, text, actions, and nested replies.

PropTypeDefaultDescription
authorrequiredstring-Who wrote it.
childrenrequiredReactNode-The comment.
actionsReactNode-Actions under it: Reply, Like, Edit (use Button variant="text" size="xs").
avatarSrcstring-Their photo.
badgeReactNode-A short tag after the name: Author, Admin, Bot.
classNamestring-Extra class names.
errorMessageReactNode-What went wrong when state is failed, with your retry action in actions.
headingLevel2 | 3 | 4 | 5 | 6-Heading level of the author line for screen readers' heading navigation. Default none (plain text).
isEditedboolean-Marks it as edited.
isHighlightedboolean-Draws attention to it: a linked or new comment.
repliesReactNode-Replies: nested Comment elements.
restrictedReactNode-Only some people can see it: shows a lock and this text ("Only visible to your team").
state"failed" | "saving"-Shows it as being saved (dimmed) or failed (with errorMessage).
timeReactNode | Date-When: a Date (shown relative, like "5 min ago", with the full date on hover) or your own text.

CommentComposer props

Where people write a comment or a reply: grows with the text, ⌘Enter or Ctrl+Enter sends.

PropTypeDefaultDescription
onSubmitrequired(text: string) => void-Called with the text when sent; clear it yourself if you control value.
authorstring-Who is writing (shows their avatar).
avatarSrcstring-Their photo.
classNamestring-Extra class names.
isSubmittingboolean-Disables sending while it saves.
labelstring-Label for screen readers. Default "Comment".
onCancel(() => void)-Shows Cancel, for inline replies.
placeholderstring-Placeholder. Default "Add a comment…".
submitLabelReactNode-Text of the send button. Default "Comment".

Specs

Generated from the source: the variants in the types, the states and tokens in the CSS, and the motion patterns that apply. The grids render the real component in both themes; the numbers are measured from the page.

Comment

Variants
statefailedsaving
Dark and light
Every color comes from theme tokens, so it follows data-theme (and presets like Graphite) on the page or any wrapper. Contrast is checked in both themes.
Styling hooks
.alea-comment.alea-comment-main.alea-comment-head.alea-comment-author.alea-comment-badge.alea-comment-time.alea-comment-restricted.alea-comment-body.alea-comment-error.alea-comment-actions.alea-comment-replies
Data attributes
data-highlighteddata-state=saving

CommentComposer

States
Focus inside
Dark and light
Every color comes from theme tokens, so it follows data-theme (and presets like Graphite) on the page or any wrapper. Contrast is checked in both themes.
Styling hooks
.alea-comment-composer.alea-comment-field.alea-comment-input.alea-comment-composer-actions

Accessibility

  • Each comment is an article; times are real time elements with the exact date.
  • Failed comments announce their error as an alert.
  • The composer is a labeled field; ⌘Enter or Ctrl+Enter sends, and the button says the shortcut.

Keyboard

KeyDoes
⌘Enter / Ctrl+EnterSends the comment

Do and don't

Do

  • Keep replies one or two levels deep.
  • Show who can see restricted comments.

Don't

  • Don't hide actions until hover only: keyboard and touch people need them too.
Tested with axe, keyboard and screen reader roles