<amp-selector id="sampleSelector" class="" on="select:AMP.setState({selectedTab: event.targetOption})">
<button class="button " option="1">
Dude!
</button>
<button class="button " option="2">
Rad!
</button>
<button class="button " option="3">
Neat!
</button>
</amp-selector>
<amp-state id="sampleSelectorState">
<script type="application/json">
{
selectedTab: false
}
</script>
</amp-state>
<amp-selector
id="{{id}}"
class="{{modifier}}"
{{#if role}}role="{{role}}"{{/if}}
{{#if selectorlayout}}layout="{{selectorlayout}}"{{/if}}
{{#if name}}name="{{name}}"{{/if}}
{{#if on}}on="{{on}}"{{/if}}
{{#if multiple}}multiple{{/if}}
{{#if selected}}[selected]="{{statevalue}}"{{/if}}
>
{{> @children}}
</amp-selector>
{{#if state}}
<amp-state id="{{id}}State">
<script type="application/json">
{
{{state}}: {{statevalue}}
}
</script>
</amp-state>
{{/if}}
{
"id": "sampleSelector",
"modifier": null,
"style": null,
"role": null,
"selectorlayout": null,
"on": "select:AMP.setState({selectedTab: event.targetOption})",
"state": "selectedTab",
"statevalue": "false",
"multiple": null,
"selected": null,
"children": [
{
"component": "button",
"context": {
"text": "Dude!",
"option": 1
}
},
{
"component": "button",
"context": {
"text": "Rad!",
"option": 2
}
},
{
"component": "button",
"context": {
"text": "Neat!",
"option": 3
}
}
]
}
amp-selector {
[role="tabpanel"] {
display: none;
}
[selected] + [role="tabpanel"] {
display: block;
}
}
Represents a control that presents a menu of options and lets the user choose from it.
More information can be found in the AMP documentation.
<script async custom-element="amp-selector" src="https://cdn.ampproject.org/v0/amp-selector-0.1.js"></script>
The AMP selector is a control that presents a list of options and lets the user choose one or many options; the contents of the options aren’t just limited to text.
<li option='value'></li>
).<li option='d' disabled></li>
).<li option='b' selected></li>
).AMPSelector is accessible by keyboard and screenreader users according to WCAG 2.0 guidelines.