Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic2/3 - header button icon has different size then auto back button

I am using Ionic's 2/3 auto button when using NavController.

On one of the pages I want to add button to the header, which will change something, so I've added it:

<ion-header>
  <ion-navbar color="orange">
    <ion-title>Test</ion-title>
    <ion-buttons end>
      <button ion-button icon-right clear (click)="openModal()">
        Next <ion-icon name="arrow-forward"></ion-icon>
      </button>
    </ion-buttons>
  </ion-navbar>
</ion-header>

Unfortunately, size of the icon is slightly different (smaller) then Back button added automatically by the Ionic. I know that I can style it with CSS but I am afraid to break something (I can't test all the devices).

Screenshot (both Android & iOS): right button's icon is smaller then back icon same for iOS

Maybe should I use different button classes or components? How can I make size of all buttons & icons in header the same?

like image 328
dease Avatar asked Aug 24 '17 12:08

dease


People also ask

How do I change the icon on the ion menu button?

To define a custom asset for our ion-icon is as easy as just passing the path of our file in the src property. Now copy and paste the XML below into the custom-menu. svg . The cool part is that using this technique it's possible to customize the theme by just adding the color attribute in the ion-menu-button .

How ion back button works?

The back button navigates back in the app's history upon click. It is smart enough to know what to render based on the mode and when to show based on the navigation stack. To change what is displayed in the back button, use the text and icon properties.

How do I change the color of my back button on my ion?

Check your variables. css file there is should be @media (prefers-color-scheme: dark) section that relates to dark theme colors. Also you need set color light to ion-back-button.

How do you use the back button in ionic?

The hardware back button is found on most Android devices. In native applications it can be used to close modals, navigate to the previous view, exit an app, and more. By default in Ionic, when the back button is pressed, the current view will be popped off the navigation stack, and the previous view will be displayed.


1 Answers

You can use icon-only directive and that's all. This way is back-button.

<ion-buttons end>
   <button ion-button icon-right icon-only clear (click)="openModal()">
      Next <ion-icon name="arrow-forward"></ion-icon>
   </button>
</ion-buttons>
like image 93
Sergio Escudero Avatar answered Oct 28 '22 20:10

Sergio Escudero