react-dialog-element
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

react-dialog-element

React Dialog component using native <dialog> element.

Using native HTML element has few benefits over custom dialog components:

  • Better accessibility
  • Better performance
  • Small bundle size (about 1kB)
  • Fully styleable
  • Traps focus inside dialog
  • Closes on escape key press
  • Closes on click outside dialog

Usage

import { Dialog } from 'react-dialog-element';

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

  return (
    <>
      <button onClick={() => setOpen(true)}>Open dialog</button>
      <Dialog isOpen={isOpen} setOpen={setOpen}>
        <h1>Dialog content</h1>
      </Dialog>
    </>
  );
};

Browser support

Caniuse link

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.0
    0
  • 1.0.2
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i react-dialog-element

Weekly Downloads

0

Version

1.1.0

License

MIT

Unpacked Size

43.2 kB

Total Files

20

Last publish

Collaborators

  • vanih