Licence
MIT
Version
0.1.3
Deps
1
Size
38 kB
Vulns
0
Weekly
0
swiper-action
Simple react component for swipe-to-action.
Disclaimer
This project is still in its early stages. If you have ideas for improvements, open an issue or a pull request!
Getting started
You can install this package using your favorite package manager:
npm install swiper-action
There are two components:
SwiperAction: acts as the outer container for your content.Action: used for the definition of your "swipe-to-actions" actions. The handler for each action receives anInteractionEventthat can either be aMouseEventor aTouchEvent.
import { SwiperAction, Action } from "swiper-action";
function Example() {
const actions = [
<Action action={(e) => handleClick(e)} key={1}>
<div className="flex h-full flex-col justify-center">
action
</div>
</Action>,
<Action action={(e) => handleClick(e)} key={2}>
<div className="flex h-full flex-col justify-center">
action2
</div>
</Action>,
];
return (
<SwiperAction actions={actions}>
<div>Content</div>
</SwiperAction>
);
}
In the end, this should look something like this image:

Caveats
- Currently, the
keyprop needs to be set manually for theActioncomponent. This will likely be fixed in the future. - The width and height of the outer container for the
SwiperActioncomponent need to be set explicitly.
Contributing
This project is just getting started. Hence, feel free to open issues and pull requests!