I'm using Angular 6
and NgbModal
like
openViewDescriptionModal(id) {
const viewModal = this.modalService.open(ProductComponent, {size: 'lg'});
}
But this opens modal with width 50% only with 25% space empty on both sides.
I want to redesign modal width to up to 90% of the window width.
But there are only sm
and lg
sizes allowed with NgbModal
.
How can I increase the width of the modal or probably use a custom class to increase modal width?
I tried setting values like xl
to size
but it does not work.
I also tried customizing the CSS of the modal class but this did not work either.
Modal Size Change the size of the modal by adding the . modal-sm class for small modals, . modal-lg class for large modals, or . modal-xl for extra large modals.
The docs reactstrap really bad to explained. Don't forget everyone, you can also do size="xl" . To achieve greater sizes than this, you have to use a stylesheet imported and on the Modal component itself, specifically a property called contentClassName . By writing to a separate file like styles.
As of today the open method of https://ng-bootstrap.github.io/#/components/modal has the following signature: open(content: string | TemplateRef<any>, options: NgbModalOptions) . As you can see from this signature you can open a modal providing content as: string.
You can set the 'windowClass' property referencing some class, so your code would be like:
openViewDescriptionModal(id) {
const viewModal = this.modalService.open(ProductComponent, {size: 'lg', windowClass: 'modal-xl'});
}
and then, on some .css you're using, add your own class with the custom size to override like:
.modal-xl .modal-lg {
max-width: 90%;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With