Giter VIP home page Giter VIP logo

responsive-modal-react's Introduction

Responsive Modal

A customizable and responsive modal component for React.

Installation

Install the package using npm:

npm install responsive-modal-react

Usage

import React, { useState } from 'react';
import Modal from 'responsive-modal-react';

const App = () => {
  const [modalState, setModalState] = useState(false);

  return (
    <div>
      <button onClick={() => setModalState(true)}>Open Modal</button>
      <Modal
        isVisible={modalState}
        onClose={() => setModalState(false)}
        width="50%"
        height="50%"
        scroll
        header={<YourHeaderComponent/>}
        wrapperClassName="custom-wrapper"
        contentClassName="custom-content"
        bodyClassName="custom-body"
      >
        <div>Modal Content Goes Here</div>
      </Modal>
    </div>
  );
};

export default App;

Props

children (required)

  • Type: ReactNode
  • Description: The content to be rendered inside the modal.

isVisible (required)

  • Type: boolean
  • Description: Controls the visibility of the modal.

width

  • Type: string
  • Default: undefined
  • Description: Specifies the width of the modal. Accepts CSS values like percentages or pixels.

height

  • Type: string
  • Default: undefined
  • Description: Specifies the height of the modal. Accepts CSS values like percentages or pixels.

onClose (required)

  • Type: () => void
  • Description: Callback function triggered when the modal is closed.

scroll

  • Type: boolean
  • Default: false
  • Description: Enables or disables scrolling within the modal body.

header

  • Type: React.ReactElement<{ onClose?: () => void }>
  • Default: undefined
  • Description: React element to be used as the modal header. It can have an optional onClose prop.

wrapperClassName

  • Type: string
  • Default: undefined
  • Description: Custom class name for the modal wrapper.

contentClassName

  • Type: string
  • Default: undefined
  • Description: Custom class name for the modal content.

bodyClassName

  • Type: string
  • Default: undefined
  • Description: Custom class name for the modal body.

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.