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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-mini-fab

v1.1.1

Published

A lightweight and customizable Mini Floating Action Button (Mini FAB) component for React applications. This component provides an easy way to add a floating action button to your UI, enhancing user interaction and accessibility.

Readme

React Mini Floating Action Button

NPM Storybook

A lightweight and customizable Mini Floating Action Button (Mini FAB) component for React applications. This component provides an easy way to add a floating action button to your UI, enhancing user interaction and accessibility.

Demo

Features

  • Draggable - Vertically draggable with position persistence via localStorage
  • Smooth Animations - Elegant show/hide animations and position transitions
  • Flexible Positioning - Support for left and right screen positions with animated switching
  • Badge Support - Optional badge indicator for notifications or status
  • Highly Customizable - Configurable colors, icons, and accessibility labels
  • TypeScript Support - Full TypeScript type definitions included
  • Lightweight - Minimal dependencies and optimized bundle size
  • Accessibility First - Built with ARIA labels and keyboard navigation support

Installation

Prerequisites

This library requires React as a peer dependency. Make sure you have React installed in your project:

  • React 17.x, 18.x, or 19.x

If you don't have React installed, install it first:

npm install react react-dom
yarn add react react-dom
pnpm add react react-dom

Install react-mini-fab

Install the package using your preferred package manager:

npm install react-mini-fab
yarn add react-mini-fab
pnpm add react-mini-fab

Usage

Here's a basic example of how to use the MiniFAB component:

import { MiniFAB } from 'react-mini-fab';

import 'react-mini-fab/style.css';

function App() {
  return (
    <MiniFAB
      onClick={() => console.log('FAB clicked!')}
      position="right"
      title="Help"
      ariaLabel="Open help window"
      backgroundColor="#007bff"
      draggableId="help-fab"
    >
      <svg width="24" height="24" viewBox="0 0 24 24">
        {/* Your icon SVG */}
      </svg>
    </MiniFAB>
  );
}

Props API

MiniFABProps

| Prop | Type | Required | Default | Description | |------|------|----------|---------|-------------| | onClick | () => void | No | - | Callback function invoked when the button is clicked | | isHide | boolean | No | false | Controls the visibility of the button. When true, the button is hidden | | title | string | No | - | Tooltip text displayed when hovering over the button | | ariaLabel | string | Yes | - | Accessibility label for screen readers | | backgroundColor | string | Yes | - | Background color of the button (any valid CSS color) | | position | "left" \| "right" | No | "left" | Position of the button on the screen | | draggableId | string | No | - | Unique identifier for the draggable functionality. When provided, the vertical position is saved to localStorage | | badge | Badge | No | - | Badge configuration to display on the button | | includeFixedClassName | boolean | No | false | Whether to include fixed class names for custom styling purposes | | children | React.ReactNode | No | - | Content to be rendered inside the button (typically an icon or text) |

Badge

| Prop | Type | Required | Description | |------|------|----------|-------------| | color | string | Yes | Background color of the badge (any valid CSS color) |

Examples

With Badge Indicator

<MiniFAB
  onClick={() => console.log('Notification clicked')}
  position="right"
  ariaLabel="Notifications"
  backgroundColor="#ff6b6b"
  draggableId="notification-fab"
  badge={{ color: "#00ff00" }}
>
  <NotificationIcon />
</MiniFAB>

Dynamic Position Switching

function App() {
  const [position, setPosition] = useState<"left" | "right">("left");

  return (
    <>
      <button onClick={() => setPosition(position === "left" ? "right" : "left")}>
        Toggle Position
      </button>
      <MiniFAB
        position={position}
        ariaLabel="Settings"
        backgroundColor="#9b59b6"
        draggableId="settings-fab"
      >
        <SettingsIcon />
      </MiniFAB>
    </>
  );
}

Show/Hide Control

function App() {
  const [isHidden, setIsHidden] = useState(false);

  return (
    <>
      <button onClick={() => setIsHidden(!isHidden)}>
        {isHidden ? 'Show' : 'Hide'} FAB
      </button>
      <MiniFAB
        isHide={isHidden}
        ariaLabel="Help"
        backgroundColor="#3498db"
        draggableId="help-fab"
      >
        <HelpIcon />
      </MiniFAB>
    </>
  );
}

With Custom Text

<MiniFAB
  onClick={() => console.log('Chat opened')}
  ariaLabel="Open chat"
  backgroundColor="#2ecc71"
  draggableId="chat-fab"
>
  <span style={{ color: '#fff', fontWeight: 'bold' }}>Chat</span>
</MiniFAB>

Accessibility

This component is built with accessibility in mind:

  • ARIA Labels: The ariaLabel prop is required to ensure screen readers can properly identify the button's purpose
  • Keyboard Navigation: The FAB is fully keyboard accessible using standard button interactions
  • Focus Indicators: Clear focus outlines for keyboard navigation
  • Semantic HTML: Uses proper <button> element for interactive functionality
  • Tooltip Support: Optional title prop provides additional context on hover

Development

This library is built using modern tooling and best practices:

Build

pnpm run build

The build process generates both UMD and ES module formats:

  • UMD: dist/index.umd.cjs (for CommonJS environments)
  • ES Module: dist/index.js (for modern bundlers)
  • TypeScript definitions: dist/index.d.ts

Testing

# Run tests
pnpm run test

# Run tests with UI
pnpm run test:ui

# Run tests with coverage
pnpm run test:coverage

Storybook

View and interact with component examples:

# Start Storybook dev server
pnpm run dev:storybook

# Build Storybook
pnpm run build:storybook

Code Quality

# Lint and format with Biome
pnpm run check:write

LICENSE

MIT