A headless hook for implementing drag-to-scroll functionality with scroll buttons.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/zayne-labs/ui/llms.txt
Use this file to discover all available pages before exploring further.
Import
Usage
Hook Options
The direction in which scrolling is allowed
horizontal- Only scroll horizontallyvertical- Only scroll verticallyboth- Scroll in both directions
Amount to scroll when using navigation buttons
"item"- Scroll by the width/height of the first child elementnumber- Scroll by a fixed pixel amount
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)
Custom class names for drag scroll parts
base?: string- Root container classesitem?: string- Item classes
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.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)
Returns props for individual scroll itemsReturns:
- Element props with snap-center classes
- Data attributes:
data-scope="drag-scroll",data-part="item"
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
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
Ref object containing the scrollable container element
storeApi
Store API for accessing and subscribing to drag scroll state
useDragScrollStore
Hook for subscribing to specific slices of the drag scroll state
disableInternalStateSubscription
The resolved value of the
disableInternalStateSubscription option