Adaptive dialog <ha-adaptive-dialog>
+
+ + Responsive dialog component that automatically switches between a full + dialog and bottom sheet based on screen size. +
+ +Demos
+ + + ++ Tip: Resize your browser window to see the + responsive behavior. The dialog automatically switches to a bottom + sheet on narrow screens (<870px width) or short screens + (<500px height). +
+Design
+ +Responsive behavior
+ +
+ The ha-adaptive-dialog component automatically switches
+ between two modes based on screen size:
+
-
+
-
+ Dialog mode: Used on larger screens (width >
+ 870px and height > 500px). Renders as a centered dialog using
+
ha-wa-dialog. +
+ -
+ Bottom sheet mode: Used on mobile devices and
+ smaller screens (width ≤ 870px or height ≤ 500px). Renders as a
+ drawer from the bottom using
ha-bottom-sheet. +
+
+ The mode is determined automatically and updates when the window is
+ resized. To prevent mode changes after the initial mount (useful for
+ preventing form resets), use the block-mode-change
+ attribute.
+
Width
+ ++ In dialog mode, there are multiple width presets available. These are + ignored in bottom sheet mode. +
+ +| Name | +Value | +
|---|---|
small |
+ min(320px, var(--full-width)) |
+
medium |
+ min(580px, var(--full-width)) |
+
large |
+ min(1024px, var(--full-width)) |
+
full |
+ var(--full-width) |
+
Adaptive dialogs have a default width of medium.
Header
+ ++ The header contains a navigation icon, title, subtitle, and action + items. +
+ +| Slot | +Description | +
|---|---|
headerNavigationIcon |
+ + Leading header action (e.g., close/back button). In bottom sheet + mode, defaults to a close button if not provided. + | +
headerTitle |
+ The header title content. | +
headerSubtitle |
+ The header subtitle content. | +
headerActionItems |
+ Trailing header actions (e.g., icon buttons, menus). | +
Header title
+ +
+ The header title can be set using the header-title
+ attribute or by providing custom content in the
+ headerTitle slot.
+
Header subtitle
+ +
+ The header subtitle can be set using the
+ header-subtitle attribute or by providing custom content
+ in the headerSubtitle slot. The subtitle position
+ relative to the title can be controlled with the
+ header-subtitle-position attribute.
+
Header navigation icon
+ ++ In bottom sheet mode, a close button is automatically provided if no + custom navigation icon is specified. In dialog mode, the dialog can be + closed via the standard dialog close button. +
+ +Header action items
+ ++ The header action items usually contain icon buttons and/or menu + buttons. +
+ +Body
+ +The body is the content of the adaptive dialog.
+ +Footer
+ +The footer is the footer of the adaptive dialog.
+ +
+ It is recommended to use the ha-dialog-footer component
+ for the footer and to style the buttons inside the footer as follows:
+
| Slot | +Description | +Variant to use | +
|---|---|---|
secondaryAction |
+ The secondary action button(s). | +plain |
+
primaryAction |
+ The primary action button(s). | +accent |
+
Implementation
+ +When to use
+ +
+ Use ha-adaptive-dialog when you need a dialog that should
+ adapt to different screen sizes automatically. This is particularly
+ useful for:
+
-
+
- Forms and data entry that need to work well on mobile devices +
- + Content that benefits from full-screen presentation on small devices + +
- + Interfaces that need consistent behavior across desktop and mobile + +
+ If you don't need responsive behavior, use
+ ha-wa-dialog directly for desktop-only dialogs or
+ ha-bottom-sheet for mobile-only sheets.
+
+ Use the block-mode-change attribute when you want to
+ prevent the dialog from switching modes after it's opened. This is
+ especially useful for forms, as it prevents form data from being lost
+ when users resize their browser window.
+
Example usage
+ +<ha-adaptive-dialog
+ .hass=\${this.hass}
+ open
+ width="medium"
+ header-title="Dialog title"
+ header-subtitle="Dialog subtitle"
+>
+ <div slot="headerActionItems">
+ <ha-icon-button label="Settings" path="mdiCog"></ha-icon-button>
+ <ha-icon-button label="Help" path="mdiHelp"></ha-icon-button>
+ </div>
+ <div>Dialog content</div>
+ <ha-dialog-footer slot="footer">
+ <ha-button slot="secondaryAction" variant="plain"
+ >Cancel</ha-button
+ >
+ <ha-button slot="primaryAction" variant="accent">Submit</ha-button>
+ </ha-dialog-footer>
+</ha-adaptive-dialog>
+
+ Example with block-mode-change for forms:
<ha-adaptive-dialog
+ .hass=\${this.hass}
+ open
+ header-title="Edit configuration"
+ block-mode-change
+>
+ <ha-form .schema=\${schema} .data=\${data}></ha-form>
+ <ha-dialog-footer slot="footer">
+ <ha-button slot="secondaryAction" variant="plain"
+ >Cancel</ha-button
+ >
+ <ha-button slot="primaryAction" variant="accent">Save</ha-button>
+ </ha-dialog-footer>
+</ha-adaptive-dialog>
+
+ API
+ +
+ This component combines ha-wa-dialog and
+ ha-bottom-sheet with automatic mode switching based on
+ screen size.
+
Attributes
+ +| Attribute | +Description | +Default | +Options | +
|---|---|---|---|
open |
+ Controls the adaptive dialog open state. | +false |
+ false, true |
+
width |
+ + Preferred dialog width preset (dialog mode only, ignored in + bottom sheet mode). + | +medium |
+
+ small, medium, large,
+ full
+ |
+
header-title |
+ Header title text when no custom title slot is provided. | ++ | + |
header-subtitle |
+ + Header subtitle text when no custom subtitle slot is provided. + | ++ | + |
header-subtitle-position |
+ Position of the subtitle relative to the title. | +below |
+ above, below |
+
aria-labelledby |
+ + The ID of the element that labels the dialog (for + accessibility). + | ++ | + |
aria-describedby |
+ + The ID of the element that describes the dialog (for + accessibility). + | ++ | + |
block-mode-change |
+ + When set, the mode is determined at mount time based on the + current screen size, but subsequent mode changes are blocked. + Useful for preventing forms from resetting when the viewport + size changes. + | +false |
+ false, true |
+
CSS custom properties
+ +| CSS Property | +Description | +
|---|---|
--ha-dialog-surface-background |
+ Dialog/sheet background color. | +
--ha-dialog-border-radius |
+ Border radius of the dialog surface (dialog mode only). | +
--ha-dialog-show-duration |
+ Show animation duration (dialog mode only). | +
--ha-dialog-hide-duration |
+ Hide animation duration (dialog mode only). | +
Events
+ +| Event | +Description | +
|---|---|
opened |
+ + Fired when the adaptive dialog is shown (dialog mode only). + | +
closed |
+ + Fired after the adaptive dialog is hidden (dialog mode only). + | +
after-show |
+ Fired after show animation completes (dialog mode only). | +
Focus management
+ +
+ To automatically focus an element when the adaptive dialog opens, add
+ the
+ autofocus attribute to it. Components with
+ delegatesFocus: true (like ha-form) will
+ forward focus to their first focusable child.
+
Example:
+ +<ha-adaptive-dialog .hass=\${this.hass} open>
+ <ha-form autofocus .schema=\${schema}></ha-form>
+</ha-adaptive-dialog>
+