×

Ionic Buttons

Ionic Buttons

There are different types of buttons in the Ionic framework. These buttons are subtly animated, enhancing the user experience when using the application. Buttons are a fundamental way of interacting and navigating through an app, and they should clearly explain what will happen after the user click them. Buttons can consist of two things, which are Text and Icons, and also used both options. The main class for button types is the button. For accessibility reasons, buttons use a standard <button> element, but are enhanced with an <ion-button> directive. The different styles of buttons attributes are shown below:

  • Basic Usage
  • Expand
  • Fill
  • Round Buttons
  • Button Sizes
  • Icon Buttons

Basic Usage: It is the Basic Usage of buttons. The Syntax of the Basic Usage style is:

Button

It set the color of the button by using color property. Ionic includes different default colors that can be easily overridden.

Example: The below example shows how to make basic buttons in the ionic application.



Buttons




Primary Button

medium Button

danger Button

Success Button

Warning Button

Dark Button

When you execute this code in your localhost, then you will get an output, which is shown in the given below screenshot.

When you execute this code in your localhost

Expand: This attribute lets you specify the width of the button. By default, buttons are blocks in the line, but setting this attribute will change the button to a full-width block element.

Expand is divided into two parts:

Block Buttons: Adding a block to the button will make the button take 100% of its parent's view. It is a full-width button with rounded corners.

The Syntax of the block button is:

Block Button
  • Full button: The full addition to the button will make the button take 100% of its parent's width. However, it will also remove the left and right edges of the button. This style is useful when the button should be extended across the full width of the screen. The Syntax of the Full button is:
Full

Example: The below example shows how to make expand buttons in the ionic application.



Buttons




Full
Block
 

Output: When you execute this code in your localhost, then you will get an output, which is shown in the given below screenshot.

Expand

Fill: This attribute specifies the background and button border color. By default, buttons have a solid background unless the button is inside the toolbar, in this case they have a transparent background. Fill is divided into three parts,

  1. Clear
  2. Outline
  3. Solid

Clear Style: Clear style is used to create a button with a transparent background that resembles a flat button. You can add the clear property to use a clear style for a button.

The Syntax for clear style is:

Clear

Outline Style: Outline style is used to create a button with a transparent background and a visible border. By just adding the outline property, you can use the outline style for a button. The Syntax for outline style is:

Outline

Solid Style: Solid style is used to create a button with a filled background. It is useful for buttons in a toolbar. The Syntax for solid style is:

Solid

Example: The below example shows how to make fill buttons in the ionic application.



Buttons




Full
Block
solid
 

Output: When you execute this code in your localhost, then you will get an output, which is shown in the given below screenshot.

Fill is divided into three parts

Round Buttons: It is used to make a button with rounded corners, with adding the round property. The Syntax of the round button is:

Round Button 

Example: The below example shows how to make a round button in the ionic application.



Buttons




Round Button
 

Output: When you execute this code in your localhost, then you will get an output, which is shown in the given below screenshot.

Round Button

Button Sizes: The size feature specifies the size of the button. It permitted the user to change the height and padding of the button. You can use the large attribute to make a large button or small attribute to a small button. There are mainly three types of button sizes i.e.

  • Default
  • Small
  • Large

Default Size: It is used to create a button with less height and padding. It is useful in default for the button in an item.

The Syntax of default size is:

default Button

Small Size: It is used to create a button with the default height and padding. It is useful for buttons in an item.

The Syntax of a small size is:

Small Button

Large Size: It is used to make a button with more height and padding. The Syntax of large size is:

Large Button

Example: The below example shows how to changes the sizes of buttons in the ionic application.



Buttons




Default Button

Small Button

Large Button

Output: When you execute this code in your localhost, then you will get an output, which is shown in the given below screenshot.

Button Sizes

Icon Buttons:  If you need to add an icon inside the button, then you have to add an icon element inside the button. By using the slot property, you can add the icon inside the button. There are three types of slot properties in the icon button.

  • Start: This attribute places the content of the button text to the left side. The following Syntax shows how we can add the icon inside the button.


Left 
  • End: This attribute places the content of the button text to the right side. The following Syntax shows how we can add the icon inside the button.


Right 
  • Icon: When the button hasn't any text, then you can use the icon. The following Syntax shows how we can add the icon inside the button.


 

Example: The below example shows how to set the icon in the buttons.



Buttons




Left

Right

Output: When you execute this code in your localhost, then you will get an output, which is shown in the given below screenshot.

Icon Buttons

Related Topics

Ionic Geolocation

In today’s time, the mobile location plays an essential role in the mobile application. The Ionic Cordova geolocation plugin provides information about the location of the device, like as latitude and longitude. The...

5 minutes read.

Ionic Segment

A segment is a collection of buttons, sometimes which are known as segmented controls. The segment buttons are displayed at horizontal rows. These segment buttons can be shown in a toolbar or the...

2 minutes read.

Ionic Chip

Ionic chip displays the complex entities in small entities in small blocks, such as the contacts. Ionic chip has several types of elements like avatars, thumbnails, text, and icons. It is a bubble-like...

3 minutes read.

Ionic Reorder

The Ionic offers the <ion-reorder> component to reordering features. Ionic reorder component adds the Drag and Drop feature to list items, in which the user can change the order of the items. Reorder...

3 minutes read.

Ionic Refresher

Refresher means updating the currently showing page so that the user can see the latest view. It is also known as re-loading in web technology. It provides a pull- to-refresh feature on a...

4 minutes read.

Ionic Toggle

The toggle is the same as the HTML checkbox entry, but it looks different and easier to use on a touchscreen device. It is an input component that holds the boolean value. Toggle...

2 minutes read.

Ionic Spinner

The ionic spinner component provides the various SVG (Scalable Vector Graphic) spinners. Ionic spinners are the visual indicators that display the app which is loading content or performing another process that the user...

5 minutes read.

Ionic progress bar

The ionic progress bar element is a horizontal progress bar used to visualize the progression of operation and activity. You can use the <ion-progress-bar> component to create a progress bar in the ionic...

4 minutes read.

Ionic Colors

Ionic Colors Before we start with the actual elements available in the Ionic frame, let's understand a little bit how Ionic uses colors for different elements. Ionic Color Classes Ionic framework is a set of nine predefined...

3 minutes read.

Ionic Modal

Ionic modal is displayed as a temporary UI that slides into the screen. The ionic modal is a dialog box that is displayed at the top of the app’s content, and it...

5 minutes read.

Ionic Alert

Ionic Alert An Alert is a dialog box that presents the users with important information, or it stores the data from the user by using the inputs. Alerts are a great way to provide...

5 minutes read.

Ionic List

Ionic List The ionic list is created of several rows of items that can contain text, buttons, thumbnails, keys, icons, and more. Lists are one of the essential components in any web or...

4 minutes read.

Ionic Slides

The ionic slides component is the multi-section container. You can swipe or drag any segment between them. This contains any number of slides components. Slides help it easy to make galleries, tutorials, and...

2 minutes read.

Ionic Select

The Ion Selection component is similar to the HTML <select> element. However, the Ionic Selection component makes it easy for users to categorize and choose the preferred option or other options. You must...

3 minutes read.

Ionic vs Xamarin

Ionic vs Xamarin Ionic and Xamarin are both the most popular frameworks used to develop a hybrid mobile application. Both frameworks are used in large enterprises by the developers. Here, we will discuss the...

4 minutes read.

Ionic Date Time

Ionic Date Time The DateTime component is used to display an interface that makes it simple for users to select dates and times. Tapping on <ion-datetime> will display a slider up from the...

4 minutes read.

Ionic vs Apache Cordova

Ionic Vs Apache Cordova Ionic and Cordova are two popular technology going on in the market for mobile application development. The combination of these two technologies creates a development platform that is known as...

3 minutes read.

Ionic Infinite Scroll

The infinite scroll permits you to perform an action when the user scrolls a particular content from the bottom or top of the page. When you display the large collection of data...

3 minutes read.

Ionic Navigation and Routing

The latest version (ionic 4) of the ionic framework, no longer limited to the angular. In Ionic 4, you can create an ionic project in different front-end frameworks such as Vue.js, React.js, and...

6 minutes read.

Ionic Toolbar

A toolbar is a general toolbar that can be used in an application such as a header, sub-header, footer, or even a sub-footer. Because the ion-toolbar is flexbox-dependent, no matter how many toolbars...

3 minutes read.