npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-tailwind-modal

v1.0.7

Published

A modal window for Vue using Tailwind CSS.

Downloads

832

Readme

Vue Tailwind Modal Lightbox

A Vue component that creates a Modal\Lightbox using Tailwind CSS.

Supports Vue 2 and 3, TailwindCSS 1 and 2.

Note: Assumes you already have Tailwind CSS installed in your project (it is not a dependency of this package)

Project setup

npm install --save vue-tailwind-modal

or

yarn add vue-tailwind-modal

Using the modal

Installing globally

In your main js file:

import VueTailwindModal from "vue-tailwind-modal"
Vue.component("VueTailwindModal", VueTailwindModal)

Using within a component

In your component .vue file

import VueTailwindModal from 'vue-tailwind-modal'

export default {
  components: {
	VueTailwindModal,
	...
  },
  ...

Once installed simply use as any other component:

<vue-tailwind-modal
	:showing="true"
	@close="showModal = false"
	:showClose="true"
	:backgroundClose="true"
>
	<!-- Put your modal content here -->
</vue-tailwind-modal>

To hide and show the modal simply pass a boolean to the :showing attribute (true to show, false to hide). You can capture the close event using @close to hide the modal (as in the example above) and do further processing. If you do not wish to show the close button (top right) change :showClose to false.

By default clicking on the background will close the modal. To prevent this change backgroundClose parameter to false.

Custom CSS

You can pass an optional CSS parameter to the component to customise the modal. Simply pass an object with one or more of the following keys:

modalOptions: {
	background: "",
	modal: "max-h-90",
	close: "",
}

The right hand side should contain the Tailwind CSS or standard CSS classes you want to add to the modal.

Then add this to the Modal:

<vue-tailwind-modal
	:showing="true"
	@close="showModal = false"
	:showClose="true"
	:backgroundClose="true"
	:css="modalOptions"
/>

Background colour

If you would like to grey out the background you will need to add the "smoke" background colour to your tailwind.config.js file, an example below:

module.exports = {
	theme: {
		extend: {
			colors: {
				"smoke-900": "rgba(0, 0, 0, 0.9)",
				"smoke-800": "rgba(0, 0, 0, 0.75)",
				"smoke-600": "rgba(0, 0, 0, 0.6)",
				smoke: "rgba(0, 0, 0, 0.5)",
				"smoke-400": "rgba(0, 0, 0, 0.4)",
				"smoke-200": "rgba(0, 0, 0, 0.25)",
				"smoke-100": "rgba(0, 0, 0, 0.1)",
			},
		},
	},
	variants: {},
	plugins: [],
}

Animate in/out

An optional CSS file can be included (using your CSS management technique of choice) css/modal.css that will add a fade in and out animation to the modal.

@import "modal"; // postCSS

Purge CSS in production

When using purge CSS in production you will need to add the smoke background colour you use to the Purge CSS whitelist and inlcude the modules classes for purging. Below is an example tailwind.config.js extract:

module.exports = {
   purge: {
	content: [
		'./apps-ui/portal/layouts/**/*.vue',
		'./apps-ui/portal/pages/**/*.vue',
		'./apps-ui/portal/components/**/*.vue',
		'./apps-ui/portal/plugins/**/*.vue',
		'./apps-ui/portal/static/**/*.vue',
		'./apps-ui/portal/store/**/*.vue',
		'./node_modules/vue-tailwind-modal/src/VueTailwindModal.vue',
	],
	options: {
		// Include the bg-smoke for use when css is compressed
		// see: https://tailwindcss.com/docs/controlling-file-size
		whitelist: ['bg-smoke-800'],
	},
   },
}