image-carousel-basic-ex-04
stackzero/image-carousel-basic-ex-04FreeExample
stackzero publishes no description for this item.
Install it
npx shadcn@latest add https://ui.stackzero.co/r/image-carousel-basic-ex-04.jsonSource
1"use client";23import { useState } from "react";4import ImageCarouselBasic, {5 CarouselImages,6} from "@/components/commerce-ui/image-carousel-basic";78const images: CarouselImages = [9 {10 title: "Speaker 1",11 url: "https://raw.githubusercontent.com/stackzero-labs/ui/refs/heads/main/public/placeholders/speaker-02.jpg",12 },13 {14 title: "Speaker 2",15 url: "https://raw.githubusercontent.com/stackzero-labs/ui/refs/heads/main/public/placeholders/speaker-03.jpg",16 },17 {18 title: "Speaker 3",19 url: "https://raw.githubusercontent.com/stackzero-labs/ui/refs/heads/main/public/placeholders/speaker-04.jpg",20 },21];2223export default function ImageCarousel_Basic_Ex_04() {24 const [selectedIndex, setSelectedIndex] = useState(0);2526 return (27 <div className="space-y-8">28 <div>29 <div className="mb-4 flex w-full flex-wrap items-center justify-between gap-2">30 <button31 className="cursor-pointer rounded border px-3 py-1"32 onClick={() => setSelectedIndex(Math.max(0, selectedIndex - 1))}33 >34 Previous35 </button>36 <span className="font-mono">Current Slide: {selectedIndex + 1}</span>37 <button38 className="cursor-pointer rounded border px-3 py-1"39 onClick={() =>40 setSelectedIndex(Math.min(images.length - 1, selectedIndex + 1))41 }42 >43 Next44 </button>45 </div>46 <ImageCarouselBasic47 images={images}48 imageFit="contain"49 selectedIndex={selectedIndex}50 onSlideChange={setSelectedIndex}51 />52 </div>53 </div>54 );55}
What it pulls in
npm packages
Other registry items
Files it writes
More from stackzero
All 112 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| address-02-block-exaddress-02-block-ex | stackzero | Examples | Free | 2 deps | |
| cart-01-block-excart-01-block-ex | stackzero | Examples | Free | 1 dep | |
| face-rating-basic-ex-01face-rating-basic-ex-01 | stackzero | Examples | Free | 1 dep | |
| face-rating-basic-ex-02face-rating-basic-ex-02 | stackzero | Examples | Free | 1 dep | |
| face-rating-basic-ex-03face-rating-basic-ex-03 | stackzero | Examples | Free | 1 dep | |
| face-rating-gradient-ex-01face-rating-gradient-ex-01 | stackzero | Examples | Free | 1 dep | |
| image-carousel-basic-ex-01image-carousel-basic-ex-01 | stackzero | Examples | Free | 1 dep | |
| image-carousel-basic-ex-02image-carousel-basic-ex-02 | stackzero | Examples | Free | 1 dep |
