Components

QueryFeedback

Collects binary helpful/unhelpful feedback on a query result or AI-generated answer.

Category: DI Domain / Standalone

Import

import {
  QueryFeedback,
  type QueryFeedbackProps,
  type FeedbackValue,
} from "@hareru/ui"

Exports

NameTypeDescription
QueryFeedbackComponentFeedback toggle (<fieldset>)
QueryFeedbackPropsTypeProps interface
FeedbackValueType"helpful" | "unhelpful"

Key Props

PropTypeDefaultDescription
onFeedback(value: FeedbackValue | null) => voidCallback when feedback changes
valueFeedbackValue | nullControlled value
defaultValueFeedbackValue | nullnullInitial value (uncontrolled mode)
disabledbooleanfalseDisables both buttons
helpfulLabelstring"Helpful"Helpful button label
unhelpfulLabelstring"Not helpful"Unhelpful button label

States

StateTypeValuesDefaultCSS Reflection
feedbackenumnone | helpful | unhelpfulnone
disabledboolean

Accessibility

  • Roles: group
  • ARIA attributes: aria-label, aria-pressed
  • Semantic elements: fieldset
  • Keyboard:
    • Tab to navigate feedback buttons
    • Enter to submit feedback

Usage

import { useState } from "react"
import { QueryFeedback, type FeedbackValue } from "@hareru/ui"

// Uncontrolled
<QueryFeedback
  onFeedback={(value) => console.log("Feedback:", value)}
/>

// Controlled
function ControlledExample() {
  const [feedback, setFeedback] = useState<FeedbackValue | null>(null)
  return <QueryFeedback value={feedback} onFeedback={setFeedback} />
}

// With custom labels
<QueryFeedback
  helpfulLabel="Good answer"
  unhelpfulLabel="Bad answer"
  onFeedback={(value) => console.log("Feedback:", value)}
/>

Notes

  • Supports both controlled (value prop) and uncontrolled (defaultValue prop) modes.
  • Clicking an already-selected button toggles it off (value becomes null).
  • Renders as a <fieldset> with aria-label="Query feedback".
  • Each button uses aria-pressed for toggle state accessibility.
  • Icons: for helpful, for unhelpful.

On this page