Skip to content

Question Card

One quiz question to answer: pick one, pick many, true or false, or type it. Keys 1 to 9 pick, Enter checks, and the verdict and explanation open below.

On this page
Used for
  • A quiz question
  • A knowledge check in a lesson
  • A poll with a right answer
  • A flashcard that checks typing

Examples

Multiple choice with partial credit

True or false, and a typed answer

Reveal at the end

Installation

npx knowns-ui@latest add question-card
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

questionrequired
QuizQuestion
{ id, kind, prompt, choices?, answer, explanation?, points?, timeLimitSec? } from lib/knowns/quiz. kind is single, multi, truefalse or short.
value / defaultValue / onValueChange
string[]
Default[]
The picked choice ids, or the typed text as the first item for a short question.
submitted / defaultSubmitted
boolean
Defaultfalse
Whether the answer is handed in. It locks the card. Controlled for a review screen.
onSubmit
(value, grade) => void
Called when the answer is handed in. grade has correct, fraction, points, max, hits, extras and misses.
reveal
boolean
Defaulttrue
Show right and wrong after submitting. false locks the answer with no verdict, for a quiz that reveals at the end.
number
number
Shows Question 3 above the prompt.
showKeys / submitLabel
boolean / string
Defaulttrue / Check answer
The 1 to 9 key on each choice, and the button text.
actions
ReactNode
Extra content next to the submit button, such as a Next button.
autoFocus / disabled
boolean
Defaultfalse
Focus the first control on mount; or lock everything.
Keyboard
keys
1 to 9 pick a choice (T and F for true or false), Enter checks the answer, the arrow keys and Space work as on real radio buttons and checkboxes. In the text box of a short question digits are typed.
Screen readers
live region
Right and wrong are announced as Correct, Partly right or Not quite, with the right answer. A wrong or missed choice also says so in its own label.
Motion
180ms ease-out
The verdict folds open once; choice colours change in 120ms. Nothing plays on first render or with reduced motion.

What it handles

  1. 01Renders single choice, multiple choice, true or false and a typed answer from one question object.
  2. 02Picks with the keys 1 to 9 (T and F for true or false), hands the answer in with Enter, and keeps the arrow keys and Space of real radio buttons and checkboxes.
  3. 03Grades with partial credit for multiple choice and shows the right answer, the points and your explanation in a verdict that opens below.
  4. 04Marks right and wrong with a glyph as well as colour, and says Correct or Not quite and the right answer through a polite live region.
  5. 05Locks after the answer is handed in, or locks without a verdict when the quiz reveals at the end.
  6. 06Works controlled for a review screen: pass the saved value and submitted, and it shows the verdict with no controls.

States

Pick
The choice takes the selected border and fill
120ms, ease-out
Check answer
The verdict and explanation fold open
180ms, ease-out
Right or wrong
Green or red border and a check or cross
120ms, ease-out
First render
Nothing plays
none
Reduced motion
The verdict appears at once
0ms

Works with

When to use

When to use

  • One question in a lesson or a knowledge check, where the person answers and sees at once if they were right and why.
  • A true or false, multiple choice or typed question you build the page around yourself.

When not to use

  • Running a whole quiz with progress, a timer and a score: use Quiz Player.
  • A choice with no right answer, such as a setting: use Radio Group.
  • Writing the questions: use Quiz Builder.

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 Question Card to my app and wire it to my own data.
  • I need one question in a lesson or a knowledge check, where the person answers and sees at once if they were right and why. Set that up with the Knowns UI Question Card.
  • Which Question Card props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "question-card" }) and search_docs({ query: "question card" }).

Need help?

Stuck on Question Card, or found something off? We read every message.