shadcn.io is not affiliated with official shadcn/ui
Similar Threads Comments Block for Svelte
A question title box that finds similar threads as you type: ranked matches with shared words marked, an accepted answer to open, This answers it, and Still ask to post the question.
Installation
Overview
Stop duplicate questions before they are posted, with this similar-threads check for Svelte with Ark UI. A compact header sits over one framed panel. A title Input starts with a question already typed. As you type, the words that matter (small words removed, plurals folded) are matched against six typed threads, and the best three appear under "Already asked" with a label (Strong match or Possible match), how many answers each has, and the shared words marked in the title. Open shows that thread's accepted answer in a reserved band, where This answers it clears the draft. The one primary, a Shine Button, is Still ask: it posts your question to the top of the recent questions list. The results area keeps room for three rows, and an Empty state names what you typed when nothing matches. It is built from Input, Badge, Button, Empty, Field, Shine Button and Guides, with a CSS entrance only. For forums, help centres and any form that asks a question.
FAQ
How are the matches ranked?
Both titles are cut into words, small words and very short ones are dropped, a trailing s is folded (runs and run match), and the threads are ranked by how many words they share, then by answers. A thread needs two shared words (one if your title has only one useful word). Four shared words, or every word of a short title, is a Strong match. The shared words are marked in each result.
Can I use search or embeddings instead?
Yes. Replace matchesOf(title, corpus) with a call to your search that returns the same list of { thread, shared, strength }. Keep marking what matched: it is what lets the asker judge a result at a glance. Debounce the call and keep the results area at a fixed height so typing never moves the form.
What stays local?
The six threads and your question. Still ask adds your title to the recent questions list in the page and says "Posted in this demo. Nothing was sent." To make it real, post the title (and a body field) from ask to your server, and link it to the thread a person said did not answer it.
What does it say when nothing matches?
An empty state: "Type your title" before you type anything, and "Nothing similar" with your own words quoted once you have. A title under ten characters cannot be posted: Still ask explains that in a problem line under the box.