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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-controlled-dialog

v1.3.5

Published

A declarative interface for the native dialog element

Downloads

6

Readme

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

| Option | Type | Default | Description | | -------------------- | ---------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------- | | children | node or array of nodes | null | Child elements for the dialog can be passed naturally | | isOpen | boolean | false | Whether the dialog should be open (required) | | setOpen | function | null | Function that updates isOpen to switch to true or false (required) | | type | string | "dialog" | Determine whether the dialog should open as a modal or use default behavior | | closeOnBackDropClick | boolean or function | false | Accepts a boolean or a function that evaluates to a boolean to determine whether clicking on the backdrop should close the modal | | DialogComponent | node | null | A custom element that replaces the default, unstyled dialog (should accept a ref, role, and onClick attributes) | | closeButton | node | null | Your custom close button | | onClick | function | null | custom event handler for onClick events for the dialog |