99 lines (90 sloc) 3.84 KB
"comment": "amp-sidebar needs to be the first element after the body tag, this is currently not possible the way examples are structured",
"skipValidation": true
#### Introduction
A sidebar provides a way to display meta content intended for temporary access (navigation links, buttons, menus, etc.). The sidebar can be revealed by a button tap while the main content remains visually underneath.
<!-- -->
<!doctype html>
<html ⚡>
<meta charset="utf-8">
<script async src=""></script>
<!-- #### Setup -->
Import the `amp-sidebar` component.
<script async custom-element="amp-sidebar" src=""></script>
<script async custom-element="amp-fit-text" src=""></script>
<link rel="canonical" href="<%host%>/components/amp-sidebar/">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<style amp-custom>
amp-sidebar {
width: 250px;
padding-right: 10px;
.amp-sidebar-image {
line-height: 100px;
.amp-close-image {
top: 15px;
left: 225px;
cursor: pointer;
li {
margin-bottom: 20px;
list-style: none;
button {
margin-left: 20px;
<!-- #### Basic Usage -->
There can be only one `amp-sidebar` in an AMP document. The `amp-sidebar` should be a direct child of the `<body>`. It must have a layout of nodisplay.
The`amp-sidebar` may not contain any AMP Elements except for `amp-accordion`, `amp-img` and `amp-fit-text`.
`amp-fit-text` expands or shrinks its font size to fit the content within the space given to in the menu.
<amp-sidebar id='sidebar' layout="nodisplay" side="right">
<amp-img class='amp-close-image' src="/img/ic_close_black_18dp_2x.png" width="20" height="20" alt="close sidebar" on="tap:sidebar.close" role="button" tabindex="0"></amp-img>
<li><a href="/">Home</a></li>
<li> Nav item 1</li>
<amp-fit-text width="220" height="20" layout="responsive" max-font-size="24">
Nav item 2 - &lt;amp-fit-text&gt;
<amp-fit-text width="220" height="20" layout="responsive" max-font-size="24">
Nav item 3 - &lt;amp-fit-text&gt; longer text
<li> Nav item 4 - Image<amp-img class='amp-sidebar-image' src="/img/favicon.png" width="20" height="20" alt="an image"></amp-img></li>
<li> Nav item 5</li>
<li> Nav item 6</li>
<!-- #### Sidebar Actions -->
Click to toggle the sidebar.
<button on='tap:sidebar.toggle'>Toggle sidebar</button>
Click to open the sidebar.
<button on=''>Open sidebar</button>
Click to close the sidebar.
<button on='tap:sidebar.close'>Close sidebar</button>