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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nardole/material-ui-dynamic-dialog

v0.0.5

Published

A tiny, flexible dynamic dialog system for React + MUI (Material UI). Quickly open confirmation or custom dialogs from anywhere in your app using a Provider and a simple hook.

Readme

@nardole/material-ui-dynamic-dialog

A tiny, flexible dynamic dialog system for React + MUI (Material UI). Quickly open confirmation or custom dialogs from anywhere in your app using a Provider and a simple hook.

  • Framework: React 18+
  • UI: MUI v7
  • Language: TypeScript
  • Bundler: Vite

Features

  • Open dialogs programmatically from anywhere
  • Fully typed options and slots (override MUI components or provide your own)
  • Default confirm/cancel actions, texts, and order
  • Per-dialog or global defaults via Provider

Installation

Install via your favorite package manager:

# npm
npm install @nardole/material-ui-dynamic-dialog

# yarn
yarn add @nardole/material-ui-dynamic-dialog

# pnpm
pnpm add @nardole/material-ui-dynamic-dialog

Peer dependencies you must have in your app:

  • react, react-dom (>=18)
  • @mui/material (>=7)

Quick Start

Wrap your application with the provider once (usually near the root):

import React from "react";
import ReactDOM from "react-dom/client";
import { CssBaseline, ThemeProvider, createTheme } from "@mui/material";
import App from "./App";
import { DynamicDialogProvider } from "@nardole/material-ui-dynamic-dialog";

const theme = createTheme({
  palette: {
    mode: "light",
    primary: { main: "#1976d2" },
  },
});

ReactDOM.createRoot(document.getElementById("root")!).render(
  <React.StrictMode>
    <ThemeProvider theme={theme}>
      <CssBaseline />
      <DynamicDialogProvider>
        <App />
      </DynamicDialogProvider>
    </ThemeProvider>
  </React.StrictMode>,
);

Open a dialog from anywhere using the hook:

import { Button } from "@mui/material";
import { useDynamicDialog } from "@nardole/material-ui-dynamic-dialog";

export function Example() {
  const { dialog } = useDynamicDialog();

  const handleClick = () => {
    const { id, close } = dialog({
      title: "Delete item",
      content:
        "Are you sure you want to delete this item? This action cannot be undone.",
      confirmText: "Delete",
      cancelText: "Cancel",
      onConfirm: () => {
        // perform delete
        console.log("confirmed", id);
      },
      onCancel: () => console.log("canceled", id),
    });

    // You can later close it programmatically if needed:
    // close();
  };

  return <Button onClick={handleClick}>Open Dialog</Button>;
}

API

Provider

Props for <DynamicDialogProvider />:

| Prop | Type | Default | Description | | --------------- | -------------------- | ------- | -------------------------------------------------------------------- | | defaultOptions? | DynamicDialogOptions | — | Options applied globally to every dialog unless overridden per call. |

Hook

useDynamicDialog() returns an API object:

| Member | Signature | Returns | Description | | -------------- | ------------------------------------------------------- | --------------------------------- | ------------------------------------------------------------------------- | | dialog | (options: DynamicDialogOptions) | { id: string; close: () => void } | Opens a new dialog with the provided options and returns id and close fn. | | close | (id: string, reason?: 'confirm' | 'cancel' | 'close') | void | Closes a dialog by id. Reason is optional and used by callbacks/guards. | | remove | (id: string) | void | Immediately removes a dialog node by id (usually close is preferred). | | defaultOptions | — | DynamicDialogOptions | undefined | Provider-level default options (if set). |

Options

DynamicDialogOptions (defaults in parentheses):

| Name | Type | Default | Description | | -------------------------- | ----------------------------------------------------------------- | ----------------- | ---------------------------------------------------------------------------- | | title? | React.ReactNode | (null) | Dialog title content. | | content? | React.ReactNode | (null) | Dialog body content. | | confirmText? | string | "Confirm" | Label for the confirm button. | | cancelText? | string | "Cancel" | Label for the cancel button. | | slots?.Dialog? | React.ComponentType | MUI Dialog | Root dialog component to render. | | slotsProps?.dialog? | Omit<React.ComponentProps, 'open'> | {} | Props for slots.Dialog (except open, which is controlled). | | slots?.DialogTitle? | React.ComponentType | MUI DialogTitle | Component for title area. | | slotsProps?.dialogTitle? | React.ComponentProps | {} | Props for slots.DialogTitle. | | slots?.DialogContent? | React.ComponentType | MUI DialogContent | Component for content area. | | slotsProps?.dialogContent? | React.ComponentProps | {} | Props for slots.DialogContent. | | slots?.DialogActions? | React.ComponentType | MUI DialogActions | Component for actions area. | | slotsProps?.dialogActions? | React.ComponentProps | {} | Props for slots.DialogActions. | | slots?.Confirm? | React.ComponentType | MUI Button | Component for confirm button. | | slotsProps?.confirm? | React.ComponentProps | {} | Props for slots.Confirm. | | slots?.Cancel? | React.ComponentType | MUI Button | Component for cancel button. | | slotsProps?.cancel? | React.ComponentProps | {} | Props for slots.Cancel. | | disableClose? | boolean | false | Disable closing via backdrop click/escape. | | disableCancel? | boolean | false | Hide/disable the cancel button. | | disableConfirm? | boolean | false | Hide/disable the confirm button. | | onConfirm? | (id: string) => void | () => {} | Called when confirm button is clicked. | | onCancel? | (id: string) => void | () => {} | Called when cancel button is clicked. | | onClosed? | (id: string) => void | () => {} | Called when dialog is closed via backdrop/escape (when not disabled). | | shouldClose? | (reason: 'confirm' | 'cancel' | 'close', id: string) => boolean | () => true | Guard: return false to prevent closing for a given reason. | | buttonOrder? | Array<'confirm' | 'cancel'> | [] | Controls action buttons order if you need to enforce a specific arrangement. |

You can also open custom body UIs by providing custom slots/components.

Child hook (advanced)

useDynamicDialogChild() → gives { id, close, remove } for the currently rendered dialog, useful when rendering custom content that needs to close itself.

Local Development

Prereqs: Node 18+, pnpm/yarn/npm.

  • Install deps: yarn (or npm i, pnpm i).
  • Build: yarn build
  • Typecheck: yarn typecheck
  • Lint/format check: yarn lint:format
  • Format: yarn format

This is a library repo (no dev server). You can link it into a test app with yarn link/npm link or use pnpm/yarn workspace.

Contributing

See CONTRIBUTING.md for detailed guidelines.

Quick version:

  • Fork the repo and create a feature branch
  • Run build and checks locally before opening a PR
  • Open a Pull Request using the provided template

License

MIT © Luiz Braga

Acknowledgements

  • Built with MUI and Vite