Import
Usage
Hook Options
'horizontal' | 'vertical' | 'both'
default:"horizontal"
The direction in which scrolling is allowed
horizontal- Only scroll horizontallyvertical- Only scroll verticallyboth- Scroll in both directions
'item' | number
default:"item"
Amount to scroll when using navigation buttons
"item"- Scroll by the width/height of the first child elementnumber- Scroll by a fixed pixel amount
'allScreens' | 'desktopOnly' | 'mobileAndTabletOnly'
default:"allScreens"
Device usage constraints for drag behavior
allScreens- Drag works on all devicesdesktopOnly- Drag works only on desktop (width >= 768px)mobileAndTabletOnly- Drag works only on mobile/tablet (width < 768px)
object
Custom class names for drag scroll parts
base?: string- Root container classesitem?: string- Item classes
boolean
default:false
Whether to disable the internal state subscription for setting data attributesThis is useful if you want to subscribe to the state yourself
Return Value
propGetters
Object containing prop getter functions for each component part.function
Returns props for the scrollable container elementReturns:
- Element props with scroll behavior classes
refcallback for container registration- Data attributes:
data-scope="drag-scroll",data-part="root",data-dragging(when dragging)
function
Returns props for individual scroll itemsReturns:
- Element props with snap-center classes
- Data attributes:
data-scope="drag-scroll",data-part="item"
function
Returns props for the previous/back scroll buttonReturns:
- Button props with click handler to scroll backward
disabledwhen at the start of scroll- Data attributes:
data-scope="drag-scroll",data-part="back-button",data-disabled
function
Returns props for the next/forward scroll buttonReturns:
- Button props with click handler to scroll forward
disabledwhen at the end of scroll- Data attributes:
data-scope="drag-scroll",data-part="next-button",data-disabled
containerRef
React.RefObject<TElement | null>
Ref object containing the scrollable container element
storeApi
StoreApi<DragScrollStore<TElement>>
Store API for accessing and subscribing to drag scroll state
useDragScrollStore
function
Hook for subscribing to specific slices of the drag scroll state
disableInternalStateSubscription
boolean
The resolved value of the
disableInternalStateSubscription option