Coder Social home page Coder Social logo

tailwindcss-modal's Introduction

How to use

update your tailwind.config.js file with this code

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ["./src/**/*.{js,jsx,ts,tsx}"],
  purge: [
    "./src/**/*.{js,jsx,ts,tsx}",
    "./node_modules/tailwindcss-modal/**/*.{js,mjs,ts}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
};

src/MyComponent.jsx

import { TailwindcssModal, useModal } from "tailwindcss-modal";

function App() {
  const { isOpen, onOpen, onClose } = useModal();
  return (
    <div className="w-screen">
      <button
        onClick={onOpen}
        className="font-semibold text-lg w-fit bg-red-400 px-3 py-1 rounded-sm"
      >
        Hello
      </button>
      <TailwindcssModal
        className=""
        isOpen={isOpen}
        onClose={onClose}
        closeButton
        closeOnBackdropClick
      >
        <h1 className="text-xl font-bold">Tailwind css Modal</h1>
        <p className="mt-4">
          Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit
          excepturi harum tempore aliquam dolorum corrupti eum quam distinctio
          temporibus est.
        </p>

        <p className="text-center mt-5">build with ๐Ÿ’™ by miral.</p>
      </TailwindcssModal>
    </div>
  );
}

export default App;

Props

name type required description
isOpen boolean required This props is passed to see if modal is open or not.
onClose function required This function is used to close the modal if it is open.
closeButton boolean not required This boolean is passed to show the close in modal.
closeOnBackdropClick boolean not required This boolean is passed to close the modal when we click on backdrop of modal.
backdropBlur 'none', 'sm', 'md', 'lg' not required This prop helps with adding backdrop blur property for your modal.
className string not required This prop is passed to add additional style to your modal.

tailwindcss-modal's People

Contributors

miralsuthar avatar

Stargazers

Roman avatar Keshav Sharma avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.