0.0.7 • Published 1 year ago

floating-modal v0.0.7

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

Floating Modal

A customizable, lightweight, smooth, zero depedencies and easy-to-use React component for creating floating modals in your web application.

Demo

you can visit here

Installation

To install Floating Modal, you can use npm or yarn:

npm install floating-modal

or

yarn add floating-modal

Usage

import React, { useState } from "react";
import { FloatingModal } from "floating-modal";

const App = () => {
  const [isOpen, setIsOpen] = useState(false);

  const handleOpen = () => {
    setIsOpen(true);
  };

  const handleClose = () => {
    setIsOpen(false);
  };

  return (
    <div>
      <button onClick={handleOpen}>Open Modal</button>
      <FloatingModal
        isOpen={isOpen}
        onClose={handleClose}
        initialHeight={150}
        maxHeight={window.innerHeight - 100}
      >
        <h2>Modal Content</h2>
        <p>This is the content inside the modal.</p>
      </FloatingModal>
    </div>
  );
};

export default App;

API Props

PropTypeDefaultDescription
intialHeightnumber150Optional. The initial height of the modal (in pixels).
maxHeightnumberwindow.innerHeight - 100Optional. The maximum height of the modal (in pixels).
isOpenbooleanfalseRequired. Determines whether the modal is open or closed.
onClose() => voidundefinedRequired. Function to call when the modal is closed.
onOpen() => voidundefinedOptional. Function to call when the modal is opened.
childrenReact.ReactNodenullRequired. The content to display inside the modal.
0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago