Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ionic: how to change the size of FAB icon

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.

like image 573
IntelligenceArtificial Avatar asked Nov 17 '16 14:11

IntelligenceArtificial


People also ask

How do I change the size of the ion-icon?

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.

How do I use icons in ionic framework?

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.

How to change the size of an icon in a button?

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.

Why does the Fab button scroll with the content?

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:


3 Answers

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.

like image 69
Fernando Del Olmo Avatar answered Oct 21 '22 14:10

Fernando Del Olmo


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
like image 8
sampereless Avatar answered Oct 21 '22 14:10

sampereless


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

like image 1
1x2x3x4x Avatar answered Oct 21 '22 13:10

1x2x3x4x