Description Displays a Twitter Tweet.
Required Script <script async custom-element="amp-twitter" src="https://cdn.ampproject.org/v0/amp-twitter-0.1.js"></script>
Supported Layouts fill, fixed, fixed-height, flex-item, nodisplay, responsive
Examples Annotated code example for amp-twitter

Behavior

The amp-twitter component allows you to embed a Tweet for the specified Twitter ID.

Here's an example of a basic embedded Tweet:

Show full code

Appearance

Twitter does not currently provide an API that yields fixed aspect ratio for embedded Tweets. Currently, AMP automatically proportionally scales the Tweet to fit the provided size, but this may yield less than ideal appearance. You might need to manually tweak the provided width and height. Also, you can use the media attribute to select the aspect ratio based on the screen width.

Placeholders & fallbacks

An element marked with a placeholder attribute displays while the content for the Tweet is loading or initializing. Placeholders are hidden once the AMP component's content displays. An element marked with a fallback attribute displays if amp-twitter isn't supported by the browser or if the Tweet doesn't exist or has been deleted.

Visit the Placeholders & fallbacks guide to learn more about how placeholders and fallbacks interact for the amp-twitter component.

Example: Specifying a placeholder

Show full code

Example: Specifying a placeholder and a fallback

Show full code

Attributes

data-tweetid (required)

The ID of the Tweet. In a URL like https://twitter.com/joemccann/status/640300967154597888, 640300967154597888 is the tweetID.

data-* (optional)

You can specify options for the Tweet appearance by setting data- attributes. For example, data-cards="hidden" deactivates Twitter cards. For details on the available options, see Twitter's docs.

Show full code
common attributes

This element includes common attributes extended to AMP components.

Validation

See amp-twitter rules in the AMP validator specification.