Skip to content
ghostui

Preview

An acceptance criterion links a userto an observable.

Design guidance

Use typed blanks for open answers and a choice bank for a finite set. Give each slot an accessible label. The sentence supplies visible context; empty answers can remain text-free.

Choice values identify consumable answers. A selected choice stays visible and disabled in the bank. Click or tap another choice to replace it. Focus a blank and press its option key to assign, or Delete/Backspace to clear. Drag a choice onto an eligible blank to assign it directly. Keyboard dragging uses Enter to start, Tab between eligible targets, Enter to drop and Escape to cancel.

Keep the answer key and checking action in your application. Supply status only after checking, and clear it when an answer changes. Put the checking action inside FillInTheBlank; result feedback and explicitly revealed hints follow it.

Installation

Install

Basic usage

Structures

parts contains text and stable, named slots. Typed answers compose Input. Choice answers compose a read-only Input and Button bank, or Select for the popup presentation. A hidden native select keeps bank answers available to form submission and required validation. The bank follows the focused choice slot.

children holds caller-owned actions below the sentence and bank. Feedback follows the actions. Dragging uses one internal behavior owner shared with RankingField; assignment and grading stay with their respective owners.

Examples

Typed blanks

Use open text when the answer cannot be represented by a fixed choice list. Inputs use the shared default control height. Answer text stays centered. Boxes start at 100px, grow with their text, and stay within the sentence width. Empty boxes are dashed; filled boxes are solid.

An acceptance criterion links a userto an observable.

Choice answer bank

Keep finite choices visible below the sentence. Choices have dotted borders and can be clicked, selected by key, or dragged into the answer box.

To learn whether people can complete a task, run a.

Multiple choice targets

Focus either blank to choose its answer. The same option value can be used once across the sentence. Replacing or clearing an answer makes its old choice available again.

A useful review checks thebefore the.

Underline typed answers

Use variant="underline" to give answers only a bottom boundary. The line stays thin: subtle at rest, darker on hover, and the theme accent on focus. Hover and focus add no background fill. Checked states use their result color.

An acceptance criterion links a userto an observable.

Underline choices

The same variant applies to the answer box and bank. Empty answer lines are dashed; choice lines are dotted.

To learn whether people can complete a task, run a.

Horizontal wrap

The default choiceLayout="wrap" moves choices onto another line when space runs out.

To learn whether people can complete a task, run a.

Vertical choices

Use choiceLayout="vertical" for a list of choices.

To learn whether people can complete a task, run a.

Horizontal scroll

Use choiceLayout="scroll" to keep choices in one bounded row. Keyboard focus brings each choice into view.

To learn whether people can complete a task, run a.

Select presentation

Use a popup when choices need less space. The values and single-use rule stay the same; dragging applies to the bank presentation.

A component keeps itswith one canonical source.

Optional answer checking

The caller supplies the button and evaluates the answers. Basic use has no checking action.

An acceptance criterion links a userto an observable.

Correct answer

Apply status="correct" to checked answers. Editing clears the caller's result.

An acceptance criterion links a userto an observable.

Incorrect answer

Apply status="incorrect" to the wrong answer. This example gives feedback without revealing the answer key.

An acceptance criterion links a userto an observable.

Incorrect answer with a hint

Set a slot's hint and showHint when your application chooses to reveal help. The hint appears below Check answer and stays associated with its input.

An acceptance criterion links a userto an observable.

Required answers

Named values participate in native forms. Required empty answers prevent submission.

A shipment needs a

Disabled answers

Use disabled to preserve a visible answer while preventing changes.

A shipment needs a

Shared dragging behavior

RankingField uses the same drag transport for reordering. Its move controls remain available as an alternative.

  1. Usability
  2. Reliability
  3. Performance

API reference

Text parts use type="text" and text. Slots use type="slot", id, kind="typed" | "choice", and label. Optional slot properties are placeholder, disabled, required, status="correct" | "incorrect", hint, and showHint (false by default).

Choice slots accept options with non-empty unique value, label, optional keyboard key, and optional disabled. The same value across choice slots identifies the same single-use answer. Keys default to A–Z for the first 26 choices; use explicit single-character keys for longer banks. Typed text does not consume choices. Caller-supplied values are preserved; pass valid choice values and avoid duplicate controlled assignments.

Native div attributes, className, children and the div ref are forwarded. Bank shortcuts apply only to a focused read-only answer control and ignore modified or composing keys. No answer key, automatic grading or hint reveal is built in.