Skip to content
nexus-dialogs
GitHub npm

Dialogs, forms and wizards

Built on the native <dialog>, with no dependencies and tested accessibility.

For : vacation requests, new hires, approvals with a reason, deletes with confirmation and importing from Excel.

npm i nexus-dialogs
empleados.ts
import { confirmDelete } from 'nexus-dialogs/patterns'

if (await confirmDelete({ what: 'Laura Méndez' })) {
  await api.employees.remove(id)
}
Runs with this page’s library

See it in action

It is a mockup you can use: type, click and try the validation. Pick the scene and the appearance; the real dialogs on this page change with the appearance.

View code
import { confirmDelete } from 'nexus-dialogs/patterns'

import { confirmDelete } from 'nexus-dialogs/patterns'

if (await confirmDelete({ what: 'Laura Méndez' })) {
  // delete
}

—npm downloads, last week
11.2 KBthe core, gzip
9HR templates
AAWCAG 2.2 target, with axe tests
No dependencies TypeScript Shadow DOM WCAG 2.2 AA target Vue React Angular SweetAlert2
npm v1.1.1 core 11.2 KB gzip license MIT CI tests on every change

What’s new

The latest in version 1.1.1. See all changes.

Tabs

General data, appointment and interview in a single dialog, with keyboard and screen reader support. Try it · Guide

Step-by-step tracking

The progress of a candidate or a procedure with status, date and progress, vertical or horizontal. Try it · Guide

Sizes and responsive

Tabs and tracking in sm, md or lg, adapting to the available width, also on phones. Try it · Guide

Safe HTML by default

An html string is shown as text unless you allow it with strictHtml or filter it with sanitize, also in the no-bundler build with Swal.configure. Security

Forms in columns

columns: 'auto': two columns on the phone, three on desktop, and long fields on a full row. Guide

Try it right here

These buttons use this page’s library, not screenshots.

Why

Alerts solve the “Are you sure?” and little else. nexus-dialogs also brings forms with validation, multi-step wizards, Excel import and export, Mexican validators and HR templates.

A real top layer

No z-index wars with Bootstrap, other libraries or your sticky menu. The background becomes inert and scrolling is locked.

Shadow DOM

Your page’s CSS doesn’t break it and its own doesn’t leak out. It works with a strict CSP, without unsafe-inline.

Promises that don’t fail

const r = await dialog.confirm(…) always resolves with { confirmed, denied, value, reason }.

Truly accessible

Correct initial focus, Esc, focus return, errors tied to each field, announced toasts and reduced motion. Tested with axe.

Made for HR and accounting

RFC, CURP, NSS and CLABE with check digit, amounts in pesos, business days and holidays, signature, address by postal code.

Migrate from SweetAlert2

Change the import and your code keeps working. See how to migrate.

One piece instead of several

What in a business system is usually assembled from different packages comes here in a single one, with no dependencies.

What you usually assemble from several packages and where it is in nexus-dialogs
What you needUsually built withIn nexus-dialogs
Confirm, approve, warn about changesAn alerts or modals libraryconfirmDelete, approval, unsavedChanges
Forms with validationA forms library and another for validationform, with RFC, CLABE and more already validated
Dates and business daysA separate calendar componentThe daterange field with businessDays
Import and export ExcelOne more utility, with its own interfaceimportData and exportData
Notices that disappearA toast librarytoast, with “Undo”
AccessibilityChecking each piece separatelyFocus, keyboard and WCAG 2.2 AA target, with axe tests

Every piece you add is another version to update and another style to match. Here it is one, with a single theme.

In one line

Each recipe already comes with the right text, buttons, focus and accessibility.

import { dialog } from 'nexus-dialogs'
import { confirmDelete } from 'nexus-dialogs/patterns'
import { form } from 'nexus-dialogs/forms'
import { toast } from 'nexus-dialogs/toast'

if (await confirmDelete({ what: 'Laura Méndez' })) await api.employees.remove(id)

const r = await form({
  title: 'New expense',
  fields: [
    { name: 'rfc', label: 'Supplier RFC', type: 'rfc', required: true },
    { name: 'amount', label: 'Amount', type: 'money', required: true },
  ],
})
if (r.confirmed) toast.success('Sent for approval')

Modules: install only what you use

Sizes measured when building this site (minified + gzip). Each path is imported separately.

PathWhat forSize
nexus-dialogsalert, confirm, prompt, open11.2 KB
nexus-dialogs/formsform, wizard, formFromJSON and the fields24.9 KB
nexus-dialogs/toastQueued notices5.1 KB
nexus-dialogs/patternsRecipes: delete, unsaved, session, approve, bulk actions6.2 KB
nexus-dialogs/importImport and export CSV and Excel10.1 KB
nexus-dialogs/tableChoose rows from a table3.6 KB
nexus-dialogs/tabsAccessible tabs, standalone or in a dialog; sizes and responsive3.2 KB
nexus-dialogs/timelineStep tracking with status, date and progress2.9 KB
nexus-dialogs/mxRFC, CURP, NSS, CLABE, business days1.1 KB
nexus-dialogs/rrhhHR templates in JSON4.0 KB
nexus-dialogs/themesBootstrap, Tailwind, Material, dark1.3 KB
nexus-dialogs/vue · /reactPlugin and hooks that close the dialogs on unmount0.8 KB · 1.0 KB
nexus-dialogs/swalSweetAlert2 compatible7.5 KB

Paths that depend on the core share it: it is not downloaded twice.