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
- A:
Q:Is the paper matte or satin?
Asked by Sam · Today · 0 answers
View code
<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.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Usage
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.
| Prop | Type | Required | Description |
|---|---|---|---|
questions | Question[] | Yes | |
empty | RemixNode | No | Shown in place of the list when nobody has asked yet. |
labels | Labels | Yes |
Also accepts everything in Omit<TagProps<"div">, "children">.