Skip to main content

Working with Button Components

1. Using IonButton Component

Property Values Description
color 'primary', 'secondary', 'tertiary', 'success', 'warning', 'danger', 'light', 'medium', 'dark' Sets the color of the button
fill 'solid', 'outline', 'clear' Defines the fill style of the button
size 'small', 'default', 'large' Adjusts the size of the button
expand 'block', 'full' Makes the button span full width or block
disabled true, false Disables the button if set to true
strong true, false Makes the button text bold

Example: Basic IonButton Usage

<ion-button color="primary">
  Click Me
</ion-button>

Example: Button with Icon

<ion-button>
  <ion-icon name="add"></ion-icon>
  Add Item
</ion-button>

Example: Button with Outline Style

<ion-button fill="outline" color="secondary">
  Outline Button
</ion-button>

2. Creating Solid Buttons

Property Values Description
fill "solid" Applies a solid background to the button. This is the default fill type.
color "primary", "secondary", "tertiary", "success", "warning", "danger" Defines the color theme of the button.
size "small", "medium", "large" Sets the size of the button.
expand "block", "full" Expands the button to fill the container width.

Example: Basic Solid Button

<ion-button fill="solid" color="primary">
  Click Me
</ion-button>

Example: Large Solid Button with Expand

<ion-button fill="solid" color="secondary" size="large" expand="block">
  Full Width Button
</ion-button>

3. Creating Outline Buttons

Property Values Description
fill "outline" Applies an outline style to the button
color "primary", "secondary", "danger", etc. Defines the color scheme of the outline button
size "small", "default", "large" Sets the size of the button

Example: Basic Outline Button

<ion-button fill="outline">Outline Button</ion-button>

Example: Colored Outline Button

<ion-button fill="outline" color="secondary">Secondary Outline</ion-button>

Example: Large Outline Button

<ion-button fill="outline" size="large">Large Outline</ion-button>

4. Creating Clear Buttons

Property Values Description
clear true | false Sets the button to have no background or border. Default is false.
color primary | secondary | success | warning | danger | light | medium | dark Applies a color to the button. Default is primary.
size small | default | large Sets the size of the button. Default is default.

Example: Basic Clear Button

<ion-button clear>Clear Button</ion-button>

Example: Clear Button with Color

<ion-button clear color="secondary">Secondary Clear</ion-button>

Example: Clear Button with Size

<ion-button clear size="large">Large Clear</ion-button>

5. Setting Button Sizes

Property Values Description
size small, default, large Sets the size of the button

Example: Button sizes

<ion-button size="small">Small</ion-button>
<ion-button size="default">Default</ion-button>
<ion-button size="large">Large</ion-button>

6. Using Block Buttons

Property Values Description
expand "block" Expands the button to fill the width of its container
size "small", "default", "large" Adjusts the size of the button
fill "solid", "outline", "clear" Defines the visual style of the button

Example: Block Button Usage

<ion-button expand="block">
  Click Me
</ion-button>
Note: Block buttons are ideal for full-width actions in forms or navigation lists.

7. Using Icon-Only Buttons

Property Values Description
iconOnly true Boolean flag to render button with only icon and no text
size small, medium, large Sets the size of the icon-only button
fill solid, outline, clear Determines the visual style of the button

Example: Icon-Only Button with Ionicons

<ion-button icon-only="">
  <ion-icon name="heart"></ion-icon>
</ion-button>

Example: Large Icon-Only Button

<ion-button icon-only="" size="large">
  <ion-icon name="star"></ion-icon>
</ion-button>
Note: Icon-only buttons should have accessible labels using aria-label or title for screen readers.

8. Implementing Button States

State Description Class/Property Usage
default Standard button state with no interaction ion-button Basic button rendering
active Button is currently pressed or selected ion-button.active Visual feedback for active state
disabled Button is not interactive and visually disabled ion-button[disabled] Prevents interaction and shows disabled style
loading Button displays loading indicator and is inactive ion-button[loading] Used during async operations

Example: Button States in Ionic

<ion-button>Default</ion-button>
<ion-button class="active">Active</ion-button>
<ion-button disabled>Disabled</ion-button>
<ion-button loading>Loading</ion-button>
Note: The loading state automatically disables the button and shows a spinner.

9. Styling Button Shapes

Shape Description Example
round Rounds the button edges to create a circular shape. <ion-button shape="round">Round</ion-button>
block Stretches the button to fill the width of its container. <ion-button shape="block">Block</ion-button>
full Creates a button that is full-width and has no border. <ion-button shape="full">Full</ion-button>

Example: Button with Round Shape

<ion-button shape="round">
  <ion-icon name="heart"></ion-icon>
</ion-button>

Example: Button with Block Shape

<ion-button shape="block">
  Submit
</ion-button>

10. Using Button Colors

Color Usage Notes
primary <ion-button color="primary">Primary</ion-button> Default brand color for the app
secondary <ion-button color="secondary">Secondary</ion-button> Alternative color for actions
tertiary <ion-button color="tertiary">Tertiary</ion-button> Used for less important actions
success <ion-button color="success">Success</ion-button> For positive actions or confirmations
warning <ion-button color="warning">Warning</ion-button> For caution or potentially destructive actions
danger <ion-button color="danger">Danger</ion-button> For destructive actions like delete
light <ion-button color="light">Light</ion-button> For light background buttons
medium <ion-button color="medium">Medium</ion-button> For medium contrast buttons
dark <ion-button color="dark">Dark</ion-button> For dark background buttons

Example: Button Color Usage

<ion-button color="primary">Primary</ion-button>
<ion-button color="secondary">Secondary</ion-button>
<ion-button color="success">Success</ion-button>
<ion-button color="warning">Warning</ion-button>
<ion-button color="danger">Danger</ion-button>

Was this article helpful?