Response summary
What came back, one mini-chart per question: bars, histogram with mean and NPS, list of texts, matrix grid.
import { ResponseSummary, summarizeForm, formResponseGrid, formPercent } from "@forgeron/ui";- Responses
- 24
- Completed
- 100 %
- Questions
- 4
- 1
Which session did you attend?
Single choiceWhich session did you attend? - 2
How was it?
RatingHow was it? - 01 answers: 0
- 02 answers: 0
- 83 answers: 8
- 84 answers: 8
- 85 answers: 8
Mean 4Median 4
- 3
Which topics helped you?
Multiple choiceWhich topics helped you? - 4
What should we change?
Long text- Share the slides beforehand.
- More time for questions.
- The room was too warm.
- A real project to work on would help.
| Responseid | Submitteddate | Which session did you attend?single choice | How was it?rating | Which topics helped you?multiple choice | What should we change?long text |
|---|---|---|---|---|---|
| r1 | 2026-11-01 | Morning | 3 | Design | More time for questions. |
| r2 | 2026-11-02 | Afternoon | 5 | Design, Code | NULL |
| r3 | 2026-11-03 | Both | 4 | Code, Process | NULL |
| r4 | 2026-11-04 | Morning | 3 | Process | The room was too warm. |
| r5 | 2026-11-05 | Afternoon | 5 | Design | NULL |
| r6 | 2026-11-06 | Both | 4 | Design, Code | NULL |
import {
DataGrid,
ResponseSummary,
formResponseGrid,
type FormResponse,
type FormSchema,
} from "@forgeron/ui";
const schema: FormSchema = {
version: 1,
title: "Workshop feedback",
sections: [
{
id: "s1",
title: "",
questions: [
{
id: "session",
type: "singleChoice",
title: "Which session did you attend?",
required: true,
options: [
{ id: "am", label: "Morning" },
{ id: "pm", label: "Afternoon" },
{ id: "both", label: "Both" },
],
},
{ id: "stars", type: "rating", title: "How was it?", range: { min: 1, max: 5 } },
{
id: "topics",
type: "multiChoice",
title: "Which topics helped you?",
options: [
{ id: "t1", label: "Design" },
{ id: "t2", label: "Code" },
{ id: "t3", label: "Process" },
],
},
{ id: "words", type: "longText", title: "What should we change?" },
],
},
],
};
const comments = [
"More time for questions.",
"The room was too warm.",
"Share the slides beforehand.",
"Shorter breaks, longer sessions.",
"A real project to work on would help.",
];
// Fake data, made from a counter: no real person is behind these rows.
const responses: FormResponse[] = Array.from({ length: 24 }, (_, i) => ({
id: `r${i + 1}`,
submittedAt: `2026-11-${String(1 + (i % 9)).padStart(2, "0")}`,
answers: {
session: ["am", "pm", "both"][(i * 7) % 3]!,
stars: 3 + ((i * 5) % 3),
topics: [["t1"], ["t1", "t2"], ["t2", "t3"], ["t3"]][i % 4]!,
...(i % 3 === 0 ? { words: comments[(i / 3) % comments.length]! } : {}),
},
}));
export default function Default() {
const grid = formResponseGrid(schema, responses);
return (
<div style={{ display: "grid", gap: 24 }}>
<ResponseSummary schema={schema} responses={responses} />
<DataGrid label="Responses" columns={grid.columns} rows={grid.rows.slice(0, 6)} />
</div>
);
}- Responses
- 18
- Completed
- 100 %
- Questions
- 3
- 1
Would you recommend us?
ScaleWould you recommend us? - 00 answers: 0
- 01 answers: 0
- 02 answers: 0
- 13 answers: 1
- 04 answers: 0
- 15 answers: 1
- 26 answers: 2
- 27 answers: 2
- 28 answers: 2
- 59 answers: 5
- 510 answers: 5
Mean 8.06Median 9
- NPS
- +33
- Promoters
- 10
- Passives
- 4
- Detractors
- 4
- 2
How satisfied are you with each part?
MatrixHow satisfied are you with each part? Poor Fair Good Speed 3 3 12 Docs 3 7 8 - 3
What do you want next?
RankingWhat do you want next?
import { ResponseSummary, type FormResponse, type FormSchema } from "@forgeron/ui";
// A scale marked as NPS adds the score; a matrix is counted cell by cell; a ranking by points.
const schema: FormSchema = {
version: 1,
title: "Customer survey",
sections: [
{
id: "s1",
title: "",
questions: [
{
id: "nps",
type: "scale",
title: "Would you recommend us?",
range: { min: 0, max: 10, nps: true },
},
{
id: "grid",
type: "matrix",
title: "How satisfied are you with each part?",
options: [
{ id: "speed", label: "Speed" },
{ id: "docs", label: "Docs" },
],
columns: [
{ id: "1", label: "Poor" },
{ id: "2", label: "Fair" },
{ id: "3", label: "Good" },
],
},
{
id: "rank",
type: "ranking",
title: "What do you want next?",
options: [
{ id: "api", label: "A public API" },
{ id: "app", label: "A mobile app" },
{ id: "sso", label: "Single sign-on" },
],
},
],
},
],
};
const orders = [
["api", "app", "sso"],
["app", "api", "sso"],
["sso", "api", "app"],
];
const responses: FormResponse[] = Array.from({ length: 18 }, (_, i) => ({
id: `r${i + 1}`,
answers: {
nps: [10, 9, 8, 7, 10, 6, 9, 3, 10, 8, 9, 5][(i * 5) % 12]!,
grid: {
speed: ["3", "3", "2", "3", "1", "3"][i % 6]!,
docs: ["2", "3", "3", "1", "2", "3", "2"][i % 7]!,
},
rank: orders[(i * 7) % 3]!,
},
}));
export default function Nps() {
return <ResponseSummary schema={schema} responses={responses} />;
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
schema | FormSchema | — | { version: 1, title, description?, sections: { id, title, description?, showIf?, questions: FormQuestion[] }[], submitLabel?, thanks? }. Plain data: store it as JSON. |
responses | { id, submittedAt?, answers }[] | — | One per respondent. A conditional question is counted only for the responses that were shown it. |
label | string | "Responses" | Names the summary for assistive technology. |
textLimit | number | 4 | How many text answers show before Show all. |
className | string | — | Extra classes. |