1.3.5 • Published 5 years ago

react-controlled-dialog v1.3.5

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

React Controlled Dialog

Declarative React interface for the HTML5 Dialog

Demo

https://react-controlled-dialog.netlify.com/

Installation

Install through your preferred package manager

# NPM
npm install react-controlled-dialog

# Yarn
yarn add react-controlled-dialog

Then, include the component in your codebase

import Dialog from "react-controlled-dialog";

Examples

A simple dialog:

import React, { useState } from "react";
import Dialog from "../lib/ReactControlledDialog";

const Simple = () => {
  const [isOpen, setOpen] = useState(false);
  return (
    <div id="simple">
      <h2>Simple Dialog</h2>
      <p>Click below to open!</p>
      <button onClick={() => setOpen(true)}>Simple Dialog</button>
      <Dialog isOpen={isOpen} setOpen={setOpen}>
        foobar
      </Dialog>
      <p>
        The native dialog component can be activated by passing an{" "}
        <code>open</code> attribute, or by invoking the <code>show()</code>{" "}
        method from the native API.
      </p>
    </div>
  );
};

The dialog can be opened as either a dialog (which is default), or as a modal, by specifying a type of "modal" or "dialog".

Settings

OptionTypeDefaultDescription
childrennode or array of nodesnullChild elements for the dialog can be passed naturally
isOpenbooleanfalseWhether the dialog should be open (required)
setOpenfunctionnullFunction that updates isOpen to switch to true or false (required)
typestring"dialog"Determine whether the dialog should open as a modal or use default behavior
closeOnBackDropClickboolean or functionfalseAccepts a boolean or a function that evaluates to a boolean to determine whether clicking on the backdrop should close the modal
DialogComponentnodenullA custom element that replaces the default, unstyled dialog (should accept a ref, role, and onClick attributes)
closeButtonnodenullYour custom close button
onClickfunctionnullcustom event handler for onClick events for the dialog
1.3.5

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago