
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
svelte-a11y-dialog
Advanced tools
Experimental!
This is a Svelte wrapper component for a11y-dialog@7.3.0
npm install svelte-a11y-dialog
After installing the npm package, import the SvelteA11yDialog component
and optionally setup a dialog instance binding:
import { SvelteA11yDialog } from "svelte-a11y-dialog";
let dialogInstance;
const assignDialogInstance = (instance) => {
dialogInstance = instance;
}
Then use as follows:
<button
type="button"
data-a11y-dialog-show="a11y-dialog"
>Open dialog</button>
<SvelteA11yDialog
id="a11y-dialog"
dialogRoot="#dialog-root"
closeButtonLabel="My close button label"
closeButtonPosition="last"
title="A11yDialog Test"
titleId="uniqueTitleId"
role="dialog"
on:instance={assignDialogInstance}
>
<svelte:fragment slot="closeButtonContent">
<span>Close</span>
</svelte:fragment>
<div>
<p>This is some content</p>
</div>
</SvelteA11yDialog>
In your main index.html, add a container where your dialog will be rendered into — dialog-root in this example:
<!DOCTYPE html>
<html>
<body>
<div id="app"></div>
<div id="dialog-root"></div>
</body>
</html>
The
a11y-dialogdocumentation is here
ididStringtrueid attribute added to the dialog element, internally used by a11y-dialog to manipulate the dialog.dialogRootdialogRootString — CSS Selector string.trueclassNamesclassNamesObjectfalse{}base, overlay, document, title, closeButton. See a11y-dialog docs for reference.titletitleStringtrueclasses.title to it.titleIdtitleIdStringfalseid + '-title'.id attribute of the dialog’s title element, used by assistive technologies to provide context and meaning to the dialog window.closeButtonLabelcloseButtonLabelStringfalse'Close this dialog window'aria-label attribute of the close button, used by assistive technologies to provide extra meaning to the usual cross-mark.roleroleStringfalsedialogrole attribute of the dialog element, either dialog (default) or alertdialog to make it a modal (preventing closing on click outside of ESC key).on:instancea11y-dialog instance when a11y-dialog is instantiated via
a Svelte dispatch event. Note that as is idiomatic in dispatched Svelte events, you need to access the instance via event.detail object (see below).a11y-dialog instance once the component has been instantiated. Here's an example of how to set up in your parent component (pay special note of the ev.detail.instance to gain access to the passed a11y-dialog instance!):<script>
const assignDialogInstance = (ev) => {
dialogInstance = ev.detail.instance;
};
const openDialog = () => {
if (dialogInstance) {
dialogInstance.show();
}
};
</script>
<SvelteA11yDialog on:instance={assignDialogInstance} ...etc
titletitlecloseButtonContentcloseButtonLabel\u00D7 (×)closeButtonPositioncloseButtonPositionfirstfirst, last, or noneThis has only been tested client-side.
FAQs
Svelte component wrapping for a11y-dialog
We found that svelte-a11y-dialog demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.