Tweet Button Parameter Reference

A Tweet Button supports pre-populating share text, hashtags, and a Twitter account reference. Associate related Twitter accounts to drive followers.

Tweet content parameters

Parameter Description Example
text Pre-populated text highlighted in the Tweet composer. custom share text
url URL included with the Tweet. https://dev.twitter.com/web/tweet-button
hashtags A comma-separated list of hashtags to be appended to default Tweet text. example,demo
via Attribute the source of a Tweet to a Twitter username. twitterdev
related A comma-separated list of accounts related to the content of the shared URI. twitterapi,twitter

Button display parameters

Customize your displayed Tweet Button size, button alignment, and more.

These visual parameters do not apply to Web Intents, which are styled separately by implementing sites.

Parameter Description Example
size When set to large, display a larger version of the button. Set to l for iframe. large
lang A supported Twitter language code. es
dnt When set to true, the button and its embedded page on your site are not used for purposes that include personalized suggestions and personalized ads. true

HTML data-* example

<a class="twitter-share-button"
  href="https://twitter.com/share"
  data-size="large"
  data-text="custom share text"
  data-url="https://dev.twitter.com/web/tweet-button"
  data-hashtags="example,demo"
  data-via="twitterdev"
  data-related="twitterapi,twitter">
Tweet
</a>

Iframe example

<iframe
  src="https://platform.twitter.com/widgets/tweet_button.html?size=l&url=https%3A%2F%2Fdev.twitter.com%2Fweb%2Ftweet-button&via=twitterdev&related=twitterapi%2Ctwitter&text=custom%20share%20text&hashtags=example%2Cdemo"
  width="140"
  height="28"
  title="Twitter Tweet Button"
  style="border: 0; overflow: hidden;">
</iframe>

JavaScript factory example

twttr.widgets.createShareButton(
  "https:\/\/dev.twitter.com\/web\/tweet-button",
  document.getElementById("tweet-container"),
  {
    size: "large",
    text: "custom share text",
    hashtags: "example,demo",
    via: "twitterdev",
    related: "twitterapi,twitter"
  }
);

Web Intent example

Tweet

<a href="https://twitter.com/share?
  url=https%3A%2F%2Fdev.twitter.com%2Fweb%2Ftweet-button&
  via=twitterdev&
  related=twitterapi%2Ctwitter&
  hashtags=example%2Cdemo&
  text=custom%20share%20text">
Tweet
</a>