# Reviews

> Product ratings, customer photos and reviews for a product page. Handles rating filters, helpful votes, review photos and products with no reviews yet.

Canonical: https://hextaui.com/blocks/reviews
Last updated: 2026-10-29

## Overview

Reviews is the reviews section of a product page: an average with stars, a rating histogram, feature ratings, a size scale, a strip of customer photos and the review list. It takes an array of reviews and works out the stats itself, or takes stats from your API when you only load a page at a time.

Every histogram bar is a button. Click 4 stars and the list shows only 4-star reviews, the bar stays highlighted, a removable 4 stars chip appears above the list and screen readers hear how many reviews match. Filters are single-choice, combine with With photos, search within reviews and four sort orders, and an empty result offers to clear them. With five reviews or fewer the histogram is hidden, since a distribution of three reviews says nothing.

Each review shows its stars, title, body clamped at six lines with Read more, the buyer’s name with a Verified buyer badge, the variant they bought and their size feedback. Photos open a lightbox. A merchant reply sits indented under the review. Helpful votes count up straight away, one vote per review, and roll back with a message if your API fails. Rating-only and photo-only reviews lay out without empty gaps.

WriteReview is a dialog, a bottom sheet on phones, with a star rating input, title, body with a minimum length, a Runs small · True to size · Runs large scale, photo uploads with previews, name and email. It validates in place, keeps the draft if the shopper closes it, and ends on “Thanks, your review will appear after a quick check.” RatingStars, RatingInput, ReviewsSummary, ReviewPhotos and ReviewList also work on their own.

## Installation

### Step 1: Get HextaUI Pro

One payment unlocks every block, including future ones. [See pricing](https://hextaui.com/pricing).

### Step 2: Add the Pro registry to components.json

```json title="components.json"
{
  "registries": {
    "@hextaui-pro": {
      "url": "https://hextaui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${HEXTAUI_PRO_TOKEN}"
      }
    }
  }
}
```

### Step 3: Add your token

Create a token on your [account page](https://hextaui.com/account) and put it in `.env.local` as `HEXTAUI_PRO_TOKEN`.

### Step 4: Add the block

```bash
npx shadcn@latest add @hextaui-pro/reviews
```

## Usage

### From Judge.me, Yotpo or Shopify

Map each provider’s review once to the Review shape. Judge.me pictures, Yotpo images and custom fit fields, helpful votes and merchant replies all have a place, and Shopify’s product review metaobjects map in a few lines.

```tsx
import type { Review, ReviewFit } from "@/components/blocks/reviews/review"

type JudgeMeReview = {
  id: number
  rating: number
  title: string | null
  body: string | null
  created_at: string
  verified: "buyer" | "nothing" | "email"
  reviewer: { name: string }
  pictures: { urls: { original: string; small: string } }[]
  votes?: { up: number; down: number }
  reply?: { content: string; created_at: string } | null
}

type YotpoReview = {
  id: number
  score: number
  title: string
  content: string
  created_at: string
  verified_buyer: boolean
  user: { display_name: string }
  votes_up: number
  votes_down: number
  images_data?: { id: number; original_url: string; thumb_url: string }[]
  custom_fields?: Record<string, { title: string; value: string }>
  comment?: { content: string; created_at: string } | null
}

type ShopifyReviewMetaobject = {
  id: string
  rating: { value: string }
  title?: { value: string }
  body?: { value: string }
  author: { value: string }
  createdAt: string
  verified?: { value: string }
}

const fits: Record<string, ReviewFit> = {
  "Runs small": -1,
  "True to size": 0,
  "Runs large": 1,
}

export function fromJudgeMe(review: JudgeMeReview): Review {
  return {
    id: String(review.id),
    rating: review.rating,
    title: review.title ?? undefined,
    body: review.body ?? undefined,
    author: review.reviewer.name,
    verified: review.verified === "buyer",
    createdAt: review.created_at,
    photos: review.pictures.map((picture, index) => ({
      id: `${review.id}-${index}`,
      src: picture.urls.original,
      thumbnail: picture.urls.small,
    })),
    helpful: review.votes,
    reply: review.reply
      ? { author: "", body: review.reply.content, createdAt: review.reply.created_at }
      : undefined,
  }
}

export function fromYotpo(review: YotpoReview): Review {
  const fields = Object.values(review.custom_fields ?? {})
  const fit = fields.find((field) => field.title === "Fit")?.value
  return {
    id: String(review.id),
    rating: review.score,
    title: review.title || undefined,
    body: review.content || undefined,
    author: review.user.display_name,
    verified: review.verified_buyer,
    createdAt: review.created_at,
    fit: fit ? fits[fit] : undefined,
    photos: review.images_data?.map((image) => ({
      id: String(image.id),
      src: image.original_url,
      thumbnail: image.thumb_url,
    })),
    helpful: { up: review.votes_up, down: review.votes_down },
    reply: review.comment
      ? { author: "", body: review.comment.content, createdAt: review.comment.created_at }
      : undefined,
  }
}

export function fromShopifyMetaobject(review: ShopifyReviewMetaobject): Review {
  const rating = JSON.parse(review.rating.value) as { value: string }
  return {
    id: review.id,
    rating: Number(rating.value),
    title: review.title?.value,
    body: review.body?.value,
    author: review.author.value,
    verified: review.verified?.value === "true",
    createdAt: review.createdAt,
  }
}
```

### Server-side pagination

For products with thousands of reviews, pass stats from your API and set manual. Rating, photo, search and sort changes come out through onQueryChange, Show more calls onLoadMore, and the list dims while the next page loads.

```tsx
"use client"

import * as React from "react"

import { defaultQuery, type Review, type ReviewQuery, type ReviewStats } from "@/components/blocks/reviews/review"
import { Reviews } from "@/components/blocks/reviews/reviews"

type Page = { reviews: Review[]; total: number; cursor: string | null }

async function fetchReviews(
  productId: string,
  query: ReviewQuery,
  cursor: string | null
): Promise<Page> {
  const params = new URLSearchParams({
    sort: query.sort,
    q: query.search,
    photos: String(query.withPhotos),
    limit: "10",
  })
  if (query.rating !== null) params.set("rating", String(query.rating))
  if (cursor) params.set("cursor", cursor)
  const response = await fetch(`/api/products/${productId}/reviews?${params}`)
  if (!response.ok) throw new Error("Couldn’t load reviews")
  return response.json()
}

export function ProductReviews({
  productId,
  stats,
  firstPage,
}: {
  productId: string
  stats: ReviewStats
  firstPage: Page
}) {
  const [query, setQuery] = React.useState<ReviewQuery>(defaultQuery)
  const [page, setPage] = React.useState(firstPage)
  const [loading, setLoading] = React.useState(false)
  const request = React.useRef(0)

  const changeQuery = async (next: ReviewQuery) => {
    setQuery(next)
    const id = ++request.current
    setLoading(true)
    try {
      const result = await fetchReviews(productId, next, null)
      if (id === request.current) setPage(result)
    } finally {
      if (id === request.current) setLoading(false)
    }
  }

  return (
    <Reviews
      manual
      stats={stats}
      reviews={page.reviews}
      total={page.total}
      query={query}
      onQueryChange={changeQuery}
      loading={loading}
      hasMore={page.cursor !== null}
      onLoadMore={async () => {
        const next = await fetchReviews(productId, query, page.cursor)
        setPage((current) => ({
          ...next,
          reviews: [...current.reviews, ...next.reviews],
        }))
      }}
      onVote={async (review, vote) => {
        const response = await fetch(`/api/reviews/${review.id}/vote`, {
          method: "POST",
          body: JSON.stringify({ vote }),
        })
        if (!response.ok) throw new Error("Vote failed")
      }}
    />
  )
}
```

### Submit with photos

WriteReview hands you the rating, text, fit, photo Files, name and email. Post them as FormData. Throw an Error with a specific message and it shows in the dialog while everything the shopper wrote stays put.

```tsx
"use client"

import * as React from "react"

import { Button } from "@/components/ui/button"

import type { ReviewDraft } from "@/components/blocks/reviews/review"
import { WriteReview } from "@/components/blocks/reviews/write-review"

async function submitReview(productId: string, draft: ReviewDraft) {
  const form = new FormData()
  form.set("productId", productId)
  form.set("rating", String(draft.rating))
  form.set("title", draft.title)
  form.set("body", draft.body)
  form.set("name", draft.name)
  form.set("email", draft.email)
  if (draft.fit !== null) form.set("fit", String(draft.fit))
  for (const photo of draft.photos) form.append("photos", photo, photo.name)

  const response = await fetch("/api/reviews", { method: "POST", body: form })
  if (response.status === 409) {
    throw new Error("You’ve already reviewed this product with that email.")
  }
  if (!response.ok) {
    throw new Error("Couldn’t send your review. Try again in a moment.")
  }
}

export function ReviewButton({ productId, title }: { productId: string; title: string }) {
  const [open, setOpen] = React.useState(false)
  return (
    <>
      <Button variant="outline" onClick={() => setOpen(true)}>
        Write a review
      </Button>
      <WriteReview
        open={open}
        onOpenChange={setOpen}
        product={{ title }}
        maxPhotos={4}
        onSubmit={(draft) => submitReview(productId, draft)}
      />
    </>
  )
}
```

## Anatomy

The parts you compose, from the outside in.

| Part | Description |
| --- | --- |
| `Reviews` | The whole section: summary on the left, photos and list on the right, stacked on narrow screens. |
| `ReviewsSummary` | Average, stars, review count, histogram filter, feature ratings, size scale and Write a review. |
| `ReviewPhotos` | A scrolling strip of every customer photo, opening a lightbox that links back to the review. |
| `ReviewList` | Toolbar, filter status, review items, Show more and empty states. |
| `WriteReview` | The review form in a dialog, with validation, photo uploads and a success state. |
| `RatingStars, RatingInput` | Star display with fractional fill, and a star radio group for writing a review. |
| `getReviewStats, queryReviews, formatCount` | Work out stats, filter and sort reviews, and format counts like 1,284 or 12.4K. |

## API reference

### Reviews

Also takes div props.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `reviews` | `Review[]` | – | The reviews to show. In manual mode, the pages loaded so far. |
| `stats` | `ReviewStats` | – | Count, average, distribution, feature ratings and fit. Worked out from reviews when left out. |
| `attributes` | `{ name: string; low?: string; high?: string }[]` | – | Which feature ratings to show, in order, with labels for each end of the scale. |
| `photoReviews` | `Review[]` | – | Reviews for the photo strip, when they differ from the loaded page. |
| `query` | `ReviewQuery` | – | The rating filter, With photos, search and sort. Controlled when set. |
| `defaultQuery` | `Partial<ReviewQuery>` | – | The starting query when uncontrolled. |
| `onQueryChange` | `(query: ReviewQuery) => void` | – | Called when a filter, the search or the sort changes. Search changes are debounced. |
| `manual` | `boolean` | `false` | The reviews are already filtered, sorted and paged by your server. |
| `total` | `number` | – | How many reviews match the query, in manual mode. |
| `hasMore` | `boolean` | – | Whether another page exists, in manual mode. |
| `onLoadMore` | `() => void \| Promise<void>` | – | Loads the next page. A rejected promise shows Couldn’t load more reviews with a retry. |
| `loading` | `boolean` | – | Dims the list while a new query loads. |
| `pageSize` | `number` | `5` | Reviews per Show more step when paging on the client. |
| `onVote` | `(review, vote: "up" \| "down" \| null) => void \| Promise<void>` | – | Saves a helpful vote. Counts change at once and roll back if it throws. null removes the vote. |
| `votes` | `Record<string, "up" \| "down">` | – | Votes the shopper already cast, by review id. |
| `onSubmitReview` | `(draft: ReviewDraft) => void \| Promise<void>` | – | Enables Write a review. Throw an Error to show its message in the form. |
| `product` | `{ title: string; image?: string; variant?: string }` | – | Shown at the top of the review form. |
| `fit` | `boolean` | `true` | Show the size scale in the summary and the form. |
| `histogramThreshold` | `number` | `5` | Hide the histogram at this many reviews or fewer. |
| `merchantName` | `string` | – | Name used for merchant replies without an author. |
| `locale` | `Intl.LocalesArgument` | `"en-US"` | Locale for numbers and dates. |
| `labels` | `{ summary?, list?, photos?, write? }` | – | Every user-facing string, per part. |

### ReviewsSummary

Also takes section props.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `stats` | `ReviewStats` | – | The numbers to show. |
| `rating` | `1 \| 2 \| 3 \| 4 \| 5 \| null` | – | The active histogram filter. |
| `onRatingChange` | `(rating) => void` | – | Called with the clicked rating, or null when the active bar is clicked again. |
| `onWriteReview` | `() => void` | – | Shows the Write a review button. |
| `headingLevel` | `2 \| 3` | `2` | Heading level for Customer reviews. |

### ReviewList

Also takes section props, and the list props of Reviews.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `count` | `number` | – | Total reviews for the product, used for the no reviews yet state. |
| `onWriteReview` | `() => void` | – | Shows Write the first review in the empty state. |
| `showToolbar` | `boolean` | `true` | Show search, With photos and sort. |
| `actionsRef` | `Ref<{ reveal(id: string): void }>` | – | reveal clears filters if needed, pages to the review, scrolls to it and focuses it. |

### ReviewPhotos

Also takes section props.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `reviews` | `Review[]` | – | Reviews whose photos fill the strip. |
| `onJumpToReview` | `(review: Review) => void` | – | Shows Read review in the lightbox. |

### WriteReview

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `open` | `boolean` | – | Whether the dialog is open. Controlled when set. |
| `onOpenChange` | `(open: boolean) => void` | – | Called when the dialog opens or closes. It can’t close while submitting. |
| `onSubmit` | `(draft: ReviewDraft) => void \| Promise<void>` | – | Receives rating, title, body, fit, photos as File[], name and email. |
| `minBodyLength` | `number` | `20` | Minimum characters when the shopper writes a review body. |
| `maxPhotos` | `number` | `5` | How many photos can be attached. |
| `maxPhotoBytes` | `number` | `10485760` | Largest photo accepted, in bytes. |
| `defaultValues` | `{ name?, email?, rating? }` | – | Prefill for signed-in shoppers or a rating picked from an email. |

### RatingStars

Also takes span props.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `number` | – | A rating from 0 to 5. Fractions fill part of a star. |
| `size` | `"sm" \| "default" \| "lg"` | `"default"` | Star size. |

### RatingInput

Also takes div props.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `1 \| 2 \| 3 \| 4 \| 5 \| null` | – | The chosen rating. Controlled when set. |
| `onValueChange` | `(value) => void` | – | Called when a star is chosen. |
| `invalid` | `boolean` | – | Marks the group invalid. |
| `labels` | `Partial<RatingInputLabels>` | – | Star names and the Poor to Excellent descriptions. |

### Review

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `id, rating, author, createdAt` | `string, number, string, string` | – | Required fields. createdAt is an ISO date. |
| `title, body` | `string` | – | Optional, so rating-only and photo-only reviews work. |
| `verified, variant, fit` | `boolean, string, -1 \| 0 \| 1` | – | Verified buyer badge, the variant bought, and runs small, true to size or runs large. |
| `photos` | `{ id; src; thumbnail?; alt? }[]` | – | Customer photos. |
| `helpful, reply, attributes` | `{ up; down }, { author; body; createdAt? }, Record<string, number>` | – | Vote counts, the merchant reply and per-feature ratings from 1 to 5. |

## Keyboard

| Key | Action |
| --- | --- |
| `Tab` | Moves through histogram bars, toolbar, reviews, photos and votes. |
| `Enter` `Space` | Applies or clears a rating filter, toggles With photos or a vote. |
| `ArrowLeft` `ArrowRight` | Chooses a star in the rating input, or moves between photos in the lightbox. |
| `Escape` | Clears the review search, or closes the lightbox and the review form. |

## Accessibility

- Stars are one image named “Rated 4.6 out of 5”, not five separate icons. The rating input is a radio group whose stars read “4 stars, Very good”.
- Histogram bars are toggle buttons with aria-pressed and names like “5 stars, 812 reviews, 63%”. A polite live region announces how many reviews match after each filter change.
- Votes are toggle buttons that read their count. A failed vote is announced as an alert and the count returns to what it was.
- Revealing a review from the lightbox and loading more reviews move focus to the review, so keyboard users land where the content is. Every transition has a reduced-motion version, and selection never relies on color alone.

## Built with

The free HextaUI components Reviews is made from. Each one installs on its own.

- [Badge](https://hextaui.com/docs/badge) - Status labels with colored dots, removable tags that slide closed and counts that roll to their new value.
- [Button](https://hextaui.com/docs/button) - Buttons in every variant and size, with a built-in loading, success and error flow that skips the spinner for fast requests.
- [Dialog](https://hextaui.com/docs/dialog) - A window over the page for forms and focused tasks, with a pinned header and footer, nesting, and a swipeable bottom sheet on phones.
- [Empty](https://hextaui.com/docs/empty) - A placeholder for screens with nothing to show yet, with an icon, a message and the next action.
- [Field](https://hextaui.com/docs/field) - Labels, descriptions and errors wired to their control, with validation states and layouts for forms.
- [Input](https://hextaui.com/docs/input) - A text input with three sizes, invalid and read-only states, native validation styling and a 16px touch font so phones never zoom in.
- [Input group](https://hextaui.com/docs/input-group) - An input with icons, text, buttons or a keyboard hint attached, sharing one border and focus ring.
- [Number flow](https://hextaui.com/docs/number-flow) - Animated numbers where only the changed digits spin, with any Intl format and locale.
- [Select](https://hextaui.com/docs/select) - Pick one or more options from a list that opens on the current value, with typeahead, groups and form support.
- [Textarea](https://hextaui.com/docs/textarea) - Multi-line text that grows smoothly with what you write between a minimum and maximum number of rows, with counters, validation and a submit shortcut.
- [Toggle](https://hextaui.com/docs/toggle) - A button that stays on or off, with a fill that settles in when pressed, a clear hover-to-on step and icons that can fill with the state.
- [Toggle group](https://hextaui.com/docs/toggle-group) - A row of toggles for one choice or many, with a fill that slides to the picked item, joined or spaced items and arrow-key focus.

## Code

10 files, added to components/blocks/reviews.
