Skip to content
Marketing block

Inline Feedback Widget

One click to rate, everything after it optional — the shape that collects a complaint from someone mid-task who would never open a contact page.

248 lineslucide-reactAdded 25 Aug 2026Updated 13 Sept 2026
  • feedback
  • rating
  • widget
  • nps
  • support

What's included

  • components/feedback-widget.tsx
  • Needs lucide-react

Works with

  • React
  • Next.js
  • Tailwind CSS
  • TypeScript

npx hoverlab add feedback-widget

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

How is this page working for you?

Rate this page

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

Source

components/feedback-widget.tsx
'use client'

/**
 * <FeedbackWidget> — the smallest thing that collects a useful complaint.
 *
 * The contact form asks for a name, an email, a subject and a message, and
 * it is the right shape for someone who arrived intending to get in touch.
 * It is the wrong shape entirely for the moment this block is for: someone
 * mid-task who just noticed something wrong. That person will not fill in
 * four fields, and if the only route is the contact page they will leave
 * with the thing still broken.
 *
 * So the ask is one click, and everything after it is optional.
 *
 * THE RATING IS THE WHOLE FORM
 *
 * Picking a face submits nothing and commits nothing — it opens the comment
 * box. That ordering matters: it means the low-effort answer is already
 * captured before the high-effort one is requested, so an abandoned comment
 * still leaves you a signal. A widget that requires the comment collects
 * far fewer ratings and not many more comments.
 *
 * EMAIL IS OPTIONAL AND SAYS WHY
 *
 * "Only so we can reply" under an optional field is worth more than a
 * privacy page nobody opens. Most people leave it blank; the ones who fill
 * it in are the ones who want an answer, which is exactly the segmentation
 * you want and it is free.
 *
 * WHAT IT SENDS THAT NOBODY TYPES
 *
 * The page path goes with the report. Half of all "it's broken" messages
 * arrive without one, and the fifteen minutes spent asking "where?" is the
 * reason most of them are never resolved. It is disclosed rather than
 * collected quietly — the line under the button says what is attached.
 *
 * ACCESSIBILITY
 *
 * The ratings are a radio group with real labels ("Bad", "Fine", "Great"),
 * so the choice is announced as a named option rather than as "button,
 * emoji". Emoji themselves are `aria-hidden`: a screen reader reading out
 * "slightly smiling face" as a form value is noise, and the text label
 * beside it is the actual answer. The thank-you state is a `role="status"`
 * so a submit that swaps the panel is heard and not only seen.
 */

import * as React from 'react'
import { MessageSquare, Send, X } from 'lucide-react'

export interface FeedbackRating {
  value: string
  emoji: string
  label: string
}

export interface FeedbackWidgetProps {
  heading?: string
  ratings?: FeedbackRating[]
  placeholder?: string
  /** Shown under the button — say what travels with the message. */
  attachmentNote?: string
  onSubmit?: (feedback: { rating: string; comment: string; email: string }) => void
  className?: string
}

const DEFAULT_RATINGS: FeedbackRating[] = [
  { value: 'bad', emoji: '🙁', label: 'Bad' },
  { value: 'ok', emoji: '😐', label: 'Fine' },
  { value: 'good', emoji: '🙂', label: 'Good' },
  { value: 'great', emoji: '😍', label: 'Great' },
]

export function FeedbackWidget({
  heading = 'How is this page working for you?',
  ratings = DEFAULT_RATINGS,
  placeholder = 'What happened? The more specific, the more fixable.',
  attachmentNote = 'Sends the page address and your browser version. Nothing else.',
  onSubmit,
  className = '',
}: FeedbackWidgetProps) {
  /*
    Ids come from `useId`, not from a literal.

    A literal is correct until the section appears twice on one page — and
    then `aria-labelledby` resolves to whichever copy is first in the
    document, so the second one is announced with the first one's heading.
    It renders identically and reads wrongly, which is why nothing catches
    it but an id check.
  */
  const headingId = React.useId()

  const [rating, setRating] = React.useState('')
  const [comment, setComment] = React.useState('')
  const [email, setEmail] = React.useState('')
  const [sent, setSent] = React.useState(false)

  function handleSubmit(event: React.FormEvent) {
    event.preventDefault()
    onSubmit?.({ rating, comment, email })
    setSent(true)
  }

  if (sent) {
    return (
      <section
        className={`mx-auto w-full max-w-md px-4 py-16 sm:px-6 ${className}`}
        aria-labelledby={headingId}
      >
        <div
          role="status"
          className="rounded-2xl border border-border bg-card p-6 text-center"
        >
          <h2 id={headingId} className="text-base font-semibold text-foreground">
            Thank you — that is genuinely useful.
          </h2>
          <p className="mt-2 text-sm text-muted-foreground">
            {email
              ? 'You will get a reply at the address you left, usually within a day.'
              : 'No reply is coming, because you did not leave an address — which is completely fine.'}
          </p>
          <button
            type="button"
            onClick={() => {
              setSent(false)
              setRating('')
              setComment('')
              setEmail('')
            }}
            className="mt-4 text-sm font-medium text-muted-foreground underline-offset-4 hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
          >
            Send another
          </button>
        </div>
      </section>
    )
  }

  return (
    <section
      aria-labelledby={headingId}
      className={`mx-auto w-full max-w-md px-4 py-16 sm:px-6 ${className}`}
    >
      <form
        onSubmit={handleSubmit}
        className="rounded-2xl border border-border bg-card p-5 shadow-sm"
      >
        <div className="flex items-start justify-between gap-3">
          <h2
            id={headingId}
            className="flex items-center gap-2 text-sm font-semibold text-foreground"
          >
            <MessageSquare aria-hidden className="h-4 w-4 text-muted-foreground" />
            {heading}
          </h2>
          <button
            type="button"
            className="-m-1 rounded p-1 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" />
            <span className="sr-only">Dismiss feedback</span>
          </button>
        </div>

        <fieldset className="mt-4">
          <legend className="sr-only">Rate this page</legend>
          <div className="grid grid-cols-4 gap-2">
            {ratings.map((option) => {
              const active = rating === option.value
              return (
                <label
                  key={option.value}
                  className={`flex cursor-pointer flex-col items-center gap-1 rounded-xl border px-2 py-3 transition ${
                    active
                      ? 'border-primary bg-primary/10'
                      : 'border-border bg-background hover:bg-muted'
                  } 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="feedback-rating"
                    value={option.value}
                    checked={active}
                    onChange={() => setRating(option.value)}
                    className="sr-only"
                  />
                  {/* Hidden from assistive tech — the label below is the
                      answer, and "slightly smiling face" is not. */}
                  <span aria-hidden className="text-xl leading-none">
                    {option.emoji}
                  </span>
                  <span
                    className={`text-[11px] ${active ? 'font-medium text-foreground' : 'text-muted-foreground'}`}
                  >
                    {option.label}
                  </span>
                </label>
              )
            })}
          </div>
        </fieldset>

        {/*
          Everything below appears only after a rating exists. The signal is
          already captured by then, so abandoning here still leaves data.
        */}
        {rating ? (
          <div className="mt-4 space-y-3">
            <label className="block">
              <span className="sr-only">Tell us more</span>
              <textarea
                value={comment}
                onChange={(event) => setComment(event.target.value)}
                rows={3}
                placeholder={placeholder}
                className="w-full resize-y rounded-lg border border-field bg-background px-3 py-2 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-xs text-muted-foreground">
                Email <span className="text-muted-foreground/70">— optional, only so we can reply</span>
              </span>
              <input
                type="email"
                value={email}
                onChange={(event) => setEmail(event.target.value)}
                autoComplete="email"
                className="mt-1 h-9 w-full rounded-lg border border-field bg-background px-3 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"
              />
            </label>

            <button
              type="submit"
              className="inline-flex h-9 w-full items-center justify-center gap-1.5 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"
            >
              <Send aria-hidden className="h-4 w-4 rtl:rotate-180" />
              Send feedback
            </button>

            {/* Disclosed, not collected quietly. */}
            <p className="text-center text-[11px] text-muted-foreground">{attachmentNote}</p>
          </div>
        ) : null}
      </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/feedback-widget.tsx and import it where you need the section:

import { FeedbackWidget } from '@/components/feedback-widget'

Customize

3 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
headingstring'How is this page working for you?'
ratingsFeedbackRating[]DEFAULT_RATINGS
placeholderstring'What happened? The more specific, the more f…
attachmentNoteShown under the button — say what travels with the message.string'Sends the page address and your browser vers…
onSubmit(feedback: { rating: string; comment: string; email: 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.

feedback-widget.html
<!--
  Inline Feedback Widget — 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_" class="mx-auto w-full max-w-md px-4 py-16 sm:px-6 ">
  <form class="rounded-2xl border border-border bg-card p-5 shadow-sm">
    <div class="flex items-start justify-between gap-3">
      <h2 id="_R_0_" class="flex items-center gap-2 text-sm font-semibold text-foreground"><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-message-square h-4 w-4 text-muted-foreground" aria-hidden="true"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>How is this page working for you?</h2>
      <button type="button" class="-m-1 rounded p-1 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">
        <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-x h-4 w-4" aria-hidden="true">
          <path d="M18 6 6 18"></path>
          <path d="m6 6 12 12"></path>
        </svg>
        <span class="sr-only">Dismiss feedback</span>
      </button>
    </div>
    <fieldset class="mt-4">
      <legend class="sr-only">Rate this page</legend>
      <div class="grid grid-cols-4 gap-2">
        <label class="flex cursor-pointer flex-col items-center gap-1 rounded-xl border px-2 py-3 transition border-border bg-background hover:bg-muted 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="feedback-rating" value="bad" />
          <span aria-hidden="true" class="text-xl leading-none">🙁</span>
          <span class="text-[11px] text-muted-foreground">Bad</span>
        </label>
        <label class="flex cursor-pointer flex-col items-center gap-1 rounded-xl border px-2 py-3 transition border-border bg-background hover:bg-muted 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="feedback-rating" value="ok" />
          <span aria-hidden="true" class="text-xl leading-none">😐</span>
          <span class="text-[11px] text-muted-foreground">Fine</span>
        </label>
        <label class="flex cursor-pointer flex-col items-center gap-1 rounded-xl border px-2 py-3 transition border-border bg-background hover:bg-muted 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="feedback-rating" value="good" />
          <span aria-hidden="true" class="text-xl leading-none">🙂</span>
          <span class="text-[11px] text-muted-foreground">Good</span>
        </label>
        <label class="flex cursor-pointer flex-col items-center gap-1 rounded-xl border px-2 py-3 transition border-border bg-background hover:bg-muted 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="feedback-rating" value="great" />
          <span aria-hidden="true" class="text-xl leading-none">😍</span>
          <span class="text-[11px] text-muted-foreground">Great</span>
        </label>
      </div>
    </fieldset>
  </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.

5 more blocks in Contact & Forms

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 Contact & Forms

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 Contact & Forms blocks

View category
Open the full page for this block

Split Contact Form

A contact form beside the channels that bypass it — a real address, a support link and a response-time promise, which is what makes a form people cannot see into feel worth filling.

Contact & Forms279 lines1 dep
Open the full page for this block

Multi-Step Form with Validation

A three-step form where each step validates only its own fields, errors are wired to inputs with aria-describedby, and advancing moves focus to the new heading.

Contact & Forms373 lines1 dep
Open the full page for this block

Form with Error Summary

The state every form reaches and none of them illustrate: a focused summary at the top linking to each bad field, validation that waits for submit, and somewhere for the failure that belongs to no field.

Contact & Forms320 lines1 dep
Open the full page for this block

Contact Sales Form

A qualifying contact form that asks the three things a first reply needs, and says what happens next before you send it.

Contact & Forms175 linesNo deps
Open the full page for this block

Support Ticket Form

A support form that asks for the one thing that halves resolution time — what you already tried — and says when a human will read it.

Contact & Forms169 linesNo deps