1.0.0 • Published 12 months ago

@ludwig801/vue3-dialog v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Vue 3 Dialog

This is a component which builds a barebones modal using the HTML5 <dialog> element. The dialog element has only the necessary inline styling to make sure the elements are coherent with the expected behaviour. Any extra styling should be provided via the *-class props.

Installation (ES Module)

npm i @ludwig801/vue3-dialog

Exports

  • LMDialog: a barebones <dialog> with only the backdrop and the content slot.

LMDialog

Properties

PropertyTypesRequiredDefaultDescription
v-model:openboolean:white_check_mark:falseOpens/closes the dialog window.
widthstring"24rem"A CSS string determining the base width of the content element.
max-widthstring"calc(100vw - 4rem)"A CSS string determining the max width of the content element.
animation-timenumber150The duration, in ms, of the open/close animation. (0 disables the animation).
backdrop-classstringobjectundefinedThe class or classes to the apply to the backdrop element.
content-classstringobjectundefinedThe class or classes to the apply to the content-wrapping element.

Events

EventArgumentsTrigger
update:openopen: boolean - the new stateThe dialog's open state is changed via user interaction
open:beginThe dialog has started the opening animation Called even when animationTime is 0.
open:endThe dialog has finished the opening animation Called even when animationTime is 0.
close:beginThe dialog has started the closing animation Called even when animationTime is 0.
close:endThe dialog has finished the closing animation Called even when animationTime is 0.

Slots

SlotBindingsDescription
defaultThe dialog's default slot, where the content will be placed.
backdropUsed to customize the appearance of the backdrop, if backdrop-class is not enough.

Example usage

<template>
  <div>
    <button type="button" @click="isOpen = true">Open the dialog</button>
    <LMDialog
      v-model:open="isOpen"
      width="200px"
      max-width="100vw"
      backdrop-class="bg-slate-900"
      content-class="bg-slate-100 text-slate-900"
      @open:begin="isOpening"
      @open:end="hasOpened"
      @close:begin="isClosing"
      @close:end="hasClosed"
    >
      This is the dialog's content
    </LMDialog>
  </div>
</template>

<script setup>
import { ref } from "vue"
import { LMDialog } from "@ludwig801/vue3-dialog"

const isOpen = ref(false)

function isOpening() { ... }
function hasOpened() { ... }

function isClosing() { ... }
function hasClosed() { ... }
</script>
1.0.0

12 months ago

0.2.4

12 months ago

0.2.3

12 months ago

0.2.2

12 months ago

0.2.1

12 months ago

0.2.0

12 months ago

0.1.8

12 months ago