OpenParable
Skip to content
← Back to skills

Rezi Modal Dialogs

Development
rezi-modal-dialogs

Rezi Modal Dialogs is an Agent Skill for development published in the RtlZeroMemory/Rezi repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Add modal dialogs and overlay UI with focus trapping. Use when implementing confirmations, alerts, or layered interfaces.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/RtlZeroMemory/Rezi/blob/HEAD/.claude/skills/rezi-modal-dialogs/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/rezi-modal-dialogs, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

When to use

Use this skill when:

  • Adding confirmation dialogs, alerts, or prompts
  • Building layered/overlay UI
  • Need focus trapping within a dialog

Source of truth

  • packages/core/src/widgets/useModalStack.ts — useModalStack() hook
  • packages/core/src/widgets/types.ts — ModalProps, LayersProps
  • packages/core/src/widgets/ui.ts — ui.modal(), ui.layers()
  • packages/core/src/ui/recipes.ts — recipe.modal() and recipe.surface() for design-system-consistent modal styling

Steps

Option A: useModalStack (recommended for multiple modals)

  1. Use useModalStack() inside a defineWidget:
    const modals = useModalStack(ctx);
    
    // Push a modal
    modals.push("confirm", {
      title: "Confirm",
      content: body,
      onClose: () => modals.pop(),
    });
    
    // Include in view
    return ui.layers([mainContent, ...modals.render()]);
    

Option B: ui.modal (simple single modal)

  1. Use ui.modal() directly with a state-controlled flag:

    return ui.layers([
      mainContent,
      ...(state.showModal
        ? [
            ui.modal({
              id: "confirm-modal",
              title: "Confirm",
              initialFocus: "confirm-ok",
              returnFocusTo: "open-confirm",
              onClose: () => app.update((s) => ({ ...s, showModal: false })),
              content: ui.text("Are you sure?"),
              actions: [
                ui.button({
                  id: "confirm-cancel",
                  label: "Cancel",
                  intent: "secondary",
                  onPress: () => app.update((s) => ({ ...s, showModal: false })),
                }),
                ui.button({
                  id: "confirm-ok",
                  label: "OK",
                  intent: "primary",
                  onPress: () => app.update((s) => ({ ...s, showModal: false })),
                }),
              ],
            }),
          ]
        : []),
    ]);
    
  2. Overlay ordering note:

    • Modal, dropdown, and toast overlays share unified z-ordering through the LayerRegistry.
    • Prefer ui.layers([...]) as the common overlay composition root.
  3. Dialog action intent note:

    • Use intent to communicate action semantics in modal/dialog button rows.
    • Recommended mapping: confirm/continue -> primary, cancel/back -> secondary, destructive -> danger, positive approval -> success, cautionary acknowledgment -> warning.

Verification

  • Modal opens and closes correctly
  • Focus traps within the modal (Tab doesn't escape)
  • Focus returns to previous element on close