ValyroUI Русская версия

Article Comments

Article comments: votes, sorting, replies, moderation. Pro · Content and social › Feed and news

Installation

npx valyro-cli@latest login
npx valyro-cli@latest add article-comments
npm install valyro-ui-pro

import 'valyro-ui-pro/styles.css';
import { ArticleComments } from 'valyro-ui-pro';

Props

PropTypeDefault
valueArticleComment[]Controlled value; use with onValueChange.
defaultValueArticleComment[][]Initial value when uncontrolled.
onValueChange(comments: ArticleComment[]) => voidCalled with the new value when it changes.
sort'top' | 'newest' | 'oldest'Order of top-level comments; replies stay chronological.
defaultSort'top' | 'newest' | 'oldest''top'Initial sort when uncontrolled.
onSortChange(sort: ArticleCommentsSort) => voidCalled with the new sort when it changes.
currentUserArticleCommentAuthorThe signed-in reader. Without one, the composer gives way to a sign-in prompt.
onSignIn() => voidShows a "Sign in" button in the prompt for signed-out readers.
onPost(comment: ArticleComment, parentId: string | null) => voidCalled after a comment is posted; parentId is null for top-level comments.
onVote(commentId: string, vote: -1 | 0 | 1) => voidCalled after the reader votes; the list already updated the score.
onReport(commentId: string) => voidShows a "Report" action on other readers' comments.
totalCountnumberNumber in the header when the list holds only a page of the discussion (default: the comments in the list).
hasMorebooleanfalseMore comments can be loaded: shows a "Show more comments" button.
onLoadMore() => voidCalled by the "Show more comments" button.
loadingMorebooleanfalseThe next page is loading: the button shows a spinner.
closedbooleanfalseDiscussion closed: no composer and no reply buttons.
maxLengthnumber2000Longest comment in characters (default 2000); a counter appears near the limit.
rulesReactNodeCommunity rules or a moderation note under the composer.
maxDepthnumber3Nesting levels that get their own indentation; deeper replies line up with their parent (default 3).
headingLevel1 | 2 | 3 | 4 | 5 | 62Level of the title (default 2).
localestringBCP 47 locale for numbers and dates; defaults to the ThemeProvider's, then the browser's.
labelsPartial<ArticleCommentsLabels>Overrides for the built-in English text; keys left out keep their defaults.

Related components

  • Article Card — News card: vertical, horizontal and over a photo
  • Live Blog — Live blog: update feed, pinned and key events
  • Breaking News — “Breaking” banner with rotating headlines
  • Article Header — Article header: section, headline, lede, authors and date
  • Byline — Byline: authors, published and updated dates, reading time
  • Article Figure — Image with caption and photo credit
  • Pull Quote — Pull quote with attribution
  • Key Points — “Key points” summary block
  • Editor Note — Update, correction, disclosure and sponsored-content notes
  • Article Toc — Article table of contents that tracks the current section
  • Reading Progress — Reading progress bar
  • Share Bar — Share: Telegram, VK, X, WhatsApp, email and copy link

Previous: Breaking News · Next: Citation Evidence Lens · All Content and social