GitHub

Dialog

A modal dialog using the native HTML dialog element with focus trap, ESC to close, and htmx integration.

<rhx-dialog>

Examples

Basic Dialog

Example Dialog

This is a basic dialog with a title and close button.

Press ESC or click the close button to dismiss.

No Header

Are you sure you want to proceed?

With Footer

Size Variants

Use rhx-size to control the dialog width. Preset values: small, medium, large, full.

Small Dialog

A compact dialog at 24rem wide. Good for confirmations and short messages.

Medium Dialog

The medium size at 32rem wide. Works well for simple forms with a few fields.

Large Dialog

A wide dialog at 48rem. Ideal for multi-column forms, data tables, or detailed content.

Full-Width Dialog

Full-width dialog at 90vw. Useful for complex workflows, dashboards, or image previews.

Custom Width

Pass any CSS width value to rhx-size for a custom dialog width.

Custom Width

This dialog uses a custom width of 40rem set via rhx-size="40rem".

You can use any CSS length: 600px, 70vw, 40rem, etc.

htmx Integration

Edit Profile

Loading...

Properties

Property Type Default Description
rhx-open bool false Whether the dialog is initially open
rhx-label string - Title text displayed in the dialog header
rhx-no-header bool false Hides the default header with title and close button
rhx-size string - Dialog width: small (24rem), medium (32rem), large (48rem), full (90vw), or any CSS width value
rhx-focus-after-swap string "first" CSS selector or "first" for focus target after htmx swap; "none" to disable
id string - Element ID used for dialog open triggers

Accessibility

  • Uses the native <dialog> element with built-in focus trap and inert background.
  • ESC key closes the dialog.
  • Dialog title is linked via aria-labelledby for screen readers.
  • Close button has aria-label="Close".
  • Focus is returned to the trigger element when the dialog closes.