Skip to main content
A Mention button is a special type of Post button to encourage a new Post focused on an interaction between the user and a mentioned account. A Post beginning with @username do not appear on the author’s timeline in the default view; the Post will only appear in the home timeline of the author’s followers if the viewer follows both the author and the mentioned user. Read more about @replies and @mentions.

How to add a Mention Button to your website

  1. Create a new anchor element with a twitter-mention-button class to allow the X for Websites JavaScript to discover the element and enhance the link into a Mention button. Set a href attribute value of https://x.com/intent/tweet to create a link to the X web intent composer.
<a class="twitter-mention-button"
  href="https://x.com/intent/tweet">
Post</a>
  1. Add the username of the mentioned account as a screen_name query parameter value and a component of the anchor element’s inner text.
<a class="twitter-mention-button"
  href="https://x.com/intent/tweet?screen_name=XDevelopers">
Post to @XDevelopers</a>
  1. Asynchronously load X for Websites using our loading snippet. The JavaScript snippet will check for an existing version on the page, initialize a function queue to be executed once the widgets JavaScript has loaded, and load the widgets JavaScript asynchronously from X’s CDN.

JavaScript factory function

X’s widget JavaScript library supports dynamic insertion of a Mention button using the twttr.widgets.createMentionButton function. Pass a username, target container element, and the same options supported by the Post button JavaScript factory function.
twttr.widgets.createMentionButton(
  "XDevelopers",
  document.getElementById("container"),
  {
    size:"large"
  }
);