7.6.2 • Published 1 year ago

mantine-modal-manager v7.6.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Improved Mantine modals manager

npm

This is an extension of @mantine/modals package with improved modals manager that allows to:

  • Open managed modals with full typesafety
  • Keeping the state of parent modals when opening nested modals
  • Has an improved API for managed modals

Installation

# With yarn
yarn add @mantine/hooks @mantine/core mantine-modal-manager

# With npm
npm install @mantine/hooks @mantine/core mantine-modal-manager

Usage

import { createManagedModal, createModalManager } from 'mantine-modal-manager';

// Define modal props:
type InnerProps = {
  title: string;
};

// Create managed modal:
const ExampleModal = createManagedModal<InnerProps>(({ actions, innerProps }) => {
  return (
    <div>
      <p>{innerProps.title}</p>
      <button onClick={actions.closeModal}>Close</button>
    </div>
  );
});

// Somewhere in your app create modal manager:
const [ModalManager, modalEvents] = createModalManager({
  example: ExampleModal,
});

// In your layout use the modal:

export const Layout = () => {
  return (
    <ModalManager>
      <YourApp />
    </ModalManager>
  );
};

// In your app use the modal:
const YourApp = () => {
  const openExampleModal = () =>
    modalEvents.openManagedModal({
      modal: 'example',
      innerProps: {
        title: 'Hello world',
      },
    });

  return (
    <div>
      <button onClick={openExampleModal}>Open modal</button>
    </div>
  );
};

License

MIT

7.6.2

1 year ago

7.6.1

1 year ago

7.6.0

1 year ago

7.5.3

1 year ago

7.5.2

1 year ago

7.5.1

1 year ago

7.5.0

1 year ago

7.4.0

2 years ago

7.3.2

2 years ago

7.3.1

2 years ago

7.3.0

2 years ago

7.1.7

2 years ago

7.1.6

2 years ago

7.1.5

2 years ago

7.1.4

2 years ago

7.2.2

2 years ago

7.1.3

2 years ago

7.2.1

2 years ago

7.1.2

2 years ago

7.2.0

2 years ago

7.1.1

2 years ago

7.1.0

2 years ago

7.0.0

2 years ago

7.0.0-beta.7

2 years ago

7.0.0-beta.6

2 years ago

7.0.0-beta.5

2 years ago

7.0.0-beta.4

2 years ago

7.0.0-beta.3

2 years ago

7.0.0-beta.2

2 years ago

7.0.0-beta.0

2 years ago