Skip to content

feat(modal): add position prop, default to middle#1091

Open
David-Crty wants to merge 1 commit into
robsontenorio:mainfrom
David-Crty:feat/modal-position-prop
Open

feat(modal): add position prop, default to middle#1091
David-Crty wants to merge 1 commit into
robsontenorio:mainfrom
David-Crty:feat/modal-position-prop

Conversation

@David-Crty
Copy link
Copy Markdown

@David-Crty David-Crty commented May 27, 2026

What

Adds a position prop to <x-modal> mapping to daisyUI's position modifiers: top, middle, bottom, start, end. Default is middle.

<x-modal wire:model="show" />                  {{-- modal modal-middle --}}
<x-modal wire:model="show" position="top" />   {{-- modal modal-top --}}
<x-modal wire:model="show" position="" />      {{-- modal (previous behavior) --}}

Why

Mary currently renders <dialog class="modal"> with no position class. daisyUI's bare .modal-box uses max-height: 100vh with no margin — only the modal-middle/top/bottom variants get the calc(100vh - 5em) buffer.

On mobile, 100vh extends under the browser chrome, so when content overflows, the close button (absolute top-2) and modal-action row are clipped:

Before - close button hidden at top:
image

After
image

Adds a `position` prop that maps to daisyUI's modal position modifiers
(`modal-top`, `modal-middle`, `modal-bottom`, `modal-start`, `modal-end`).

Defaults to `middle` to fix a long-standing mobile UX papercut: daisyUI's
bare `.modal-box` (i.e. no position class) uses `max-height: 100vh` with
no margin, so when content exceeds the viewport the close button and the
modal-action row get clipped under the browser chrome on mobile. Setting
a position modifier applies the documented `calc(100vh - 5em)` buffer.

Opt out with `position=""` to keep the previous edge-to-edge behavior.
@robsontenorio
Copy link
Copy Markdown
Owner

There is no need of a extra attribute.

All classes are merged together at ->class(["modal"])

This

<x-modal ... class="modal-top" />

Becomes

<div class="modal modal-top" />

@David-Crty
Copy link
Copy Markdown
Author

David-Crty commented May 27, 2026

Yes, I agree; to me, it's just a way to have a "better default."

Current default modals are broken on mobile when they exceed the height of the screen.

@robsontenorio
Copy link
Copy Markdown
Owner

robsontenorio commented May 27, 2026

I think this a daisyUI stuff on recent updates.
Maybe raising an issue on its repository should help them to investigate it (with a pure daisyUI CSS example).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants