Skip to main content

Review list Pro

Customer reviews with their summary, as Amazon and Shopify stores show them: the average in large figures, the count, and a bar per star count. Press a bar to see only those reviews, sort by newest, most helpful, highest or lowest, and read each review with its stars, verified purchase, photos, the seller's reply, Read more and Helpful. On wide screens the summary sits beside the list.

import { ReviewList } from '@patine-ui/pro';
Loading…
<ReviewList reviews={reviews} onHelpful={() => {}} onWriteReview={() => {}} style={{ width: '100%' }} />

Try the props​

Props
variant
dateFormat
bodyLines
design
<ReviewList
reviews={reviews}
onHelpful={vote}
onWriteReview={write}
/>

Example: reviews on a product page​

A product page's reviews: the summary up top filters by stars, the list sorts by most helpful, and Helpful votes are kept in the page so the counts move as you press them.

Loading…
<ReviewList
  reviews={reviews}
  sort="helpful"
  onHelpful={(review) => setReviews((all) => all.map((r) => (r.id === review.id ? { ...r, helpfulCount: (r.helpfulCount ?? 0) + 1 } : r)))}
  onWriteReview={() => {}}
  style={{ width: '100%' }}
/>

Summary from the server​

The summary is worked out from reviews. When the list is one page of many, pass the server's figures: summary={{ average: 4.6, total: 1284, distribution: { 5: 900, 4: 250, 3: 80, 2: 30, 1: 24 } }}.

Sorting, filtering and paging​

sort, defaultSort and onSortChange control the order ('recent', 'helpful', 'highest', 'lowest'); sortOptions picks which are offered, [] hides them. ratingFilter and onRatingFilterChange control the star filter the summary bars set. pageSize shows that many at first with Show more reviews; with hasMore and onLoadMore it asks your server for the next page once the shown ones run out.

Loading…
<ReviewList
  reviews={reviews}
  summary={{ average: 4.4, total: 12 }}
  variant="cards"
  dateFormat="relative"
  sortOptions={['recent', 'highest', 'lowest']}
  hasMore={reviews.length < 12}
  loadingMore={loading}
  onLoadMore={() => {
    setLoading(true);
    setTimeout(() => {
      setReviews((list) => [...list, ...make(list.length)]);
      setLoading(false);
    }, 700);
  }}
  style={{ width: 460 }}
/>

Helpful votes and photos​

onHelpful(review, helpful) shows Helpful on each review; the list keeps the user's votes itself, or pass helpful (the ids they voted for) to control them. onImagePress(review, index) opens a photo, e.g. in ImageViewer.

Props​

PropTypeDefaultDescription
reviewsReviewData[]—{ id, author: { name, avatar? }, rating, title?, body, date, verified?, helpfulCount?, images?, variant?, reply? }
variant'list' | 'cards''list'
showSummarybooleantrue
summary{ average?, total?, distribution? }from reviews
sort / defaultSort / onSortChange'recent' | 'helpful' | 'highest' | 'lowest''recent'
sortOptionsReviewSort[]all four
ratingFilter / defaultRatingFilter / onRatingFilterChangenumber | nullnull
onHelpful / helpfulHelpful votes.
bodyLinesnumber4Lines before Read more.
pageSize / hasMore / loadingMore / onLoadMorePaging.
onWriteReview() => void—Write a review, also in the empty state.
onImagePress(review, index) => void—
dateFormat'date' | 'relative''date'
locale / now
renderReview(info) => ReactNode—
loading / error / onRetry / emptyTitle / emptyDescription / renderEmptyStates.
density / animate / labels / design / theme / accessibilityLabel / style