0.0.18 • Published 9 years ago

@tgdn/react-modal v0.0.18

Weekly downloads
-
License
MIT
Repository
github
Last release
9 years ago

React Modal npm version

An accessible, easy to use, customizable modal library for the web.

Ongoing work on the library.

Playground

To run demo on your computer

Installing

npm install --save @tgdn/react-modal

Usage

import React from 'react'
import {
    ModalContent,
    Modal,
    ModalComposite,
} from '@tgdn/react-modal'

class MyModalView extends React.Component {
    constructor(props) {
        super(props)
        this.closeOnClick = this.closeOnClick.bind(this)
        this.showDialog = this.showDialog.bind(this)
    }

    closeOnClick() {
        this.modal.hide()
    }

    showDialog() {
        this.modal.show()
    }

    render() {
        return (
            <ModalComposite>
                <button className='btn' onClick={this.showDialog}>open</button>
                <Modal ref={(c) => {this.modal = c}}>
                    <ModalContent>
                        This is an example
                        <br />
                        <br />
                        <button
                            className='btn'
                            onClick={this.closeOnClick}
                        >
                            Close with a button
                        </button>
                    </ModalContent>
                </Modal>
            </ModalComposite>
        )
    }
}

Configuration

Different prop types are available for use on Modal

PropDefaultValueDescription
visiblefalsetrue/falseWhether the modal should be visible after mounting
closeOnClicktruetrue/falseIf true, clicking outside the modal will hide it
keyboardtruetrue/false or functionIf true, pressing Escape will close the modal, if a function is provided, it will be called whenever a key is pressed
canClosetruetrue/falseIf true, a close button will be displayed, and clicking on it will hide the modal

Done

  • Simple UI
  • Reactive Component
0.0.18

9 years ago

0.0.17

9 years ago

0.0.16

9 years ago

0.0.15

9 years ago

0.0.14

9 years ago

0.0.13

9 years ago

0.0.12

9 years ago

0.0.11

9 years ago

0.0.10

9 years ago

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago