A Mention button is a special type of Tweet button to encourage a new Tweet focused on an interaction between the user and a mentioned account. A Tweet beginning with @username do not appear on the author’s timeline in the default view; the Tweet 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 Twitter for Websites JavaScript to discover the element and enhance the link into a Mention button. Set a href attribute value of https://twitter.com/intent/tweet to create a link to the Twitter web intent composer.
<a class="twitter-mention-button"
href="https://twitter.com/intent/tweet">
Tweet</a>
2. 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://twitter.com/intent/tweet?screen_name=TwitterDev">
Tweet to @TwitterDev</a>
3. Asynchronously load Twitter 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 Twitter’s CDN.
JavaScript factory function
Twitter’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 Tweet button JavaScript factory function.
twttr.widgets.createMentionButton(
"TwitterDev",
document.getElementById("container"),
{
size:"large"
}
);