Skip to content

[Help]: How do I add navigation buttons? #868

Closed Answered by davidjerleke
ItsTerm1n4l asked this question in Help
Discussion options

You must be logged in to vote

Hi @ItsTerm1n4l,

Thanks for your question. Use the scrollTo method:

<script>
  import emblaCarouselSvelte from 'embla-carousel-svelte'

  let emblaApi
  let options = { loop: false }

  // Attach this where you want and pass an index
  function scrollTo(index) {
    emblaApi?.scrollTo(index)
  }

  function onInit(event) {
    emblaApi = event.detail
  }
</script>

<div
  class="embla"
  use:emblaCarouselSvelte="{{ options }}"
  on:emblaInit="{onInit}"
>
  <div class="embla__container">
    <div class="embla__slide">Slide 1</div>
    <div class="embla__slide">Slide 2</div>
    <div class="embla__slide">Slide 3</div>
  </div>
</div>

Here’s a get started guide for the Svelte package.

And on…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@ItsTerm1n4l
Comment options

@davidjerleke
Comment options

@ItsTerm1n4l
Comment options

@ItsTerm1n4l
Comment options

@davidjerleke
Comment options

Answer selected by ItsTerm1n4l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
resolved This issue is resolved question Question about how to achieve something svelte Issue is related to Svelte
2 participants