
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
@dashdot/react-hooks-slider
Advanced tools
A headless, customizable slider for React using hooks.
To get started, add @dashdot/react-hooks-slider to your project:
Using npm:
npm install --save @dashdot/react-hooks-slider
Using yarn:
yarn add @dashdot/react-hooks-slider
Please note that @dashdot/react-hooks-slider requires react@^16.0.0 as a peer dependency.
The package exports a single hook, useSlider, which can be used to control a slider. The hook returns an object containing various state values and functions for controlling the slider. The only requirements for using the hook are a container element and an array of slide elements, which are passed as refs.
const {
/* Basic usage */
activeSlide,
totalSlides,
position, // returns the position using percentage
isDisabled, // happens when slides are smaller than container
hasPreviousSlide,
hasNextSlide,
/* Handlers */
handleNextSlide, // go to next slide
handlePreviousSlide, // go to previous slide
handleSlideSelect, // navigate to specific slide
/* Swiping (when using framer-motion) */
isSwiping,
swipingProps
/* Refs */
containerRef,
slideRefs,
} = useSlider(
initialSlideIndex, // defaults to 0
autoplaySpeed, // time in ms to go to next slide. Defaults to 0 = inactive
slidesAreRendered, // passes if the slides are rendered. This fixes layout issues with conditional rendering. Defaults to true
}
import { useSlider } from '@dashdot/react-hooks-slider';
const {
position,
containerRef,
slideRefs,
} = useSlider();
return (
<div ref={containerRef}
style={{
whiteSpace: 'nowrap',
display: 'flex',
flexWrap: 'nowrap',
width: '100%',
}}
>
{slides.map((slide, index) => (
<div
key={slide.id}
ref={(ref) => { slideRefs.current[index] = ref }}
style={{
x: position,
width: '25rem',
height: '25rem',
}}
>
{slide.content}
</div>
))}
</div>
);
You can use any sort of animation or styling. The example below uses tailwind and framer-motion.
const {
position,
hasPreviousSlide,
hasNextSlide,
handleNextSlide,
handlePreviousSlide,
slideRefs,
containerRef,
isDisabled,
swipingProps,
} = useCarousel()
return (
<motion.div
ref={containerRef}
animate={{ x: isDisabled || position === null ? 0 : `${position}%` }}
transition={{ duration: 0.4, ease: 'easeOut' }}
className="whitespace-nowrap flex flex-nowrap w-full touch-pan-y"
{...swipingProps}
>
{images.map((image, index) => (
<div
key={image.filename}
ref={(ref) => { slideRefs.current[index] = ref }}
className="pr-4 lg:pr-6 last:pr-0 flex-grow-0 flex-shrink-0 w-[365px] h-[288px] relative"
>
<div className="relative w-full h-full">
<Image
maxWidth={640}
src={image.filename}
alt={image.alt}
layout="fill"
objectFit="cover"
draggable={false}
/>
</div>
</div>
))}
</motion.div>
)
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
See also the list of contributors who participated in this project.
Dashdot We shape, build and grow ambitious digital products.
This project is licensed under the MIT License - see the LICENSE.md file for details
FAQs
A headless, customizable slider for React using hooks.
We found that @dashdot/react-hooks-slider demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.