Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Facebook Comments

ProNew

The comment thread in Facebook's style: chat bubbles, Like and Reply links, short timestamps and a Log in with Facebook button. A preset of Comments that needs no SDK.

Installation

pnpm dlx shadcn@latest add @viewport/facebook-comments

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
comments*Comment[]

The comments to start with; see `Comments`.

—
userCommentAuthor

The signed-in visitor. Without one, the composer asks for a name.

—
sort"top" | "newest" | "oldest"

The order to start in.

"top"
pageSizenumber

Comments shown before "Show more".

5
onSignIn() => void

Adds a "Log in with Facebook" button above the guest composer.

—
onSubmit(draft: CommentDraft) => void | Comment | Promise<void | Comment>

Called with a new comment or reply. Return a promise to show progress; reject it to show the error.

—
onLike(commentId: string, active: boolean) => void

Called when the visitor likes or unlikes a comment.

—
hrefstring

Address of the Facebook page or post the thread belongs to, linked from the footer.

—
loadingboolean—
disabledboolean—
classNamestring—

Accessibility

  • Inherits the Comments semantics: `article` per comment, nested lists for replies, a labelled composer form and a live region for new posts.
  • Like is a toggle button with `aria-pressed`; the like count on each bubble is read as "18 reactions".
  • No Facebook script, iframe or cookie is loaded; the footer link is the only thing that leaves your site.