0.1.1 • Published 10 months ago

react-draggable-fab v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

react-draggable-fab

A simple and customizable draggable button component for the web. Users can easily move the button around the screen, and it will snap to an edge upon release.

  • Customizable: Easily configure button state, appearance to suit your needs.
  • Lightweight: Minimal dependencies—only prop-types is required.
  • Responsive: Works seamlessly across different screen sizes and devices.
  • Smooth Interaction: Provides a smooth dragging experience with snap-to-edge functionality.

Features

  • Draggable: Move the button freely around the screen.
  • Snap-to-Edge: Automatically aligns the button to an edge when released.
  • Custom Styling: Apply your own styles and customize the button's look and feel.
  • Touch and Mouse Support: Fully functional with both touch and mouse interactions.

Demo

Demo Link

Installation

To get started, install the component using npm:

npm install react-draggable-fab

Usage

import React from 'react';
import DraggableButton from 'react-draggable-fab';

const App = () => {
    return <DraggableButton>Drag Me!</DraggableButton>;
};

API

PropTypeDefaultDescription
blurDelaynumber3000Delay before applying the grayed-out (blurred) button style, in milliseconds.
childrenstring''Content inside the draggable button.
classNamestring''Additional CSS class for the component wrapper.
closeButtonBottomstring100pxCSS bottom property value for the close button.
closeButtonClassNamestring''Additional CSS class for the close button.
isVisibleboolundefinedIf true, the button will be visible.
overlayClassNamestring''Additional CSS class for the overlay (background blackout).
stickyEdgestringleftThe edge of the screen where the button will stick (left or right).
verticalThresholdnumber50Threshold value for vertical positioning. The component will not stick above or below this threshold.
xPositionstring0Horizontal position (CSS left or right) of the component relative to the window.
yPositionstring400pxVertical position (CSS top) of the component relative to the window.
onClickfunc() => {}Callback function triggered when the button is clicked.
onClosefunc() => {}Callback function triggered when the draggable button is dropped onto the close button.

License

MIT