I’m using NgbModal and there the Modal is opening from Top to Bottom by default when opening. Is it to possible to make it appear from right to left. I have set up the positioning already such that it is at the right corner of the screen. But cannot figure out the direction of opening
I looked at their API but couldn’t find an option for direction.
https://ng-bootstrap.github.io/#/components/modal/examples
Here is stackblitz of their first example which could be a minimum reproducible example
I also found this answer which uses pure bootstrap and not abstraction like ng bootstrap, so not sure how it can be applied to NgbModal
<ng-template #content let-modal>
<div class="modal-header">
<h4 class="modal-title" id="modal-basic-title">Profile update</h4>
<button type="button" class="btn-close" aria-label="Close" (click)="modal.dismiss('Crossclick')"></button>
</div>
<div class="modal-body">Modal Content</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary" (click)="modal.close('Save click')">
Save
</button>
</div>
</ng-template>
<button class="btn btn-lg btn-outline-primary" (click)="open(content)">
Launch demo modal
</button>
<hr />
<pre>{{ closeResult }}</pre>
open(content: TemplateRef<any>) {
this.modalService
.open(content, {
ariaLabelledBy: 'modal-basic-title',
animation: true,
})
.result.then(
(result) => {
this.closeResult = `Closed with: ${result}`;
},
(reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
}
);
}
Help much appreciated
2
Answers
If are only a few modals you want from left to rigth, you can add in your styles.scss (or what-ever styles "global")
Then, when you open pass the class "form-left"
If are all the modal you can use simply
In the stackblitz I add the styles in the own index.html
You can modify the below CSS to achieve whichever direction transform you want, just mess around with the X and Y values.
Stackblitz Demo