Dialog also Modal

ray-elements's modal, on the native <dialog>: top layer, the rest of the page inert, focus trapped and restored, stackable. Title, description, header, body and footer; preset or free sizes. Also exports confirmDialog().

Source on GitHub

The modal
ray-dialog is the modal of ray-elements Backdrop, inert page, trapped and restored focus, Escape, stacking. This one takes 70% of the window (size="70%" height="70%") and holds a whole settings screen: vertical tabs, fields, a table, sliders, switches and a confirmation stacked on top.
Project settings
Live General Members Build Notifications Danger zone
Visibility
Invite
Every build Failures only Nothing
These actions affect everyone in the project and cannot be undone.
Transfer ownershipMove ray-remote to another team.
Transfer…
Delete projectRemoves builds, releases and the update channel.
Delete…
Last saved 2 minutes ago Cancel Save changes
Patterns
RenameOne field, focused on open; the button's value is the returnValue.
Open
ConfirmconfirmDialog() builds one and resolves to true or false.
Delete…
Create projectA larger form (size lg) with a header badge; read its fields on ray-close.
Open
Unsaved changesPersistent: no ×, Escape or backdrop; one of three answers.
Open
Guarded draftray-request-close is cancelable: closing a written note asks first.
Open
Keyboard shortcutsLong content near the top (position top): the body scrolls, header and footer stay.
Open
Build logsize="full" for a workspace: almost the whole window.
Open
What's newSmall and announcement-like (size sm), with a hero and a single action.
Open
Cancel Rename
raylang 1.27
Frontend
Cancel Create

Your changes will be lost if you close without saving.

Don't save Cancel Save
Cancel Save note
General
Command palette⌘K
Settings⌘,
Toggle sidebar⌘B
Toggle theme⌘⇧L
Editor
Save⌘S
Find⌘F
Go to line⌃G
Format document⌥⇧F
Comment line⌘/
Run
Run program⌘R
Run tests⌘⇧T
Build native⌘⇧B
Stop⌘.
Navigation
Next tab⌃Tab
Previous tab⌃⇧Tab
Go to file⌘P
Go back⌃-
Done
Passed
$ ray build --native --release src/main.ray
  compiling std/ui, std/json, net 0.5.0, web 0.4.6
  checking  42 modules · 0 warnings
  linking   target/release/ray-remote (4.2 MB)
$ ray test
  ok   session: resumes after reconnect (12 ms)
  ok   files: upload with progress (31 ms)
  ok   files: rejects paths outside the root (2 ms)
  ok   ui: palette lists the menu commands (48 ms)
  ok   ui: theme follows the system (7 ms)
  result: 5 test(s), all passed ✓
$ ray bundle --name "Ray Remote" -o dist
  bundle    dist/Ray Remote.app (ad-hoc signed)
  done in 18.4 s
Close Show in folder
  • New ray-toggle and ray-toggle-group
  • New ray-file-upload with drag and drop
  • Changed every value change is a change event
  • Docs React and Vue code for every example
Got it
Code

In a raylang app

With the native bridge, confirmDialog() asks with the system's modal dialog instead of a ray-dialog, with the same answer. A red confirmation (a destructive action) gets the warning style. native: false keeps the page's dialog, for a question that needs more than a sentence.

if (await confirmDialog({ label: "Delete 3 builds?", message: "This cannot be undone.", confirmLabel: "Delete", color: "red" })) {
  window.ray.send("delete:" + ids.join(","));
}

ray-dialog itself is always the page's: a form, a settings panel or a wizard stay in the page.

API

For AI agents: this API as Markdown, or every component in llms-full.txt.

<ray-dialog> · RayDialog

Any slotted element with data-dialog-close closes it (its value becomes returnValue). JS: show(), close(returnValue), confirmDialog({ label, message, confirmLabel, cancelLabel, color, native }) -> Promise<boolean>; with a native host (ray-elements/core/raylang.js in a std/ui window) it asks with the system dialog unless native is false, and with the ray-dialog when the system cannot (on a phone, where the bridge does not offer it, or when the call fails).

PropertyAttributeTypeDefaultDescription
openopen reflectsbooleanShown as a modal.
labellabelstringHeading (also the dialog's accessible name).
descriptiondescriptionstringA line under the title (the dialog's accessible description).
sizesize reflectsstringmdWidth: xs…xl, full (the whole window), or any CSS length; a percentage is of the window (70% = 70vw, at least 40rem). Never wider than the window.
heightheight reflectsstringFixed height (the body scrolls): any CSS length; a percentage is of the window (70% = 70dvh, at least 30rem). Never taller than the window. Default: as tall as the content, up to the window.
radiusradius reflectsstringCorner radius: xs…xl, none, or a CSS length. Default: lg.
positionposition reflectscenter | topcenterVertical placement.
persistentpersistent reflectsbooleanEscape and backdrop clicks do not close it (the × still does; hide it with hide-close). To allow only one of them, cancel ray-request-close by its source.
hideClosehide-close reflectsbooleanNo close button in the header.
closeLabelclose-labelstringClose (text dialog.close)The close button's name, for screen readers.
overlayBluroverlay-blurstringBlur of the page behind: px ("8"), a CSS length or "none". Default: --ray-overlay-blur ([overlay] blur in tokens.toml).
EventDescription
ray-openAfter it opened.
ray-closeAfter it closed; detail: { returnValue }.
ray-request-closeEscape, backdrop or close button; cancelable (preventDefault keeps it open). detail: { source }.
SlotDescription
(default)Body.
headerExtra header content, next to the title.
footerActions, aligned to the end.
PartDescription
dialogThe native <dialog>.
titleThe heading.
descriptionThe line under the heading.
headerThe header: title, description, the header slot and the close button.
bodyThe scrollable body.
footerThe footer.
closeThe close button.

Texts

What it writes itself, in English; setStrings() translates them (Getting started: Languages).

KeyEnglish
dialog.closeClose
dialog.confirm-labelAre you sure?
dialog.confirmConfirm
dialog.cancelCancel