Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ion-toggle : Reduce size of toggle button

Is there any way to reduce the size of ion-toggle button. The picture depicts my problem. Expection Vs. Current Implementation

like image 539
Satyaki Avatar asked Jul 14 '16 06:07

Satyaki


3 Answers

In case you are creating toggle button like this:

<label class="toggle">
   <input type="checkbox">
   <div class="track">
     <div class="handle"></div>
   </div>
</label>

Use .toggle .track class to adjust following css properties:

width: 51px;
height: 31px;

and then .toggle .handle to adjust following css properties:

width: 20px;
height: 20px;
border-radius: 20px;
top: 7px;
left: 7px;

You may also add your own class name to change appearance of specific toggle buttons.

In case you are using ion-toggle directive as in

<ion-toggle ng-model="airplaneMode" class="toggle-small" toggle-class="toggle-calm">Airplane Mode</ion-toggle>

You can try to see if applying class="toggle-small" changes appearance as per your need. However, above class modifications can still be applied to this directive.

like image 27
Ritesh Jagga Avatar answered Oct 27 '22 01:10

Ritesh Jagga


try this

ion-toggle {
  zoom: 0.8;
}
like image 164
Khristof Serov Avatar answered Oct 27 '22 00:10

Khristof Serov


From what I can tell you will need to customize three CSS definitions: .toggle-icon, .toggle-inner, and .toggle-checked .toggle-inner.

  • .toggle-icon: width and height change the size of the toggle "track"
  • .toggle-inner: width and height change the size of the toggle "button" that slides in the track
  • .toggle-checked .toggle-inner.: transform: translate3d(27px, 0, 0) The first arg changes the position of the button when it is pressed
like image 36
amuramoto Avatar answered Oct 27 '22 00:10

amuramoto