shadcn.io is not affiliated with official shadcn/ui
Comment Posted Toast Success Block for React
A comment confirmation drawn in place: a shared document page beside a three-comment thread with a real composer; posting appends the comment and raises a toast with View thread and Undo, which takes it out again.
Installation
Overview
Confirm a comment where it was written, not on a blank page, with this panel for React with Base UI. It is the Threadwick stage after someone posts on a shared page: a header over one framed stage ruled by Guides. On the start side a greyscale page marks the line the thread is about with a count; on the other a thread of three comments in a scrolling region and a composer with a Textarea and a Shine Button Post. Posting appends the comment and raises a toast in the stage: "Comment posted", with View thread, which scrolls to it, and Undo, which takes it out. Because the toast has an action it never times out. For documents, issue threads, review tools and anywhere a post deserves an answer.
FAQ
What stays in the page, and how do I wire it for real?
Nothing is sent. The page, the three comments and the people are typed constants, a posted comment lives in the page's state, and the toast says no one was notified. To wire it, post to your comments endpoint, append what it returns, and make Undo delete the comment (or hold the send for a few seconds) before notifying anyone.
Why is the toast drawn in the stage and not the page's toaster?
A portalled toaster sits at the corner of the whole window, outside the frame, and would not show in the preview. Here it is drawn at the foot of the stage so the block shows both states. It is the block's one live region, so a screen reader hears "Comment posted" once. In your app, raise it through your toaster with the same two actions.
What does Undo do?
It removes the last comment this person posted, swaps the toast to "Comment removed" with a Dismiss button, and returns focus to the composer. The thread never changes height: it scrolls inside a region of fixed size.
What if I post nothing?
The composer refuses an empty post in words beside the button, keeps the focus in the field and adds no toast. The hint line returns once you type.
Related
- Pro
Undo Toast Notification
ToastsAn invoicing app's list with a delete on every row: the toast says how many are deleted with an Undo, a second delete merges into the same toast and starts its wait again, and Restore deleted on the page does the same as Undo.
- Pro
A messaging app's thread with a message toast that carries a Reply action: it never times out, Reply takes it away and puts the sender in the composer with focus, and Receive a message raises the next of three, up to three at once.
- Pro
File Comments Notification
ConversationsReview comments grouped by file, each quoting the line it is about, with a Resolve toggle that moves a comment into a collapsed resolved group and back.
- Pro
Mention Lenses Notification
Sort and findMentions seen through four chips (All, @you, @team, @channel) with counts, each snippet marking its tag, naming its channel and offering Jump to message.
- Pro
A full-height confirmation for a published post: its address in a read-only field with a real copy button, a greyscale card showing how the link looks when shared, and links for three places to share it with two-letter tiles.
- Pro
A confirmation after sending a feature request: the request with a four-word pipeline from Triage to Shipped, and four similar requests, each with a status and a Vote toggle that counts once and can be taken back.