material icon indicating copy to clipboard operation
material copied to clipboard

mdToast position center

Open jgoux opened this issue 11 years ago • 25 comments

Hi, is it possible to add a position "center" to mdToast ? This position (bottom center) is often used on Android : http://www.technobuzz.net/wp-content/uploads/2014/07/Enable-USB-Debugging.jpg

jgoux avatar Mar 04 '15 07:03 jgoux

Does bottom left right not work?

ilanbiala avatar Mar 04 '15 17:03 ilanbiala

@ilanbiala With these options, it takes 100% width, which is not what I want. In addition, on large screens the options bottom left right isn't centered.

jgoux avatar Mar 04 '15 17:03 jgoux

I would like to see this happen. On large screens, a toast on the left or right looks quite out of place in some cases.

ttl-tim avatar Apr 16 '15 19:04 ttl-tim

:+1: for this as well. Same issue as @timothymiko.

gustavohenke avatar Apr 16 '15 20:04 gustavohenke

I believe adding the code below in src/components/toast/toast.scss at line 113 would do the trick.

&.md-center {
  margin-left: auto;
  margin-right: auto;
  left: 0; right: 0;
}

ttl-tim avatar Apr 17 '15 00:04 ttl-tim

+1: Per official Material specs the Toast should be full-screen width on phones, and centered on tablets and desktops.

colinskow avatar Aug 13 '15 06:08 colinskow

timothymiko, your solution can work for some, but it stretches the toast to its max-width even if it contains just a short piece of text, which is usually undesirable.

anton-rusanov avatar Sep 25 '15 17:09 anton-rusanov

Is this feature completed? http://stackoverflow.com/questions/33413915/how-to-customize-mdtoast

webservconsultant avatar Nov 05 '15 19:11 webservconsultant

+1. Do we have any recommended workaround till this is resolved?

anupbelambe avatar Dec 30 '15 08:12 anupbelambe

+1: To follow the official specs and it simply looks better on large screens

carpaij avatar Jan 06 '16 11:01 carpaij

+1

pdore-netfore avatar Jan 13 '16 15:01 pdore-netfore

&.md-center {
  margin-left: auto;
  margin-right: auto;
  left: 0; right: 0;
}

In addition, include the width property to have a specific size toast

&.md-center {
  margin-left: auto;
  margin-right: auto;
  left: 0; right: 0;
  width: 60%;
}

deepikat avatar Jan 28 '16 19:01 deepikat

+1 all the solutions you propose means overwriting the angular material code, right? I am using bower in my project, so it is not the best thing to do :(

eulersson avatar Feb 19 '16 14:02 eulersson

That would be a great update on mdToast. Material Design is awesome but there are a lot of cases that simple the four corners are not good choice.

Usually: Top Left: Logo / Menu Top Right: Logout or options or FAB Bottom Right: FAB or Help or Chat Bottom Left: Usually not noticeable (usually there is a toolbar there...

So I agree that would be a great addition Top/Bottom Center position.

vapits avatar Apr 18 '16 14:04 vapits

+1 @vapits is absolutely correct. Material Design is fantastic, but for a toast none of the four corners may be suitable in cases where the users attention is directed elsewhere. So either the toast tears their attention away or they may miss it entirely.

rolandmaio avatar Apr 18 '16 15:04 rolandmaio

+1 center Toast is best way

thorvx avatar Apr 20 '16 13:04 thorvx

+1 Centering an mdToast will be incredibly useful. Otherwise people might result to writing their own custom CSS to do this common task or perhaps use automatically time dismissed dialogs instead to accomplish their goal.

DanielCaspers avatar Apr 21 '16 16:04 DanielCaspers

+1 for center Toast. Centering toast is very useful when screen has left and right sidenavs

webservconsultant avatar Apr 26 '16 20:04 webservconsultant

This is a very simple fix. I made a very simple pull request #8269. It looks like the team is so focused on Material2 nobody has had time to review it. Please +1 it if you want it merged.

colinskow avatar May 15 '16 23:05 colinskow

Meanwhile just add the following to your project css:

._md-center {
       left: 50%;
       transform: translate3d(-50%, 0, 0);
}

Now you can set the position to center and it works perfectly:

$mdToast.show(
      $mdToast.simple()
        .textContent('Simple Toast!')
        .position('bottom center')
        .hideDelay(3000)
    );

colinskow avatar May 15 '16 23:05 colinskow