Skip to content

ModalDialog

Reusable modal dialog with consistent styling: double border, title bar, optional footer, and solid background that covers board content.

Import

tsx
import { ModalDialog, formatTitleWithHotkey } from "silvery"

Props

PropTypeDefaultDescription
childrenReactNoderequiredDialog content
titlestring--Dialog title (rendered bold in titleColor)
titleColorstring"$primary"Title color override
titleAlign"center" | "flex-start" | "flex-end""center"Title alignment
hotkeystring--Toggle hotkey character (renders [X] prefix in title)
titleRightReactNode--Content on the right side of the title bar
borderColorstring"$border"Border color (cyan reserved for focus rings)
widthnumber--Dialog width
heightnumber--Dialog height (auto-height if omitted)
footerReactNode--Footer hint text (dimColor at bottom)
footerAlign"center" | "flex-start" | "flex-end""center"Footer alignment
onClose() => void--Called when ESC is pressed
focusScopebooleantrueWhether to create a focus scope

Helper: formatTitleWithHotkey

Formats a dialog title with a hotkey prefix. If the hotkey letter appears in the title, highlights it inline.

tsx
formatTitleWithHotkey("Details", "D") // [D]etails
formatTitleWithHotkey("Help", "?") // [?] Help

Usage

tsx
<ModalDialog title="Settings" width={60} footer="ESC to close">
  <Text>Dialog content here</Text>
</ModalDialog>

<ModalDialog title="Help" hotkey="?" titleRight={<Text>1/3</Text>}>
  <Text>Help content</Text>
</ModalDialog>

Visual Structure

+==========================+
|       Dialog Title       |
|                          |
|   Content area           |
|                          |
|       Footer hint        |
+==========================+

Double border, $surface-bg background, paddingX={2}, paddingY={1}.

See Also

  • PickerDialog -- search-and-select dialog built on ModalDialog

Released under the MIT License.