Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mickmickmick's avatar

Modal max-width with Inertia vue js 3

Hi, I'm working on a project using Inertia.js with Vue 3. On one of my pages, I'm using a Modal component and I want to change its size. According to the documentation:

The max-width lets you specify the maximum width of the modal. For modals, the default value is 2xl, and for slideover, the default value is md. These values correspond to Tailwind CSS conventions. Valid values are sm, md, lg, xl, 2xl, 3xl, 4xl, 5xl, 6xl, and 7xl.

This works fine up to 2xl, but from 3xl onward, the class seems to be ignored, and the modal becomes full-width.

For example, when I use this:

<Modal :show="showEditOrderModal" @close="closeEditOrderModal" max-width="2xl">

The resulting element has the class:

<div class="mb-6 bg-white rounded-lg overflow-hidden shadow-xl transform transition-all sm:w-full sm:mx-auto sm:max-w-2xl" style="">

However, if I change it to:

<Modal :show="showEditOrderModal" @close="closeEditOrderModal" max-width="3xl">

The resulting element becomes:

<div class="mb-6 bg-white rounded-lg overflow-hidden shadow-xl transform transition-all sm:w-full sm:mx-auto" style="">

Notice how the 3xl class is missing.

Any idea why the size is being ignored for 3xl and beyond? I really need the modal to be wider.

Thank you!

0 likes
2 replies
Thriddle's avatar

Did you write the Modal component yourself or did you use a package? Can you give a link to that resource?

mickmickmick's avatar

Thank you for your answer; it actually helped me solve the issue.

I was working with the Inertia model component, which I import using:

import Modal from '@/Components/Modal.vue';

I opened that file and found the following code:

I then edited this part:

const maxWidthClass = computed(() => {
    return {
        sm: 'sm:max-w-sm',
        md: 'sm:max-w-md',
        lg: 'sm:max-w-lg',
        xl: 'sm:max-w-xl',
        '2xl': 'sm:max-w-2xl',
    }[props.maxWidth];
});

to:

const maxWidthClass = computed(() => {
    return {
        sm: 'sm:max-w-sm',
        md: 'sm:max-w-md',
        lg: 'sm:max-w-lg',
        xl: 'sm:max-w-xl',
        '2xl': 'sm:max-w-2xl',
        '3xl': 'sm:max-w-3xl',
        '4xl': 'sm:max-w-4xl',
        '5xl': 'sm:max-w-5xl',
        '6xl': 'sm:max-w-6xl',
        '7xl': 'sm:max-w-7xl',
    }[props.maxWidth];
});

And it started working properly. I'm not sure if this is the best way to do it or if I should integrate the edit into the native modal component without changing the original code. I'm new to Vue.js and Inertia, so any advice would be greatly appreciated.

Thank you again for pointing that out.

Please or to participate in this conversation.