Open Closed

How to customize the width of a specific <abp-modal> in Angular (not global) #10226


User avatar
0
Belen.molinaMA created

Hello ABP Team,

We are working with ABP Framework (Angular UI) and using the built-in <abp-modal> component.

We need to increase the width of a single modal only, without affecting other modals globally.

🔍 What we are trying to achieve

Make one specific modal wider (XL / ~90% viewport width)

Keep all other modals unchanged

Use supported / recommended ABP approach

Avoid hacks or deprecated Angular features

This modal contains complex content (tabs + editable tables), so the default width is too restrictive for a good UX.

🧪 What we have already tried

size="xl"

<abp-modal size="xl">

➡️ No effect.

dialogClass input

<abp-modal [dialogClass]="'modal-xl'">

➡️ Angular compilation error: Can't bind to 'dialogClass' since it isn't a known property of 'abp-modal'.

CSS via component SCSS

.concept-modal-xl .modal-dialog { max-width: 90vw; }

➡️ No effect due to ViewEncapsulation and modal being rendered outside the component DOM.

CSS via global styles (styles.scss / theme.scss)

.modal-xl .modal-dialog { max-width: 90vw; }

➡️ Works only if applied globally, but this affects all modals, which we want to avoid.

modalClass attribute (as per documentation)

<abp-modal modalClass="modal-xl">

➡️ No visual change in width.

📖 Documentation referenced

https://abp.io/docs/latest/framework/ui/angular/modal

We followed the documentation, but we couldn’t find a clear, working example of how to change the width of only one specific <abp-modal>.

❓ Our questions

What is the official and supported way to change the width of a specific <abp-modal> in ABP Angular?

Is there a way to pass custom options to the underlying NgbModal (e.g. windowClass, size, or similar)?

If this is not supported, what is the recommended alternative for complex editors that require wider layouts?

🛠 Environment

ABP Framework: latest

UI: Angular

Theme: Lepton

Bootstrap: v5

Thank you very much. We appreciate guidance on the correct ABP-recommended approach.

Best regards.


2 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    1. Solution
    • Short answer
      • Use the abp-modal options input to pass ng-bootstrap’s NgbModalOptions and set a unique windowClass for that one modal. Then, add a global style targeting that specific windowClass to control the width. This changes only that modal.
    • How to do it
      1. Set a unique windowClass via options on your abp-modal
    <abp-modal
        [(visible)]="isOpen"
        [options]="{ windowClass: 'my-wide-modal', size: 'xl' }"
      >
        <ng-template #abpHeader>My Wide Editor</ng-template>
        <ng-template #abpBody> ... complex content ... </ng-template>
        <ng-template #abpFooter>
          <abp-button (click)="isOpen = false">Close</abp-button>
        </ng-template>
      </abp-modal>
    

    Notes:

    • options is forwarded to NgbModal.open(...) internally, so you can use any NgbModalOptions, including windowClass, size, centered, scrollable, keyboard, etc.
    • size can be set here as well, but for a near-full-width modal you’ll typically override width via CSS.
    1. Add a global style that targets only that modal window Put this in styles.scss (or global theme stylesheet):
    ngb-modal-window.my-wide-modal .modal-dialog {
        max-width: 90vw !important; /* or a fixed px width */
        width: 90vw;                /* ensure it expands */
        margin: 1.5rem auto;        /* optional: adjust centering/margins */
      }
    
      /* Optionally control body height/scrolling if needed */
      ngb-modal-window.my-wide-modal .modal-content {
        height: calc(100vh - 3rem);
      }
    

    Why global? NgbModal renders outside the component tree, so ViewEncapsulation styles won’t reach it. A unique windowClass ensures the rule applies only to that single modal, not globally.

    • About dialogClass/modalClass inputs

      • abp-modal does not expose dialogClass or modalClass inputs; hence the Angular template error you saw. Use options.windowClass instead.
    • Is passing custom NgbModal options supported?

      • Yes. abp-modal exposes an options input of type NgbModalOptions and spreads it into NgbModal.open(...). You can set windowClass, size, centered, scrollable, keyboard, etc., and they will be respected.
    • If you prefer a CSS-only approach without options

      • You can still set the unique class via options (recommended), then handle all sizing purely in CSS as shown above. Avoid styling only by Bootstrap’s modal-xl class globally, since that affects all modals.
    • Recommended alternative for very complex editors

      • If the content requires near full-page experience, consider:
        • Routing to a dedicated page for the editor (best UX for heavy forms/tables).
        • Or, still use abp-modal with windowClass and add responsive CSS as above.
    1. Sources
    • ABP Angular Modal component forwards options (NgbModalOptions) including windowClass/size to NgbModal:
      • https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.ts
    • ABP Angular Modal docs:
      • https://abp.io/docs/latest/framework/ui/angular/modal

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    Belen.molinaMA created

    Hello,

    Thank you very much for the detailed explanation.

    Using the options input with a custom windowClass and applying the width override in global styles resolved the issue perfectly. We can now control the width of a single <abp-modal> without affecting other modals, exactly as needed.

    Really appreciate the clear guidance and references provided.

    Best regards,

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on December 17, 2025, 04:46
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.