React API Reference

Complete reference for @reelkit/react components, props, and methods.

Reel Props

PropTypeDefaultDescription
countnumberrequiredTotal number of items
size[number, number]-Width and height as [width, height]. When omitted, auto-measures via ResizeObserver
itemBuilder(index, indexInRange, size) => ReactElementrequiredFunction to render each slide
direction'vertical' | 'horizontal''vertical'Scroll direction
initialIndexnumber0Starting index
loopbooleanfalseEnable infinite loop
enableWheelbooleanfalseEnable mouse wheel navigation
wheelDebounceMsnumber200Wheel event debounce in ms
enableNavKeysbooleantrueEnable keyboard navigation
onNavKeyPress(increment: -1 | 1) => void-Custom handler for arrow key navigation. Replaces default prev/next behavior.
transitionTransitionTransformFnslideTransitionTransition effect function. Built-in: slideTransition, fadeTransition, flipTransition, cubeTransition, zoomTransition
transitionDurationnumber300Animation duration in ms
enableGesturesbooleantrueEnable touch/mouse drag navigation
swipeDistanceFactornumber0.12Swipe threshold (0-1)
rangeExtractor(index: number, count: number) => number[]defaultRangeExtractorCustom function to determine which indexes are rendered
keyExtractor(index: number) => string-Custom key function for React reconciliation (useful with loop)
apiRefRefObject<ReelApi>-Ref to access API methods
classNamestring-CSS class for the container element
styleCSSProperties-Inline styles for the container element
ariaLabelstring-Accessible label for the carousel region, read by screen readers

Callbacks

PropTypeDescription
afterChange(index, indexInRange) => voidCalled after slide change completes
beforeChange(index, nextIndex, indexInRange) => voidCalled before slide change starts
onSlideDragStart(index) => voidCalled when drag gesture starts
onSlideDragEnd(index) => voidCalled when drag gesture ends
onSlideDragCanceled(index) => voidCalled when drag is canceled

ReelApi Methods

Access slider methods via apiRef:

typescript
MethodTypeDescription
next()() => voidGo to next slide
prev()() => voidGo to previous slide
goTo(index, animate?)(number, boolean?) => PromiseGo to specific slide
adjust()() => voidRecalculate slide positions
observe()() => voidStart keyboard observation
unobserve()() => voidStop keyboard observation

ReelIndicator Props

PropTypeDefaultDescription
countnumberautoTotal number of items. Auto-connected from parent Reel when nested inside one; pass explicitly when used standalone
activenumberautoCurrent active index. Auto-connected from parent Reel when nested inside one; pass explicitly when used standalone
direction'vertical' | 'horizontal''vertical'Indicator orientation
radiusnumber3Dot size in pixels
visiblenumber5Max normal-sized dots visible
gapnumber4Space between dots in pixels
activeColorstring'#fff'Active dot color
inactiveColorstring'rgba(255,255,255,0.5)'Inactive dot color
edgeScalenumber0.5Scale for overflow edge dots
onDotClick(index: number) => void-Callback when a dot is clicked
classNamestring-Custom CSS class
styleCSSProperties-Custom inline styles

Observer Components

Observe

Bridges core signals to React rendering without causing parent re-renders. Only the children function re-executes when subscribed signals change.

tsx

AnimatedObserve

Subscribes to animated value signals and smoothly interpolates using requestAnimationFrame.

tsx

Hooks

useBodyLock

Locks body scroll and compensates for scrollbar width shift.

typescript

Accessibility

<Reel> renders as role="region" with aria-roledescription="carousel". Set the ariaLabel prop to give the region a screen-reader name. A polite live region announces "Slide N of M" on every slide change without re-rendering the carousel. Inactive slides receive the inert attribute so focus and AT navigation skip them.

<ReelIndicator> renders as role="tablist" with roving tabindex on the dots; arrow keys move focus and Enter or Space activates the slide.

Building a custom modal around <Reel>? captureFocusForReturn, createFocusTrap, and getFocusableElements are re-exported from @reelkit/react for focus return and trap.

Utilities

createDefaultKeyExtractorForLoop

Creates a key extractor that handles duplicate indexes when loop is enabled.

tsx