Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
react-modal-component-hw
Advanced tools
A simple, modular and customizable modal window component for React applications, compatible with Tailwind CSS, allowing easy management of modal windows with styling options.
A simple, modular and customizable modal window component for React applications, compatible with Tailwind CSS, allowing easy management of modal windows with styling options.
To install the Modal component in your React project, use npm or yarn:
npm install react-modal-component-hw clsx lucide-react
or
yarn add react-modal-component-hw clsx lucide-react
The Modal component relies on certain external dependencies to function properly. Here are the minimum required versions of these libraries:
clsx
: Used to conditionally manage CSS classes. You can combine CSS or Tailwind classes via clsx
.
^2.1.1
npm install clsx@^2.1.1
Or
yarn add clsx@^2.1.1
lucide-react
: Used for SVG icons, including the close icon in the modal.
^0.446.0
npm install lucide-react@^0.446.0
Or
yarn add lucide-react@^0.446.0
clsx
package allows you to use Tailwind for class and style management if you wish.Make sure you have installed these dependencies for the component to function properly in your project.
This should cover the minimum requirements for clsx
, lucide-react
and other aspects related to the component's compatibility.
To use the Modal component and its sub-components, import it into your file and incorporate it into your JSX code:
import React, { useState } from 'react';
import { Modal, ModalContent, ModalHeader, ModalTitle, ModalDescription, ModalFooter } from 'react-modal-component-hw';
const App = () => {
const [isOpen, setIsOpen] = useState(false);
const toggleModal = () => {
setIsOpen(!isOpen);
};
return (
<div>
<button onClick={toggleModal}>Open Modal</button>
<Modal open={isOpen}>
<ModalContent onClose={toggleModal}>
<ModalHeader>
<ModalTitle>Title of Modal</ModalTitle>
</ModalHeader>
<ModalDescription>This is the content of the modal.</ModalDescription>
<ModalFooter>
<button onClick={toggleModal}>Close Modal</button>
</ModalFooter>
</ModalContent>
</Modal>
</div>
);
};
export default App;
The Modal component and its sub-components accept the following properties:
open
(required) : A boolean indicating whether the modal should be displayed or not.className
: Additional CSS classes to customize the appearance of the modal.onClose
(required) : A function called when the modal should be closed.className
: Additional CSS classes to customize the content of the modal.size
: The size of the close icon (default 25
).stroke
: The color of the close icon (default #000000
).className
: Additional CSS classes to customize each section of the modal.The Modal component allows you to add custom styles using the clsx
package, which allows you to easily combine Tailwind classes or your own CSS classes. You don't need to use specific base classes, you can directly apply your own styles via the className properties of the different sub-components.
Here is an example of using the component with custom styles:
import { useState } from 'react';
import { Modal, ModalContent, ModalHeader, ModalTitle, ModalDescription, ModalFooter } from 'react-modal-component-hw';
import './styles/main.css';
const App = () => {
const [isOpen, setIsOpen] = useState(false);
const toggleModal = () => {
setIsOpen(!isOpen);
};
return (
<div>
<button className="btn" onClick={toggleModal}>
Open modal
</button>
<Modal className="custom-modal" open={isOpen}>
<ModalContent className="custom-modal-container" onClose={toggleModal} stroke="#dfdfdf" size={32}>
<ModalHeader className="custom-modal-header">
<img className="custom-modal-img" src="./hero.svg" alt="hero" />
<ModalTitle className="custom-modal-title">Title of Modal</ModalTitle>
<ModalDescription className="custom-modal-description">This is the content of the modal.</ModalDescription>
</ModalHeader>
<ModalFooter className="custom-modal-footer">
<button
className="custom-modal-button"
onClick={toggleModal}
>
Close Modal
</button>
</ModalFooter>
</ModalContent>
</Modal>
);
};
export default App;
This project is licensed under the MIT.
FAQs
A simple, modular and customizable modal window component for React applications, compatible with Tailwind CSS, allowing easy management of modal windows with styling and accessibility options
We found that react-modal-component-hw demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.