Feedback Widget

One question with an NPS, emoji, thumbs or star scale, an optional comment and a thank-you. Inline or floating.

Category
Data & feedback
Access
Free with an account
Source
309 lines · one file
States
5 drawn

The decision inside it

Picking a score is not sending it

When there is a follow-up, the score waits for the comment or for Skip, so someone who changes their mind on the scale is not recorded twice.

When to use it

Use Feedback Widget to ask one question: type nps for recommending, emoji for how something felt, thumbs for useful or not, stars for a rating. Add followUp for an optional comment, and variant "floating" for a corner button that opens it.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Liro's Feedback Widget for this.
Install it: npx shadcn@latest add @liro/feedback-widget
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/feedback-widget.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Free components install through the @liro registry with your CLI token: see the Namespaced tab.

Usage

components/nps-survey.tsx
import { FeedbackWidget } from "@/components/ui/feedback-widget";

export function NpsSurvey() {
  return (
    <FeedbackWidget
      type="nps"
      question="How likely are you to recommend us to a colleague?"
      followUp="What is the main reason for your score?"
      onSubmit={(value) => fetch("/api/feedback", { method: "POST", body: JSON.stringify(value) })}
    />
  );
}

API reference

“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

TypeNotes
typeFeedbackType NoDefault "nps".
questionstring Yes–
followUpstring NoThe prompt for an optional comment after the score.
onSubmit(value: FeedbackValue) => void | Promise<unknown> Yes–
variant"card" | "floating" NoDefault "card".
faces"emoji" | "icons" NoFor type "emoji": colour emoji (default) or line icons that take the text colour.
thanksstring NoThe thank-you line.
classNamestring No–

Dependencies

npm packages

clsxframer-motionlucide-reacttailwind-merge

Liro foundations, installed alongside it

liro-themebuttonstar-ratingtextarea

States

All of them are drawn by the component. None is left for you to design.

  • NPS
  • Emoji
  • Thumbs
  • Stars
  • Floating

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances