New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

tchiki-modal-react

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tchiki-modal-react

customisable react modal

latest
Source
npmnpm
Version
5.0.5
Version published
Maintainers
1
Created
Source

tchiki-modal-react

Description

Just another modal plugin for React. Supports ARIA attributes and is customisable by inline CSS styles.

Table of Contents

  • Installation
  • Properties
  • Example

Installation

Node version: v18.17.1

To install, you can use npm :

$ npm install tchiki-modal-react

Properties

Here is a full list of properties accepted by the plugin :

PropTypeDescriptionDefault Value
isOpenbooleanIndicates whether the modal is open or closed.-
onClose() => voidFunction called when the modal is closed.-
closeButtonReact.ReactNodeCustom React node for the modal's close button.X
styleobjectObject containing custom styles for the modal.-
style.backdropReact.CSSPropertiesCustom styles for the modal backdrop.{ position: "fixed", top: 0, left: 0, width: "100%", height: "100%", backgroundColor: "rgba(0, 0, 0, 0.5)", zIndex: 9998 }
style.modalReact.CSSPropertiesCustom styles for the modal itself.{ position: "relative", color: "#000", backgroundColor: "#fff", padding: "20px", borderRadius: "8px", zIndex: 9999 }
style.closeReact.CSSPropertiesCustom styles for the modal's close button.{ position: "absolute", top: "10px", right: "10px", cursor: "pointer" }

Example

Here is a simple example of tchiki-modal-react being used in an app with some custom styles and focusable input elements within the modal content:

import { useState } from "react";
import { Modal } from "tchiki-modal-react";

const customStyles = {
  backdrop: {
    backgroundColor: "rgba(0, 0, 0, 0.8)",
  },
  modal: {
    backgroundColor: "rgb(207, 255, 229)",
    height: "500px",
  },
  close: {
    backgroundColor: "#3EB489",
    width: "100px",
  },
};

const closeContent = <span>Close</span>;

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

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

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

  return (
    <div>
      <button onClick={handleOpenModal}>Open Modal</button>

      <Modal
        isOpen={isOpen}
        onClose={handleCloseModal}
        closeButton={closeContent}
        style={customStyles}
      >
        <h1>It's a modal</h1>
        <p>An exemple of tchiki-modal-react.</p>
        <form
          style={{
            height: "300px",
            display: "flex",
            flexDirection: "column",
            justifyContent: "space-around",
          }}
        >
          <input />
          <button>tab navigation</button>
          <button>stays</button>
          <button>inside</button>
          <button>the modal</button>
        </form>
      </Modal>
    </div>
  );
}

export default App;

Keywords

react

FAQs

Package last updated on 22 Aug 2023

Did you know?

Socket

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.

Install

Related posts