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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@arisyntek/sv-dialog

v0.0.3

Published

A lightweight, accessible dialog component using the native HTML <dialog> element.

Readme

Svelte 5 Dialog Component

A lightweight, accessible dialog component using the native HTML <dialog> element.

Installation

npm i @arisyntek/sv-dialog

Examples Usage

Confirmation Dialog

<script lang="ts">
  import { Dialog } from '@arisyntek/sv-dialog';
  
  let open = $state(false);
  
  function handleConfirm() {
    // do something
    open = false;
  }
</script>

<button onclick={() => open = true}>Open Dialog</button>

<Dialog bind:open closedby="none" --dialog-color="#ad2e24">
  	<form method="dialog">
		<h2>Confirm Delete</h2>
		<p>This action cannot be undone.</p>
		<footer>
			<button onclick={() => open = false} type="reset">Cancel</button>
			<button onclick={handleConfirm} type="submit">Delete</button>
		</footer>
	</form>
</Dialog>

Light Dismiss Dialog

<script lang="ts">
  import { Dialog } from '@arisyntek/sv-dialog';
  
  let open = $state(false);
</script>

<button onclick={() => open = true}>Light Dialog</button>

<Dialog bind:open closedby="any">
  <p>Click outside or press Esc to close</p>
</Dialog>

Non-Modal Dialog

<script lang="ts">
  import { Dialog } from '@arisyntek/sv-dialog';
  
  let open = $state(false);
</script>

<button onclick={() => open = true}>Open Popup</button>

<Dialog bind:open modal={false}>
  <p>Page remains interactive behind this dialog</p>
</Dialog>

Programmatic Control

Programmatic Control lets you control the dialog via a component reference (bind:this) instead of binding the open state:

<script lang="ts">
  import { Dialog } from '@arisyntek/sv-dialog';
  
  let dialogRef;
</script>

<button onclick={() => dialogRef.show()}>Open</button>
<button onclick={() => dialogRef.close('cancelled')}>Close with value</button>

<Dialog bind:this={dialogRef}>
  Content
</Dialog>

Props

| Prop | Type | Default | Description | |------|------|---------|------------------------------------------------------------------------------------------------------| | open | boolean | false | Two-way bindable open state | | modal | boolean | true | Modal (blocks page) or non-modal | | closedby | 'any' \| 'closerequest' \| 'none' | - | any — Light dismiss (click outside, Esc key, or button). closerequest — Esc key or button only. none — Button/programmatic only | | returnValue | string | '' | Bindable return value from forms | | class | string | '' | Additional CSS class | | onclose | (e: Event) => void | - | Close event handler | | oncancel | (e: Event) => void | - | Cancel (Esc) event handler |

Styling

Method 1: CSS Custom Properties

The component exposes CSS variables for easy customization:

<!-- Inline on component -->
<Dialog 
  bind:open
  --dialog-bg="#1e1e1e"
  --dialog-color="white"
  --dialog-radius="1rem"
>
  Dark theme dialog
</Dialog>
/* Or globally in your CSS */
:root {
  --dialog-bg: #1e1e1e;
  --dialog-color: #ffffff;
  --dialog-radius: 1rem;
  --dialog-backdrop: rgb(0 0 0 / 0.8);
}

Available CSS Variables

| Variable | Default | Description | |----------|---------|-------------| | --dialog-bg | white | Background color | | --dialog-color | inherit | Text color | | --dialog-radius | 0.5rem | Border radius | | --dialog-padding | 0 | Dialog padding | | --dialog-content-padding | 1.5rem | Content area padding | | --dialog-max-width | min(90vw, 32rem) | Maximum width | | --dialog-max-height | 85vh | Maximum height | | --dialog-shadow | 0 25px 50px... | Box shadow | | --dialog-backdrop | rgb(0 0 0 / 0.5) | Backdrop color | | --dialog-duration | 0.2s | Animation duration | | --dialog-easing | ease-out | Animation easing | | --dialog-scale-from | 0.95 | Scale animation start |

Method 2: Custom Class + Global Styles

<Dialog bind:open class="my-dialog">
  Content
</Dialog>
/* In global CSS or :global() block */
:global(.my-dialog) {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 1rem;
}

:global(.my-dialog::backdrop) {
  background: rgb(0 0 0 / 0.8);
  backdrop-filter: blur(4px);
}

Accessibility

  • Uses native <dialog> element with built-in accessibility
  • Modal dialogs trap focus automatically
  • Esc key closes modal dialogs by default
  • Proper aria-modal handling via showModal()

Browser Support

All modern browsers since March 2022 with <dialog> element support.