Author a quiz: add, remove and reorder questions, pick the kind, mark the right answers, add an explanation, points and a time limit, import and export JSON. All from the keyboard.
- A teacher's quiz editor
- A course admin
- A question bank
- An assessment tool
Examples
Installation
Installation is part of Pro
Pro components install from a licensed registry. The live preview stays open to everyone.
Props
- value / defaultValue / onChange
Quiz- Default
empty quiz - The quiz being edited: { id, title, questions }. Controlled or not. onChange gets the whole quiz after every edit, valid or not.
- onGenerate
(text, signal?) => Promise<QuizQuestion[]>- Shows Generate from text. Call your own model or service and return questions; they are added at the end with ids that do not clash. A rejected promise shows its message. The kit makes no model calls.
- generateHint
ReactNode- Default
a short line - The text above the generate box.
- validateQuiz / validateQuestion
(…) => string[]- From lib/knowns/quiz: the plain-language problems that stop a quiz from being asked or graded. Use them to block saving.
- parseQuiz / serializeQuiz
(text) / (quiz)- The JSON the Import and Export panels use. parseQuiz returns the quiz or the reasons it could not be read.
- Keyboard
keys- Arrow up and down walk the questions, Alt and the arrows move the open one. In a choice, Enter adds the next one and Backspace in an empty one removes it. In a short answer, the same for accepted texts.
- Screen readers
live region- Adding, removing and moving a question are announced with its new position. Each choice and its right mark have their own labels.
- Motion
180ms ease-out- Import, export and generate fold open. Nothing plays on first render or with reduced motion.
| Prop | Type | Default | Description |
|---|---|---|---|
| value / defaultValue / onChange | Quiz | empty quiz | The quiz being edited: { id, title, questions }. Controlled or not. onChange gets the whole quiz after every edit, valid or not. |
| onGenerate | (text, signal?) => Promise<QuizQuestion[]> | - | Shows Generate from text. Call your own model or service and return questions; they are added at the end with ids that do not clash. A rejected promise shows its message. The kit makes no model calls. |
| generateHint | ReactNode | a short line | The text above the generate box. |
| validateQuiz / validateQuestion | (…) => string[] | - | From lib/knowns/quiz: the plain-language problems that stop a quiz from being asked or graded. Use them to block saving. |
| parseQuiz / serializeQuiz | (text) / (quiz) | - | The JSON the Import and Export panels use. parseQuiz returns the quiz or the reasons it could not be read. |
| Keyboard | keys | - | Arrow up and down walk the questions, Alt and the arrows move the open one. In a choice, Enter adds the next one and Backspace in an empty one removes it. In a short answer, the same for accepted texts. |
| Screen readers | live region | - | Adding, removing and moving a question are announced with its new position. Each choice and its right mark have their own labels. |
| Motion | 180ms ease-out | - | Import, export and generate fold open. Nothing plays on first render or with reduced motion. |
What it handles
- 01Adds, removes and reorders questions; Alt and the arrow keys move one, plain arrows walk the list.
- 02Switches a question between single choice, multiple choice, true or false and short answer, keeping what still fits.
- 03Marks the right choices, takes several accepted texts for a short answer, and adds an explanation, points and a time limit.
- 04Enter in a choice adds the next one and Backspace in an empty one removes it, so a question can be typed without the mouse.
- 05Says what is missing under the question and as a count in the footer; the quiz is always emitted so you decide what blocks saving.
- 06Imports and exports JSON, and takes an optional async function that turns pasted text into questions. The kit makes no model calls.
States
- Reorder
- The question takes its new place in the list
- none
- Panels
- Import, export and generate fold open
- 180ms, ease-out
- Pick a kind
- The kind control fills
- 120ms, ease-out
- First render
- Nothing plays
- none
- Reduced motion
- Panels open at once
- 0ms
| State | What moves | Timing |
|---|---|---|
| Reorder | The question takes its new place in the list | none |
| Panels | Import, export and generate fold open | 180ms, ease-out |
| Pick a kind | The kind control fills | 120ms, ease-out |
| First render | Nothing plays | none |
| Reduced motion | Panels open at once | 0ms |
Works with
When to use
When to use
- Authoring a quiz: questions of four kinds, right answers, explanations, points and time limits, with JSON import and export.
- An admin screen where the questions may come from text through your own model or service.
When not to use
- Taking the quiz: use Quiz Player.
- One question as a student sees it: use Question Card.
- Putting a plain list in order by dragging: use Sortable.
Using with AI
Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:
- Add the Knowns UI Quiz Builder to my app and wire it to my own data.
- I need authoring a quiz: questions of four kinds, right answers, explanations, points and time limits, with JSON import and export. Set that up with the Knowns UI Quiz Builder.
- Which Quiz Builder props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "quiz-builder" }) and search_docs({ query: "quiz builder" }). Pro props, full examples and source come back once your license key is in the MCP config.