Skip to content
Commerce block

Write a Review

The form that produces the reviews the other blocks display — a real radio group for stars, and a prompt that changes with the rating because one star and five need different questions.

249 lineslucide-reactAdded 25 Aug 2026Updated 2 Sept 2026
  • review
  • rating
  • form
  • stars
  • ugc

What's included

  • components/review-submit-form.tsx
  • Needs lucide-react

Works with

  • React
  • Next.js
  • Tailwind CSS
  • TypeScript

npx hoverlab add review-submit-form

Or over MCP, from your editor's agent — no account needed.

License

Free to read, copy and install, for personal and non-commercial projects. Shipping it in client work or a paid product needs Pro ($79 once). The source lands in your repo and stops being ours — no attribution, nothing to upgrade.

Was this useful?

Start a page with this section — add more, order them, and leave with the page source.

Preview

Review your Aeropress Go

This will be public, shown as Priya Raman, marked as a verified purchase. You can edit or delete it later.

How many stars?

Pick a rating and the rest of the form appears.

Rendered live in your current theme — this is the same component whose source is below, not a screenshot of it.

Source

components/review-submit-form.tsx
'use client'

/**
 * <ReviewSubmitForm> — writing the review, not reading it.
 *
 * <ReviewList> and <ProductReviewSummary> both display reviews that somehow
 * already exist. This is the form that produces them, and it is the one
 * that decides whether they are any good — a review form is a content
 * pipeline, and almost every design decision in it trades volume against
 * usefulness.
 *
 * THE RATING IS A RADIO GROUP, NOT FIVE BUTTONS
 *
 * The star row is `role="radiogroup"` with five real inputs. That is what
 * gives arrow-key selection, one tab stop rather than five, and an
 * announced value — "3 stars, selected, 3 of 5". A row of `<button>`s with
 * a star glyph is the common implementation and it is unusable without a
 * mouse, which on a form this short means the whole block is.
 *
 * Hover preview is a pointer affordance layered on top, never the source of
 * truth: the fill follows `hovered ?? value`, so the keyboard and the mouse
 * agree and neither one is a special case.
 *
 * WHAT THE PROMPTS ARE FOR
 *
 * "Write a review" produces "great, thanks". The prompt line under the box
 * changes with the rating — a one-star review is asked what went wrong, a
 * five-star one is asked what it is good for — because the useful content
 * in each is different and nobody writes it unprompted. This is the single
 * highest-leverage element on the form and it costs one conditional.
 *
 * WHAT IS DELIBERATELY NOT REQUIRED
 *
 * The title. Most people write one sentence, and forcing a headline out of
 * them produces "Good product" on a third of all reviews. If it is blank
 * the list can render the first line of the body, which is a better title
 * than the one they would have typed.
 *
 * WHAT IS DISCLOSED BEFORE THEY START
 *
 * That the review is public, under their display name, and that it is
 * attached to a verified purchase. People edit what they write when they
 * learn that afterwards — which means the version they submitted was
 * written under a false impression.
 *
 * The character counter appears only as it approaches the limit. A counter
 * from character zero is a target, and it makes people write to it.
 */

import * as React from 'react'
import { ImagePlus, Star, X } from 'lucide-react'

export interface ReviewSubmitFormProps {
  productName?: string
  displayName?: string
  verifiedPurchase?: boolean
  maxLength?: number
  onSubmit?: (review: { rating: number; title: string; body: string }) => void
  className?: string
}

/*
  The prompt is the block. See the note above: what makes a one-star review
  useful is not what makes a five-star one useful, and neither gets written
  unless the form asks for it specifically.
*/
const PROMPTS: Record<number, string> = {
  1: 'What went wrong? The specific failure is more useful to the next reader than how it felt.',
  2: 'What did not work as expected — and was there anything that did?',
  3: 'What would have made this a four? Middling reviews are the ones people trust most.',
  4: 'What is it good at, and what stopped it being a five?',
  5: 'What is it good for? Say who you would recommend it to and why.',
}

export function ReviewSubmitForm({
  productName = 'Aeropress Go',
  displayName = 'Priya Raman',
  verifiedPurchase = true,
  maxLength = 1500,
  onSubmit,
  className = '',
}: ReviewSubmitFormProps) {
  /*
    Per-instance prefix for every id this block emits.

    The literals these replaced were a latent duplicate the moment the
    block appeared twice on one document, and `aria-labelledby` on a
    duplicated id resolves to the first match -- so the second copy was
    labelled by the first copy's heading. Client component, so `useId` is
    the right tool.
  */
  const uid = React.useId()

  const [rating, setRating] = React.useState(0)
  const [hovered, setHovered] = React.useState<number | null>(null)
  const [title, setTitle] = React.useState('')
  const [body, setBody] = React.useState('')

  /* Hover previews; the chosen value is what counts. */
  const shown = hovered ?? rating
  const remaining = maxLength - body.length
  const nearLimit = remaining <= 200

  return (
    <section
      aria-labelledby={`${uid}-review-form-heading`}
      className={`mx-auto w-full max-w-xl px-4 py-16 sm:px-6 lg:px-8 ${className}`}
    >
      <form
        onSubmit={(event) => {
          event.preventDefault()
          onSubmit?.({ rating, title, body })
        }}
        className="rounded-2xl border border-border bg-card p-6 sm:p-8"
      >
        <h2 id={`${uid}-review-form-heading`} className="text-lg font-semibold text-foreground">
          Review your {productName}
        </h2>

        {/* Said before they write, not after. */}
        <p className="mt-1.5 text-sm text-muted-foreground">
          This will be public, shown as{' '}
          <span className="font-medium text-foreground">{displayName}</span>
          {verifiedPurchase ? ', marked as a verified purchase' : ''}. You can edit
          or delete it later.
        </p>

        <fieldset className="mt-6">
          <legend className="text-sm font-medium text-foreground">
            How many stars?
          </legend>

          {/* A real radio group: arrow keys, one tab stop, announced value. */}
          <div
            role="radiogroup"
            aria-label="Rating out of 5"
            className="mt-2 flex items-center gap-1"
            onMouseLeave={() => setHovered(null)}
          >
            {[1, 2, 3, 4, 5].map((value) => (
              <label
                key={value}
                onMouseEnter={() => setHovered(value)}
                className="cursor-pointer rounded p-1 focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background"
              >
                <input
                  type="radio"
                  name="review-rating"
                  value={value}
                  checked={rating === value}
                  onChange={() => setRating(value)}
                  className="sr-only"
                />
                <Star
                  aria-hidden
                  className={`h-7 w-7 transition ${
                    value <= shown
                      ? 'fill-amber-400 text-amber-400'
                      : 'fill-transparent text-muted-foreground/50'
                  }`}
                />
                <span className="sr-only">
                  {value} star{value === 1 ? '' : 's'}
                </span>
              </label>
            ))}
          </div>
        </fieldset>

        {rating > 0 ? (
          <div className="mt-5 space-y-4">
            <label className="block">
              <span className="text-sm font-medium text-foreground">
                Headline{' '}
                <span className="font-normal text-muted-foreground">— optional</span>
              </span>
              <input
                type="text"
                value={title}
                onChange={(event) => setTitle(event.target.value)}
                maxLength={80}
                placeholder="Leave it blank and we will use your first line"
                className="mt-1.5 h-9 w-full rounded-lg border border-field bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
              />
            </label>

            <label className="block">
              <span className="text-sm font-medium text-foreground">Your review</span>
              {/* The prompt changes with the rating. */}
              <span
                role="status"
                className="mt-0.5 block text-sm text-muted-foreground"
              >
                {PROMPTS[rating]}
              </span>
              <textarea
                value={body}
                onChange={(event) => setBody(event.target.value.slice(0, maxLength))}
                rows={5}
                className="mt-2 w-full resize-y rounded-lg border border-field bg-background px-3 py-2 text-sm text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
              />
              {/* Only near the limit. A counter from zero is a target. */}
              {nearLimit ? (
                <span className="mt-1 block text-end text-xs text-muted-foreground">
                  {remaining} characters left
                </span>
              ) : null}
            </label>

            <button
              type="button"
              className="inline-flex h-9 items-center gap-1.5 rounded-lg border border-dashed border-border px-3 text-sm font-medium text-muted-foreground transition hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
            >
              <ImagePlus aria-hidden className="h-4 w-4" />
              Add photos
            </button>

            <div className="flex flex-wrap items-center gap-3 border-t border-border pt-4">
              <button
                type="submit"
                disabled={body.trim().length === 0}
                className="inline-flex h-9 items-center rounded-lg bg-primary px-4 text-sm font-semibold text-primary-foreground transition hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50"
              >
                Post review
              </button>
              <button
                type="button"
                onClick={() => {
                  setRating(0)
                  setTitle('')
                  setBody('')
                }}
                className="inline-flex h-9 items-center gap-1.5 rounded-lg px-3 text-sm font-medium text-muted-foreground transition hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
              >
                <X aria-hidden className="h-4 w-4" />
                Start over
              </button>
            </div>
          </div>
        ) : (
          <p className="mt-5 text-sm text-muted-foreground">
            Pick a rating and the rest of the form appears.
          </p>
        )}
      </form>
    </section>
  )
}

Before you paste

  • Styling is Tailwind utility classes on semantic tokens (bg-card, text-muted-foreground) — it inherits your theme instead of overriding it.
  • Install: npm i lucide-react
  • Every prop has a default, so it renders standalone before you wire it up.

Where it goes

Drop it at components/review-submit-form.tsx and import it where you need the section:

import { ReviewSubmitForm } from '@/components/review-submit-form'

Customize

4 of this block’s props are simple enough to drive from here. Change them and the block below re-renders — it is the same component whose source is above, not a mock of it. Everything else it accepts is in the table underneath.

Props

Read out of the component’s own type and signature, so this cannot drift from the source below. Every prop has a default — the component renders standalone before you pass it anything.

PropTypeDefault
productNamestring'Aeropress Go'
displayNamestring'Priya Raman'
verifiedPurchasebooleantrue
maxLengthnumber1500
onSubmit(review: { rating: number; title: string; body: string }) => void—
classNamestring''

Not using React?

The same block rendered once to markup, wrapped as a file your framework compiles. Tailwind classes are framework-agnostic, so the design transfers intact — the behaviour does not.

This block is interactive. The markup below is its initial state with the event handlers stripped — you will need to re-wire the behaviour in your framework.

review-submit-form.html
<!--
  Write a Review — markup from the Hoverlab catalog.

  This is the block rendered once to HTML and wrapped as a component
  file. It is not a port of the React source: the Tailwind classes carry
  the design, which is the part that took the work, and they are the same
  in every framework.

  This block is interactive in React and the handlers are NOT here.
  Buttons, toggles and menus render in their initial state and do
  nothing until you wire them up.
-->
<section aria-labelledby="_R_0_-review-form-heading" class="mx-auto w-full max-w-xl px-4 py-16 sm:px-6 lg:px-8 ">
  <form class="rounded-2xl border border-border bg-card p-6 sm:p-8">
    <h2 id="_R_0_-review-form-heading" class="text-lg font-semibold text-foreground">Review your Aeropress Go</h2>
    <p class="mt-1.5 text-sm text-muted-foreground">This will be public, shown as <span class="font-medium text-foreground">Priya Raman</span>, marked as a verified purchase. You can edit or delete it later.</p>
    <fieldset class="mt-6">
      <legend class="text-sm font-medium text-foreground">How many stars?</legend>
      <div role="radiogroup" aria-label="Rating out of 5" class="mt-2 flex items-center gap-1">
        <label class="cursor-pointer rounded p-1 focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background">
          <input type="radio" class="sr-only" name="review-rating" value="1" />
          <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-star h-7 w-7 transition fill-transparent text-muted-foreground/50" aria-hidden="true">
            <path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"></path>
          </svg>
          <span class="sr-only">1 star</span>
        </label>
        <label class="cursor-pointer rounded p-1 focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background">
          <input type="radio" class="sr-only" name="review-rating" value="2" />
          <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-star h-7 w-7 transition fill-transparent text-muted-foreground/50" aria-hidden="true">
            <path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"></path>
          </svg>
          <span class="sr-only">2 stars</span>
        </label>
        <label class="cursor-pointer rounded p-1 focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background">
          <input type="radio" class="sr-only" name="review-rating" value="3" />
          <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-star h-7 w-7 transition fill-transparent text-muted-foreground/50" aria-hidden="true">
            <path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"></path>
          </svg>
          <span class="sr-only">3 stars</span>
        </label>
        <label class="cursor-pointer rounded p-1 focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background">
          <input type="radio" class="sr-only" name="review-rating" value="4" />
          <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-star h-7 w-7 transition fill-transparent text-muted-foreground/50" aria-hidden="true">
            <path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"></path>
          </svg>
          <span class="sr-only">4 stars</span>
        </label>
        <label class="cursor-pointer rounded p-1 focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background">
          <input type="radio" class="sr-only" name="review-rating" value="5" />
          <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-star h-7 w-7 transition fill-transparent text-muted-foreground/50" aria-hidden="true">
            <path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"></path>
          </svg>
          <span class="sr-only">5 stars</span>
        </label>
      </div>
    </fieldset>
    <p class="mt-5 text-sm text-muted-foreground">Pick a rating and the rest of the form appears.</p>
  </form>
</section>
  • This is rendered HTML, not a translation of the React source. The Tailwind classes carry the design and work in any framework.
  • It is one frame: the component in its initial state, with no props applied beyond the defaults.
  • This block is interactive in React — toggles, menus or form state. None of that survives here; the markup is the closed/default state and the handlers are gone. Re-wire them in your own framework.
  • Requires Tailwind, and the design tokens the classes reference (bg-card, text-muted-foreground, and so on). The template ZIPs ship a globals.css that defines them.

What each framework gets across the whole catalog — effects convert properly; this rung is markup.

For AI

The component, its props, the design tokens it expects and the command that installs it — as one prompt. Paste it into Claude, Cursor, v0 or ChatGPT and what they build around it will match the rest of the catalog instead of inventing its own system.

See the prompt

Used in these pages

Want the whole screen instead of this one section? Open a page and copy it entire.

6 more blocks in Orders & Reviews

All of them free to read, copy and install — no account, no locked tiles, no watermarked preview. The whole catalog is open, and so are the API and the CLI.

Browse Orders & Reviews

Shipping one commercially

Copying the code is free. Putting it in client work or a paid product is what Pro is for — the licence, not the access.

  • A commercial licence for everything in the catalog
  • Unlimited bundle exports, in Vue, Svelte and Tailwind
  • One payment — no subscription, nothing to renew
Pro — $79 once

More Orders & Reviews blocks

View category
Open the full page for this block

Order Confirmation

The thank-you screen built to prevent two support emails: a selectable order number and a delivery date range rather than "soon".

Orders & Reviews212 lines1 dep

Order History

Past orders with stacked item thumbnails and worded statuses — people recognise what they bought long before the order number.

Orders & Reviews195 lines1 dep
Open the full page for this block

Customer Reviews

Sortable reviews with verified-purchase badges, optimistic helpful votes and a real expand control instead of a fade that hides text.

Orders & Reviews274 lines1 dep
Open the full page for this block

Order Tracking Timeline

The fortnight between buying and reviewing, answered properly: an arrival range rather than a date, exceptions above the timeline, and a copyable carrier reference.

Orders & Reviews258 lines1 dep
Open the full page for this block

Order Lookup Form

Order tracking for the guest who never made an account, which is most of them.

Orders & Reviews176 linesNo deps
Open the full page for this block

Review Distribution Band

The rating summary with the numbers that make an average trustworthy — the count, the spread and the verified share.

Orders & Reviews125 linesNo deps