0.0.1 • Published 4 months ago

am-react-modal v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

AM React Modal Component

A customizable and accessible modal dialog component for React applications.

Installation

Install the component using npm:

npm install am-react-modal --save

Usage

Import the Modal component in your React application and use it as follows:

import React, { useState } from 'react'
import Modal from 'am-react-modal'

function App() {
  const [isOpen, setIsOpen] = useState(false)

  const openModal = () => setIsOpen(true)
  const closeModal = () => setIsOpen(false)

  return (
    <>
      <button onClick={openModal}>Open Modal</button>
      <Modal
        isOpen={isOpen}
        onClose={closeModal}
        title='Your Title Here'
        content={<p>Your content here</p>}
      />
    </>
  )
}

export default App

Props

The component accepts the following props:

PropTypeDescription
isOpenbooleanControls the visibility of the modal.
onClosefunctionCallback function to close the modal.
titlestringThe title content of the modal.
contentnodeThe body content of the modal.
overlayClassNamestringClass for the modal overlay.
contentClassNamestringClass for the modal content.
titleClassNamestringClass for the modal title.
bodyClassNamestringClass for the modal body.
footerClassNamestringClass for the modal footer.
closeButtonClassNamestringClass for the modal close button.

Styling

Default CSS classes :

ClassDescription
.modal-overlayClass for the modal overlay.
.modal-contentClass for the modal content.
.modal-titleClass for the modal title.
.modal-bodyClass for the modal body.
.modal-footerClass for the modal footer.
.modal-close-buttonClass for the modal close button.

You can style the modal using the provided CSS class names or by passing your own custom classes as props.

Accessibility

The Modal component follows WAI-ARIA best practices for modal dialogs, ensuring that it is accessible to users with disabilities.

License

Distributed under the MIT License.