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().
size="70%" height="70%") and holds a whole settings screen: vertical tabs, fields, a table, sliders, switches and a confirmation stacked on top.
confirmDialog() builds one and resolves to true or false.Your changes will be lost if you close without saving.
| General | |
|---|---|
| Command palette | |
| Settings | |
| Toggle sidebar | |
| Toggle theme | |
| Editor | |
| Save | |
| Find | |
| Go to line | |
| Format document | |
| Comment line | |
| Run | |
| Run program | |
| Run tests | |
| Build native | |
| Stop | |
| Navigation | |
| Next tab | |
| Previous tab | |
| Go to file | |
| Go back | |
$ 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
New ray-toggle and ray-toggle-groupNew ray-file-upload with drag and dropChanged every value change is achangeeventDocs React and Vue code for every example
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).
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
open | open reflects | boolean | Shown as a modal. | |
label | label | string | Heading (also the dialog's accessible name). | |
description | description | string | A line under the title (the dialog's accessible description). | |
size | size reflects | string | md | Width: 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. |
height | height reflects | string | Fixed 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. | |
radius | radius reflects | string | Corner radius: xs…xl, none, or a CSS length. Default: lg. | |
position | position reflects | center | top | center | Vertical placement. |
persistent | persistent reflects | boolean | Escape 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. | |
hideClose | hide-close reflects | boolean | No close button in the header. | |
closeLabel | close-label | string | Close (text dialog.close) | The close button's name, for screen readers. |
overlayBlur | overlay-blur | string | Blur of the page behind: px ("8"), a CSS length or "none". Default: --ray-overlay-blur ([overlay] blur in tokens.toml). |
| Event | Description |
|---|---|
ray-open | After it opened. |
ray-close | After it closed; detail: { returnValue }. |
ray-request-close | Escape, backdrop or close button; cancelable (preventDefault keeps it open). detail: { source }. |
| Slot | Description |
|---|---|
| (default) | Body. |
header | Extra header content, next to the title. |
footer | Actions, aligned to the end. |
| Part | Description |
|---|---|
dialog | The native <dialog>. |
title | The heading. |
description | The line under the heading. |
header | The header: title, description, the header slot and the close button. |
body | The scrollable body. |
footer | The footer. |
close | The close button. |
Texts
What it writes itself, in English; setStrings() translates them (Getting started: Languages).
| Key | English |
|---|---|
dialog.close | Close |
dialog.confirm-label | Are you sure? |
dialog.confirm | Confirm |
dialog.cancel | Cancel |