Git Product home page Git Product logo

react-mui-swipeable's Introduction

React Mui Swipeable

Size Downloads Stars

A simple component for making elements swipeable. It follows the material design pattern and uses @material-ui internally.

<Swipeable 
    onSwipeLeft={() => console.log("Swipe Left")}
    onSwipeRight={() => console.log("Swipe Right")}
>
    <div>Swipe Me</div>
</Swipeable>

Installation

npm install react-mui-swipeable

Usage

For the component to work proberly, the child must accept the style attribute. (If you use a DOM element, this will be the case)

import Swipeable from "react-mui-swipeable"
<Swipeable>
    // Single child
</Swipeable>

Available Props

/*
 * Triggers when the user swipes to the left / right. If no value is given,
 * The user will be unable to swipe to the left / right.
 * 
 * Default: undefined
*/
[onSwipeLeft, onSwipeRight]: Function,

/*
 * Configurations for swiping left / right.
 * 
 * Default:
 * 
 * swipeLeftConfig: {
 *     color: "#CF6679",
 *     icon: DeleteIcon,
 *     moveOutOfScreen: true
 * }
 * 
 * swipeRightConfig: {
 *     color: "#BB86FC",
 *     icon: EditIcon,
 *     moveOutOfScreen: false
 * }
*/
[swipeLeftConfig, swipeRightConfig]: {
    // Color of the background-surface exposed while swiping
    color: String,

    // Element which is renderer on the background-surface while swiping
    icon: ReactElement,

    // Whether the element should move back to the initial position when 
    // releasd or move out of screen
    moveOutOfScreen: Boolean
}

/*
 * General style configuration
 *
 * Default: {
 *     iconColor: "#000",
 *     shadow: "0px 3px 1px -2px rgba(0,0,0,0.2), 0px 2px 2px 0px 
 *              rgba(0,0,0,0.14),0px 1px 5px 0px rgba(0,0,0,0.12)",
 *     borderRadius: 8
 * }
*/
style: {
    // Color of the icon
    iconColor: String,

    // Styles applied to the child while swiping
    shadow: String,
    borderRadius: Number
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.