Skip to main content
ComponentsOverlays

Component · Overlays

Dialog

Canonical modal surface: title, description, body, actions, close policy, focus trap via OverlayStack, initial focus, opener restoration, scrolling, loading, validation; recipes normal/compact/wide/fullscreen/destructive; safe Enter (no accidental submit from body).

Kind
widget
Input
interactive
Canvas
120×40

Live preview

Loading terminal preview.

Static terminal poster. Choose Run live to start the Rust demo.

Ghosttydialog/message
Loading terminal poster…
○ loading posterNo input — rendered state only
Dialog · exact mounted Rust story

01 · Purpose

What it is for

Canonical modal surface: title, description, body, actions, close policy, focus trap via OverlayStack, initial focus, opener restoration, scrolling, loading, validation; recipes normal/compact/wide/fullscreen/destructive; safe Enter (no accidental submit from body).

Best fit: Overlays · overlay · widget

02 · Behavior

What the mounted story proves

  1. 01

    Dialog

    Representative 120×40 terminal state.

  2. 02

    Passive paint

    No keyboard or pointer action is claimed by this representative story.

  3. 03

    Evidence stays explicit

    6 covered · 8 partial · 4 missing axes.

03 · Implement

Install, then start from exact code

Install

cargo add termrock --git https://github.com/tailrocks/termrock.git --rev 5283c2acf9154d0cfcd37b1ffe821c00faf90ea2

Add TermRock once. Keep domain effects in the host application.

Minimal implementation

Exact Rust setup used by dialog/message.

Open to load code.

04 · Adapt

Variants and composition

Variants

Use the preview Variant menu when alternate registered stories exist. Each selection mounts a fresh configuration.

Composition

Overlays · overlay · widget

05 · Reference

API, tokens, accessibility

Tokens

DesignSystemInspect exact story code for roles and capability projection.

Accessibility

Input contract mountedNo input claim in the representative story.

Contract

Evidence in progress6/23 axes covered

06 · Go deeper

Advanced guidance

Authored implementation guidance

Purpose. Frame a short message or choice as a modal layer: title, body, optional actions. TermRock places and paints; you decide open/close policy and effects.

Use ChoiceDialog when actions need stable IDs and keyboard traversal. place_dialog / OverlayStack integrate with Esc peel law.

When to use / when not

Use DialogPrefer
Confirm destructive action—
Short system message—
Multi-step formsForm / FormWizard
Agent trust gatesPermissionPrompt
Fuzzy command jumpCommand palette

Focus law

ConcernOwner
Overlay trap / Esc peelOverlayStack
Surface focus (which layer)Host / InteractionScene
Action cursor among buttonsChoiceDialogState::cursor (host may project scene focus into it)
Tab between action ids when registeredHost scene only — not ChoiceDialog

Outcomes (interaction::Outcome)

  • Ignored
  • Changed — action cursor moved
  • Activated(Id)
  • Cancelled — Esc

Intents

default_choice_dialog_intent — Left/Right (j/k), Home/End, Enter, Esc. Tab is not mapped.

Non-color

  • Cursor: ActionFocused role, or ›label‹ / [label] with ascii / colorless
  • Danger variant: ! title prefix + danger border
  • Backdrop: terminal Reset (not hard black)

Responsive

WidthLayout
≥ 28Horizontal action bar
< 28Vertical stack of actions
height < 3Title/border only

State ownership

TermRockConsumer
Action cursor, hit regions, loading gateOpen policy, message copy, effects
Overlay place/open helpersScene registration of action ids (optional)
Ownership boundary

TermRock owns reusable terminal rendering and interaction state. The host owns domain data, policy, persistence, authorization, and side effects.

Evidence status

6 covered, 8 partial, and 4 missing contract axes. Missing evidence is not a behavior claim.