Command palette

@yasinsensoy/native

React Native · Components

Carousel

Swipeable slideshow: product images, promo cards, stories, logo strips.

7 exports

Live example

The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.

Preview

Code

import { Carousel, Image } from "@yasinsensoy/native";

<Carousel loop indicatorsPlacement="inside">
  {fotograflar.map((f) => (
    <Image key={f.id} src={f.src} alt={f.name} ratio={16 / 9} />
  ))}
</Carousel>

Events

  1. Events appear here when you interact with the preview.

Seamless loop: keep swiping past the end

Story style: bars fill up, holding pauses

Product strip: 1.5 / 3 / 4 cards by width, page by page

1 of 11

Logo stream (marquee): slows to a stop on hover, draggable

Controlled from outside (ref) and a custom active state

ref.current.next()

Import

import { Carousel } from "@yasinsensoy/native";

A value that varies with width: a single value or { min_width: value } (the carousel's own width).

type ResponsiveValue = T | { readonly [minWidth: number]: T; }

Transition look: side-by-side slide, cross-fade, scaling down away from the center, or your own function. The function receives the slide's distance from the aligned position (in slides, -1 is the previous one) as an Animated value.

type CarouselEffect = "slide" | "fade" | "scale" | ((distance: Animated.AnimatedInterpolation<number>) => Animated.WithAnimatedValue<ViewStyle>)

Indicators: dots, story lines, a 3 / 8 counter, thumbnails or none.

type CarouselIndicators = "dots" | "lines" | "count" | "thumbnails" | false

Autoplay settings.

NameTypeDefaultDescription
delay?number5000Time spent on a slide (ms).
stopOnInteraction?booleanfalseStops permanently when touched; with false the timer restarts.

Methods of the Carousel ref (same as web).

NameTypeDescription
next() => voidGoes to the next slide (or page).
prev() => voidGoes to the previous slide.
goTo(index: number, options?: { instant?: boolean; }) => voidGoes to a slide.
play() => voidStarts autoplay.
pause() => voidPauses autoplay.

CarouselProps

interface

Props of Carousel (same names as web).

NameTypeDefaultDescription
childrenReactNodeSlides: each child is a slide.
label?string"Karusel"Screen reader name.
loop?booleanfalseInfinite loop: the first slide follows the last one seamlessly.
slidesPerView?ResponsiveValue<number>1Number of visible slides; may be fractional (1.2).
gap?ResponsiveValue<number>16Gap between slides (px).
align?CarouselAlign"start"Alignment of the slide in the visible area.
step?number | "page"1How many slides to advance per move; "page" advances by the visible count.
orientation?"horizontal" | "vertical""horizontal"Direction. Vertical requires height.
height?numberHeight (required when vertical).
index?numberSelected slide (controlled).
defaultIndex?number0Initial slide.
onIndexChange?(index: number) => voidWhen the selected slide changes (also while dragging).
onSettle?(index: number) => voidWhen the motion ends and the slide settles into place.
autoplay?boolean | number | CarouselAutoplayAutoplay: true, the delay (ms) or settings. Stops while dragging.
marquee?boolean | numberContinuous flow (logo strip): scrolls at this speed (px/s); negative reverses. true = 40.
effect?CarouselEffect"slide"Transition look.
arrows?boolean | "always"truePrevious/next arrows. On touch screens visible only with "always".
indicators?CarouselIndicators"dots"Indicators.
indicatorsPlacement?"inside" | "outside""outside"Whether indicators are over or below the slide.
thumbnails?readonly (string | ReactNode)[]Thumbnails (indicators="thumbnails"): a URL or an element.
draggable?booleantrueDraggable by touch.
snap?booleantrueSnaps to slides; with false scrolls freely.
skipSnaps?booleanfalseA quick flick may skip several slides.
rewind?booleanfalseWithout loop, the arrow at an end goes to the other end.
duration?number500Duration of the snap animation (ms).
ref?Ref<CarouselHandle>External control.
style?StyleProp<ViewStyle>Container style.