I am new to cross-platform dev. Struggling with changing the size of FAB. This is what I have now:
<ion-fab center middle>
<button ion-fab color="blue" class="fabStartBtn"><ion-icon
name="start">Start</ion-icon></button>
</ion-fab>
.fabStartBtn {
font-size: 72px;
}
But the size is still the same. How can I get access to the button attribute? I tried id, name, #name, :before - didn't work.
Or you can set a specific size by applying the font-size CSS property on the ion-icon component. It's recommended to use pixel sizes that are a multiple of 8 (8, 16, 32, 64, etc.) Specify the icon color by applying the color CSS property on the ion-icon component.
When using icons in Ionic Framework you can specify different icons per platform. Use the md and ios attributes and provide the platform specific icon/variant name. To specify the icon size, you can use the size attribute for our pre-defined font sizes.
If the icon is inside a button you can use button properties, small or large. If not (or if you need a custom size), you can use CSS, using the chrome dev tool to inspect the elemnts and check the classes.
If the FAB button is not wrapped with <ion-fab>, it will scroll with the content. FAB buttons have a default size, a mini size and can accept different colors:
Try to use this:
<ion-fab center bottom>
<button ion-fab mini><ion-icon name="add"></ion-icon></button>
</ion-fab>
If you use the mini
attribute you can modify the size with this:
.fab[mini] {
margin: 8px;
width: 40px;
height: 40px;
line-height: 40px;
}
If you modify that class you can make the FAB button bigger or smaller.
Go into your theme/variables.scss
file and override the $fab-size
variable like this:
$fab-size: 70px; //Change value to whatever size you want
If you want to change the size of the fab and still have it centered add these classes to your scss.
ion-fab-button {
width: 100px;
height: 100px;
}
.fab-horizontal-center {
margin-left: unset;
margin-inline-start: -50px !important;
}
The margin-inline-start has to be the half of the width.
Reported the bug here: https://github.com/ionic-team/ionic-framework/issues/22564
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With