Hi,
I need to add a navbar back-button to a modal , as it happens in a normal page after the .push()
action.
This is what i have now, but css (padding and margin) are not like the default one provided with the .push()
method.
<ion-header>
<ion-navbar>
<ion-buttons left>
<button ion-button icon-only (click)="viewCtrl.dismiss()">
<ion-icon name="arrow-back"></ion-icon>
</button>
</ion-buttons>
</ion-navbar>
</ion-header>
First screenshot is what my code create.
Second screenshot is taken from a page with .push()
method.
I wish both were equal… How to achieve that?
Thx guys!
2 Likes
ion-buttons {
margin-left: 3rem;
}
Adjust the value to what you want I just put 3 randomly.
keep me update if that doesn’t work
1 Like
html: add class to button
<ion-header>
<ion-navbar>
<ion-buttons left>
<button ion-button icon-only (click)="viewCtrl.dismiss()" class="my-style-for-modal">
<ion-icon name="arrow-back"></ion-icon>
</button>
</ion-buttons>
</ion-navbar>
</ion-header>
scss:
ion-buttons button[icon-only].my-style-for-modal {
margin: 0 6px;
min-width: 36px;
}
I didn’t found a better solution
8 Likes
Thanks for both answers @melchia & @reedrichards .
I was looking for a solution without using css (like a property or something similar), but it seems that it is not possible.
I will try your solutions, but both will work for sure!
1 Like
Tamo
March 20, 2017, 3:05pm
6
Just do
.back-button {
display: block;
}
In the modal-component css, no?
1 Like
This does nothing, @Tamo …
.back-button is the button’s css class, right?
aavelyn
September 11, 2017, 5:32pm
8
Tamo is correct but lacks an “important”
my suggestion is to add a global class in variable.scss
.modal-back-button{
.back-button{
display: block!important
}
}
then add the class to each page you need
1 Like
Hi, just do:
<ion-navbar color="primary">
<ion-buttons left>
<button navPop ion-button icon-only>
<ion-icon color="light" name="arrow-back"></ion-icon>
</button>
</ion-buttons>
<ion-title>Page</ion-title>
</ion-navbar>
10 Likes
Tiquet
May 19, 2023, 4:38pm
10
@aavelyn yes, @Tamo just lacks the !important
. this works for me. Thanks you both.