1.0.4 • Published 9 months ago

hrnet-react-modal-101 v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

HRnet React Modal

This repository contains a simple React component that can be used to render a modal.

Prerequisites

Getting Started

Install package

npm install hrnet-react-modal-101
or
yarn add hrnet-react-modal-101

Import the Modal component

import { Modal } from "hrnet-react-modal-101"

You can then render the Modal component like any other React component in JSX.

Using the Modal component

import React, { useState } from 'react';
import { Modal } from 'hrnet-react-modal-101';

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

  const openModal = () => {
    setIsOpen(true);
  };

  const closeModal = () => {
    setIsOpen(false);
  };

  return (
    <div>
      <button onClick={openModal}>Open Modal</button>
      <Modal isOpen={isOpen} onClose={closeModal}>
        <h2>Modal Content</h2>
        <p>This is the content of the modal.</p>
      </Modal>
    </div>
  );
}

export default App;

Props

PropTypeDescription
isOpenbooleanDetermines if the modal is open or closed
onClosefunctionFunction used to close the modal
modalCustomStyleObjectCustom styles for the modal
childrenReact.ReactNodeContent to be displayed within the modal

Customizing Modal Styles

The modalCustomStyle prop allows you to apply custom styles to the modal. You can pass an object with CSS properties to this prop to achieve the desired look and feel. Here's an example:

import React, { useState } from 'react';
import { Modal } from 'hrnet-react-modal-101';

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

  const openModal = () => {
    setIsOpen(true);
  };

  const closeModal = () => {
    setIsOpen(false);
  };

  const customModalStyle = {
    backgroundColor: 'lightblue',
    border: '2px solid blue',
    borderRadius: '10px',
    padding: '20px'
  };

  return (
    <div>
      <button onClick={openModal}>Open Modal</button>
      <Modal isOpen={isOpen} onClose={closeModal} modalCustomStyle={customModalStyle}>
        <h2>Custom Styled Modal</h2>
        <p>This modal has a custom style applied.</p>
      </Modal>
    </div>
  );
}

export default App;

In this example, we're passing a customModalStyle object to the modalCustomStyle prop. This prop allows you to provide custom styles for the modal according to your needs.

Publishing on NPM

The HRnet React Modal is available as an npm package. You can find it here.

License

This project is licensed under the ISC License.

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago