Displays a Twitter Tweet or Moment.
|Supported Layouts||fill, fixed, fixed-height, flex-item, intrinsic, nodisplay, responsive|
|Examples||Annotated code example for amp-twitter|
amp-twitter component allows you to embed a Tweet or Moment for the specified Twitter ID.
Here's an example of a basic embedded Tweet:
Twitter does not currently provide an API that yields fixed aspect ratio for embedded Tweets or Moments. Currently, AMP automatically proportionally scales the Tweet or Moment 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 or Moment 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 or Moment doesn't exist or has been deleted.
Visit the Placeholders & fallbacks guide to learn more about how placeholders and fallbacks interact for the
Example: Specifying a placeholder
Example: Specifying a placeholder and a fallback
|data-tweetid / data-momentid / data-timeline-source-type (required)||The ID of the Tweet or Moment, or the source type if a Timeline should be displayed. In a URL like https://twitter.com/joemccann/status/640300967154597888, |
|data-timeline-* (optional)||When displaying a timeline, further arguments need to be provided in addition to |
|data-* (optional)||You can specify options for the Tweet, Moment, or Timeline appearance by setting |
|common attributes||This element includes common attributes extended to AMP components.|
See amp-twitter rules in the AMP validator specification.
You've read this document a dozen times but it doesn't really cover all of your questions? Maybe other people felt the same: reach out to them on Stack Overflow.Go to Stack OverflowFound a bug or missing a feature?
The AMP project strongly encourages your participation and contributions! We hope you'll become an ongoing participant in our open source community but we also welcome one-off contributions for the issues you're particularly passionate about.Go to GitHub