0.1.5 • Published 11 months ago
ts-simple-modal v0.1.5
ts-simple-modal
ts-simple-modal
is a simple and customizable modal component for React applications, written in TypeScript.
Prerequisites
Before getting started with this project, ensure that you have the following prerequisites installed:
- Node.js (version 18.x.x)
Installation
To install ts-simple-modal
, you can use npm or yarn:
npm install ts-simple-modal
or
yarn add ts-simple-modal
Usage
Here's a simple example of how to use the ts-simple-modal component:
import React, { useState } from 'react';
import Modal from 'ts-simple-modal';
function App() {
const [showModal, setShowModal] = useState(false);
return (
<div>
<button onClick={() => setShowModal(true)}>Open Modal</button>
<Modal
show={showModal}
onClose={() => setShowModal(false)}
>
<h1>Hello, world!</h1>
<p>Welcome to my modal!</p>
</Modal>
</div>
);
}
export default App;
Props
ts-simple-modal accepts the following props:
- show (boolean): Determines whether the modal is visible.
- onClose (function): A function that will be called when the user attempts to close the modal.
- children (ReactNode): The content to display inside the modal.