shadcn.io is not affiliated with official shadcn/ui
Unread Divider Comments Block for Svelte
A fifteen-comment thread in a held scroll region with a divider before the first unread comment, a Jump to first unread button, Mark as seen and an All or Replies to me filter.
Installation
Overview
Pick a long thread back up where you stopped reading, with this unread-divider discussion for Svelte with Ark UI. A compact header names the thread and holds an All or Replies to me Toggle Group. The frame has a band with two buttons, then the thread in a scroll region that keeps its height. A divider reads "6 new since your last visit, Tue 13 Oct, 08:30" right before the first comment you have not seen, and each of those comments carries a New badge. "Jump to first unread" scrolls the region to the divider (never the page) and lands focus on it; once you are past it, the same button counts what is left, "4 more below", and takes you to the end. The primary Shine Button, Mark as seen, removes the divider and every New word. Switching to Replies to me redraws the divider for the replies only. A polite status line says what happened. It is built from Toggle Group, Shine Button, Button, Avatar, Badge and Guides, with a CSS entrance only. For forums, long review threads and any discussion people come back to.
FAQ
How do I fill it with my own thread?
Edit PEOPLE and REMARKS (an id, who wrote it, who it answers in to, an ISO at and the body), ME for the person using the page and LAST_VISIT with its printed text. A comment is new when its at is after LAST_VISIT, so nothing else needs flagging. In a real app LAST_VISIT comes from the server, per person and per thread.
How does Jump to first unread work?
It measures the divider against the top of the scroll region and scrolls the region to it, smoothly unless the visitor prefers reduced motion, then focuses the divider so a keyboard user arrives there. After the divider is on screen, the button changes to a count of new comments below the visible part and scrolls to the end. When nothing is new it says "Nothing new" and stays in place, because the button never disappears.
What stays local?
What you have seen. Mark as seen only changes the page. To make it real, send the id of the newest comment you have read from the Mark as seen handler (or from a scroll-based read marker), store it per person and thread, and send it back as LAST_VISIT next time. Nothing refreshes on its own here; a live thread would add new comments to the end and update the count.
What does Replies to me do to the divider?
It filters the list to comments that answer ME, and the divider moves to the first new reply, with its own count. If none of those replies is new, the divider is not drawn. The region keeps its height in every case, and an empty filter shows a plain sentence in the same space.
Is it accessible?
The thread is a labelled scroll region you can reach with Tab and scroll with the arrow keys. The divider is a list item with a visible sentence, and the New badge is a word, not a colour. The toggle group names the filter, the buttons name their action, and a polite status line reports every change. Times use a machine-readable date and stay left to right inside a right-to-left page.