Skip to content

[Help]: How can I track the selected index using ShadcnUI? #919

Answered by davidjerleke
Adamkaram asked this question in Help
Discussion options

You must be logged in to vote

Hi @Adamkaram,

Thanks for your question. You're mixing the Shadcn carousel logic with the bare Embla library logic. Shadcn is a layer on top of Embla so you should use their API instead.

I would recommend you to access the Embla API as demonstrated here in the Shadcn docs using the setApi prop:

"use client"

import React, { useState, useEffect, useCallback } from "react";
import { Card, CardContent } from "@/components/ui/card";
import {
  Carousel,
  CarouselContent,
  CarouselItem,
} from "@/components/ui/carousel";
import "animate.css"; // Import animate.css styles
import Autoplay from "embla-carousel-autoplay";
import Image from 'next/image'

export default function Home() {
  const [api

Replies: 5 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by Adamkaram
Comment options

You must be logged in to vote
6 replies
@Adamkaram
Comment options

@davidjerleke
Comment options

@Adamkaram
Comment options

@davidjerleke
Comment options

@Adamkaram
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
question Question about how to achieve something missing test case or details Issue is missing important details or a test case that reproduces the problem
2 participants