inline answers
a suggestion that takes correction where it stands. one word swaps the line for plain answers, and nothing else on the page moves.
bunx --bun shadcn@latest add @mk/inline-answersexample
press wrong?. the answers take the line’s place, and wrong? stays as the lead-in that closes them. choosing an answer closes them too, and focus goes back to wrong?, as it does on escape.
the words under the slot stay put.
the words under the slot stay put.
open
an answer that needs one more word asks for it there: wrong day stays as its lead-in, and its own answers follow the arrow. the second click of a double click counts for nothing, because the answers can land under the pointer.
on a phone
each answer is a 44 px box, and a second row sits a whole target below the first, so no two hit areas overlap. the row keeps to the line’s first row, and the job’s actions stay where they were.
parts
InlineAnswers- holds the open state. its slot belongs to the parent, which holds the height. key it to the suggestion, so a new one starts closed.
open,defaultOpenandonOpenChangeare there for a ship that drives it. InlineAnswersLine- the line the answers replace.
InlineAnswersTrigger- the word that opens and closes them,
wrong?until you pass another. InlineAnswersList- the answers, as a group named by the trigger.
InlineAnswer- one plain answer, a button. choosing it closes the answers unless
onClickprevents default. InlineAnswersAsk- an answer that asks one more question.
questionis its word, and its children are the question’s ownInlineAnswers.