You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: allow for custom ion-toast positioning #17499
Describe the Feature Request
Currently with the implementation of toasts in Ionic v4, we have no way of adding some padding or margin to an ion-toast. I'd like to be able to customize this position in order to adhere to the material design principle outlined here.
Describe Preferred Solution
Ideally, this would be something that could be added in the CSS custom properties.
Reacted by Robin Genz, bene-we, Alexander Soare, Dragos Bostan, Yohan Dahmani, Norbert Korny, hfy, Ryan Espin, Matija, Alemar and 11 more
Reacted by Marc Stammerjohann, Ryan Espin, Nick E. Smith and Stéphane Roche
I see there is style applied directly to the ion-toast>div (below), but there's no "easy" way to modify this. In my example I'd like to move it up by 70px so it doesn't cover my ion-tabs.
Reacted by Joel, bene-we, Marcos Ribeiro, Syed Ali Haider, Tunde Yakub, joshsjf, Norbert Korny, Alemar, Spence DiNicolantonio, Aarej Ansari and 10 more
Reacted by alacrityio
Reacted by Marcos Ribeiro, Braulio Rodriguez, Eirik, Alemar, Aarej Ansari, Elvin J Cáceres, Tom Westrick, alacrityio, Toby Smith, Akanbi Segun Paul and 1 more
changed the title [-]Allow toast position to be customizable to adhere to material design [/-][+]feat: allow for custom ion-toast positioning[/+]on Jun 29, 2020
I'd like to add that it would be nice to have a right and left option as well for the desktop mode, and maybe by default bind the toast to the ion-content so it doesn't overlap with the toolbar.
4 months more and we can give this bug a happy birthday!
I mean, seriously. How hard it is to have the tabs show where they should? I have a tabbed interface (using ion-tabs) and the toast appears above the tabs, giving BAD UX as the user cannot switch between tabs until the toast has dismissed.
Any solution for Ionic 5.x? We can select the container shadow part, but there's no way to target the wrapper with just CSS since it's in a shadow dom...
// opts used as toastController.create(opts)if(this.tabsVisible){opts.enterAnimation=(baseEl: ShadowRoot)=>iosEnterAnimation(baseEl,opts.position,60)}consttoast=awaittoastController.create(opts);// ...
Reacted by Angus Ho
Reacted by Nelson Martell, Gers Academy and Patrick Nemenz
// opts used as toastController.create(opts)if(this.tabsVisible){opts.enterAnimation=(baseEl: ShadowRoot)=>iosEnterAnimation(baseEl,opts.position,60)}consttoast=awaittoastController.create(opts);// ...
This worked perfectly for me, thank you. For anyone confused, remember to import the following:
import { createAnimation } from '@ionic/angular';
import { Animation } from '@ionic/angular';
EDIT: Do you know how I could accomplish this same functionality on Android?
4 months more and we can give this bug a happy birthday!
I mean, seriously. How hard it is to have the tabs show where they should? I have a tabbed interface (using ion-tabs) and the toast appears above the tabs, giving BAD UX as the user cannot switch between tabs until the toast has dismissed.
We're in Ionic 6 already. Any solutions to this?
I found a solution for Ionic 6
Ts
this.toastController.create({message: 'Message to show',cssClass: 'customToast',duration: 1000,position: 'top'});
For React users, I've found a dirty workaround. This should really be supported by design. ref doesn't seem to be called for me, so I had to use querySelector.
⚠ Don't try this at home.
I am using angular with ionic and this is the best solution ive come up with.
async presentToast(position: 'top' | 'middle' | 'bottom', message: string) {
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Activity
joelmeaders commentedon Mar 15, 2019
I see there is style applied directly to the ion-toast>div (below), but there's no "easy" way to modify this. In my example I'd like to move it up by 70px so it doesn't cover my ion-tabs.
Style when using 'bottom' position.
Changing 8px to something like var(--ion-toast-y-offset, 8px) would be amazing.
I'm currently using the following in global.scss to do this and it's probably not the best way.
jbae1024 commentedon Mar 18, 2019
I do not know.... I use it like this. Is there any other problem?
css
.md .tabs-bottom { transform: translateY(-56px) !important; } .ios .tabs-bottom { transform: translateY(-50px) !important; } .md .header-top { top: 56px !important; } .ios .header-top { top: 44px !important; }ts
const toast = await this.toastController.create({ message: 'This is message', position: 'bottom', duration: 1000, color: 'warning', cssClass: 'tabs-bottom' }); toast.present();joelmeaders commentedon Mar 24, 2019
That is much better! The issue with mine is that subsequent toasts aren't covered since ion-overlay-# increments on each call.
Thank you.
bene-we commentedon Jul 11, 2019
I use a FAB in bottom tabbar, since that I have to
translateby at least-64px.I also noticed there is a slight shadow above the toast, a built in solution would be very nice!
[-]Allow toast position to be customizable to adhere to material design [/-][+]feat: allow for custom ion-toast positioning[/+]Yohandah commentedon Aug 5, 2020
I am in need of this too!
I'd like to add that it would be nice to have a right and left option as well for the desktop mode, and maybe by default bind the toast to the ion-content so it doesn't overlap with the toolbar.
darkguy2008 commentedon Nov 1, 2020
4 months more and we can give this bug a happy birthday!
I mean, seriously. How hard it is to have the tabs show where they should? I have a tabbed interface (using ion-tabs) and the toast appears above the tabs, giving BAD UX as the user cannot switch between tabs until the toast has dismissed.
We're in Ionic 6 already. Any solutions to this?
josuecaceres commentedon Nov 23, 2020
this is enough for me, thank you
darkdread commentedon Jul 16, 2021
Any solution for Ionic 5.x? We can select the container shadow part, but there's no way to target the wrapper with just CSS since it's in a shadow dom...
map-lo commentedon Aug 19, 2021
@darkdread I found a solution for Ionic 5.x. Provide a custom enter animation including an offset for the tabs bar.
angusho1 commentedon Jan 13, 2022
This worked perfectly for me, thank you. For anyone confused, remember to import the following:
EDIT: Do you know how I could accomplish this same functionality on Android?
j4vs commentedon Jan 19, 2022
I found a solution for Ionic 6
Ts
css
Now you can change the top or bottom or font size or other properties
ryubal-sh commentedon Apr 29, 2022
For me this was more than enough.
scriptify commentedon Jun 16, 2022
For React users, I've found a dirty workaround. This should really be supported by design.
refdoesn't seem to be called for me, so I had to use querySelector.⚠ Don't try this at home.
fbl773 commentedon Jul 5, 2022
It would be sweet if I could just shove the toast in a
<div>or something on my page. If I could define the toast in my html, that would be ideal.judsonmusic commentedon Jan 17, 2023
I am using angular with ionic and this is the best solution ive come up with.
async presentToast(position: 'top' | 'middle' | 'bottom', message: string) {
Notice i am using a custom class that is dynamically created but i can style however i want to. Cheers :)
0x7061 commentedon Jun 28, 2023
@judsonmusic Great find. Sadly the ::ng-deep pseudo-class is deprecated now.
feat(toast): allow custom positioning relative to specific element (#…
averyrousseau commentedon Oct 4, 2023
Hi folks, this feature has been added via #28248 and will be available in a future minor release of Ionic. Thank you!
ionitron-bot commentedon Nov 3, 2023
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.