SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

On this page

QuestionList

The questions shoppers asked about a product and the answers they got.

  • Q:Does the oak frame come with glass or acrylic?

    Asked by Lee · 3 days ago · 2 answers

    • A:
      Shatter-proof acrylic, so it ships safely and is light enough for a single nail.
      The shopStore2 days ago
    • A:
      Acrylic, and you honestly can't tell from across the room.
      PriyaVerified buyerYesterday
  • Q:Is the paper matte or satin?

    Asked by Sam · Today · 0 answers

View code
tsx
<QuestionList
	questions={product.questions.map((question) => ({
		id: question.id,
		question: question.text,
		meta: `Asked by ${question.author} · ${question.when}`,
		answers: question.answers.map((answer) => ({
			id: answer.id,
			author: answer.author,
			badge: answer.fromStore ? "Store" : undefined,
			body: answer.text,
			meta: answer.when,
		})),
	}))}
	empty="No questions yet. Ask the first one."
	labels={{ answers: "{n} answers" }}
/>

Installation

An ordinary dependency: install it, import the theme once, and import the component where it is used.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Usage

typescript
import { QuestionList } from "@sdxc/ui/commerce";

Renders each question as a list item: the "Q:" row, its meta and answer count, then an indented list of answers, each with its "A:" mark, its words and a row naming who answered. With no questions it renders empty, or nothing.

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeRequiredDescription
questionsQuestion[]Yes
emptyRemixNodeNoShown in place of the list when nobody has asked yet.
labelsLabelsYes

Also accepts everything in Omit<TagProps<"div">, "children">.

@sdxc/ui

Can’t find it? Contact us