npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-draggable-float-btn

v1.0.9

Published

A draggable floating button component for React

Readme

React Draggable Float Button

npm version npm downloads License

A lightweight, customizable draggable floating button component for React.

Features

  • 🎯 Fully draggable with viewport constraints
  • 📱 Mobile touch support (drag on mobile devices)
  • 🎨 Customizable styles via props or CSS classes
  • 🖥️ Responsive and automatically repositions on window resize
  • 🎪 TypeScript support with full type definitions
  • 🚀 Lightweight with zero dependencies
  • 💅 BEM-style CSS classes for easy customization

Installation

npm install react-draggable-float-btn

Quick Start

import { FloatingButton } from "react-draggable-float-btn";

function App() {
  return (
    <FloatingButton onClick={() => console.log("Clicked!")}>+</FloatingButton>
  );
}

Props

| Prop | Type | Default | Description | | ----------------- | -------------------------------------------------------------- | ---------------- | ------------------------------------------ | | children | React.ReactNode | Required | Content to display inside the button | | onClick | (event: MouseEvent) => void | - | Click handler | | size | 'small' \| 'medium' \| 'large' | 'medium' | Button size (40px / 50px / 60px) | | defaultPosition | 'bottom-right' \| 'bottom-left' \| 'top-right' \| 'top-left' | 'bottom-right' | Default position | | position | { x: number; y: number } | - | Fixed position (overrides defaultPosition) | | draggable | boolean | true | Enable/disable dragging | | disabled | boolean | false | Disable button interactions | | backgroundColor | string | #ffffff | Background color | | color | string | #000000 | Text/content color | | borderRadius | number | 50 | Border radius in pixels | | boxShadow | string | CSS default | Custom box shadow | | zIndex | number | 1000 | Z-index value | | className | string | - | Additional CSS class | | style | CSSProperties | - | Inline styles | | onDragStart | (position: { x: number; y: number }) => void | - | Callback when drag starts | | onDragEnd | (position: { x: number; y: number }) => void | - | Callback when drag ends |

Examples

Different Sizes

<FloatingButton size="small">S</FloatingButton>
<FloatingButton size="medium">M</FloatingButton>
<FloatingButton size="large">L</FloatingButton>

Positions

<FloatingButton defaultPosition="top-left">TL</FloatingButton>
<FloatingButton defaultPosition="bottom-right">BR</FloatingButton>

Custom Styling

<FloatingButton
  backgroundColor="#007bff"
  color="#ffffff"
  size="large"
  onClick={() => alert("Hello!")}
>
  💬
</FloatingButton>

Multiple Buttons

<>
  <FloatingButton defaultPosition="bottom-right">+</FloatingButton>
  <FloatingButton defaultPosition="bottom-left">💬</FloatingButton>
  <FloatingButton defaultPosition="top-right">🔔</FloatingButton>
</>

Non-draggable

<FloatingButton draggable={false} position={{ x: 100, y: 100 }}>
  📌
</FloatingButton>

Styling

CSS Classes

The component uses BEM-style classes:

  • .btn-float-draggable - Base class
  • .btn-float-draggable--{size} - Size variants (small/medium/large)
  • .btn-float-draggable--dragging - Applied while dragging
  • .btn-float-draggable--disabled - Applied when disabled

Override Styles

.btn-float-draggable {
  background-color: #007bff !important;
  box-shadow: 0 8px 16px rgba(0, 123, 255, 0.3) !important;
}

.btn-float-draggable--large {
  width: 70px !important;
  height: 70px !important;
}

.btn-float-draggable--dragging {
  opacity: 0.8;
  transform: scale(1.05);
}

Using Custom Classes

<FloatingButton className="my-custom-button">Custom</FloatingButton>

The button will render with combined classes:

<button
  class="btn-float-draggable btn-float-draggable--medium my-custom-button"
></button>

Advanced Usage

With Drag Callbacks

<FloatingButton
  onDragStart={(pos) => console.log("Drag started:", pos)}
  onDragEnd={(pos) => console.log("Drag ended:", pos)}
>
  📍
</FloatingButton>

With Custom Styles

<FloatingButton
  style={{
    background: "linear-gradient(45deg, #ff6b6b, #ff8e8e)",
    border: "3px solid #ff5252",
  }}
>
  ✨
</FloatingButton>

Development

# Install dependencies
npm install

# Build package
npm run build

# Watch mode
npm run dev

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.