Socket
Socket
Sign inDemoInstall

@react-md/dialog

Package Overview
Dependencies
18
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @react-md/dialog

This package is used to create accessible dialogs and modals.


Version published
Weekly downloads
1K
decreased by-8.42%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

5.1.6 (2023-12-11)

Bug Fixes

  • @react-md/chip: add overflow to support font icons (da44bbd), closes #1432
  • select: port fixed positioning fixes back from v6.0.0 (feb9ec6), closes #1461

Documentation

  • react-md.dev: update blog to include additional releases (b305882)

Readme

Source

@react-md/dialog

Create fully accessible dialogs that can span the entire page, centered within the viewport, or positioned anywhere. The dialogs can also act as a modal so that the user must press one of the actions to close the dialog instead of closing by pressing the background overlay.

The main accessibility features and other features for dialogs are:

  • automatically managing focus to and from the dialog when it mounts
  • allowing a user key press the escape key to close the dialog
  • applying the required roles and aria-* attributes
  • adding additional prominence to the dialog with the alertdialog role as needed (see docs for this one)
  • conditionally portaling the dialogs to help with overflow issues and other display errors
  • disabling scroll for the main window while a dialog is visible

Installation

npm install --save @react-md/dialog

This package also goes great with the following packages:

npm install --save @react-md/theme \
  @react-md/utils \
  @react-md/typography \
  @react-md/button \
  @react-md/app-bar

Documentation

You should check out the full documentation for live examples and more customization information, but an example usage is shown below.

Example

This package exports multiple components to create your dialog as well as a context component for handling multiple dialogs at once within your page.

import { render } from "react-dom";
import { Button } from "@react-md/button";
import {
  Dialog,
  DialogHeader,
  DialogTitle,
  DialogContent,
  DialogFooter,
} from "@react-md/dialog";
import { useToggle } from "@react-md/utils";

const App = () => {
  return (
    <>
      <Button id="dialog-toggle" onClick={enable}>
        Show Dialog
      </Button>
      <Dialog
        id="main-dialog"
        visible={visible}
        onRequestClose={disable}
        aria-labelledby="main-dialog-title"
      >
        <DialogHeader>
          <DialogTitle id="main-dialog-title">My Dialog</DialogTitle>
        </DialogHeader>
        <DialogContent>This is some content.</DialogContent>
        <DialogFooter>
          <Button id="main-dialog-close" onClick={disable}>
            Close
          </Button>
        </DialogFooter>
      </Dialog>
    </>
  );
};

render(<App />, document.getElementById("root"));

Keywords

FAQs

Last updated on 11 Dec 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc