How to show carousel dots in AMP?

In this carousel, how do I show dots?

<amp-carousel layout=fixed-height height=400 type=slides autoplay controls loop arrows dots='.'>
  <amp-img src="img/slaid.jpg" layout=fixed-height height=400></amp-img>
  <amp-img src="img/slaid.jpg" layout=fixed-height height=400></amp-img>
</amp-carousel>

Upvotes: 2

Views: 4295

Answers (2)

Kim T
Kim T

Reputation: 6454

There is an example in this codelab: https://codelabs.developers.google.com/codelabs/advanced-interactivity-in-amp/index.html

The final code is here:

<amp-carousel type="slides" layout="fixed-height" height=250 id="carousel" on="slideChange:AMP.setState({selected: {slide: event.index}})">
  <amp-img width=200 height=250 src="./shirts/black.jpg" [src]="shirts[selected.sku].image"></amp-img>
  <amp-img width=300 height=375 src="./shirts/black.jpg" [src]="shirts[selected.sku].image"></amp-img>
  <amp-img width=400 height=500 src="./shirts/black.jpg" [src]="shirts[selected.sku].image"></amp-img>
</amp-carousel>
<p class="dots">
  <span [class]="selected.slide == 0 ? 'current' : ''" class="current"></span>
  <span [class]="selected.slide == 1 ? 'current' : ''"></span>
  <span [class]="selected.slide == 2 ? 'current' : ''"></span>
</p>

https://github.com/googlecodelabs/advanced-interactivity-in-amp/blob/master/static/final.html

Upvotes: 2

ReyAnthonyRenacia
ReyAnthonyRenacia

Reputation: 17651

Navigational dots can be added by indicating it in the CSS Custom Properties, <style></style>. Here's a Github sample from Styling/Theming with AMP:

<head>
  <style>
    amp-carousel {
      --arrow-color: green;
      --dots: {
        opacity: 50%;
        color: blue;
      }
    }
  </style>
</head>

<body>
  <amp-carousel width=500 height=500>
    <div>
      <amp-img width=500 height=500 src="https://placekitten.com/g/500/500">
      </amp-img>
    </div>
    <div>
      <amp-img width=500 height=500 src="https://placekitten.com/g/500/500">
      </amp-img>
    </div>
  </amp-carousel>
</body>

You can also check this SO thread for additonal reference.

Upvotes: 0

Related Questions