Skip to content
Tutorials Center
My learning

Topics

Lesson 6 of 37 ยท Components and Theming

Ionic Buttons, Cards and Icons

Use ion-button, ion-card, ion-icon, ion-badge and ion-chip: fills, sizes, colors, expand, slots, icon packs and accessibility labels with examples.

Buttons, cards and icons are the first components you reach for in any app. Ionic gives each one a small, consistent set of properties: color, fill, size, expand, and so on. Learn these properties once and they carry over to dozens of other components. This lesson covers the properties, the icon system, and how to keep controls accessible.

Buttons

HTML
<ion-button>Default</ion-button>
<ion-button color="secondary">Secondary</ion-button>
<ion-button color="danger" fill="outline">Delete</ion-button>
<ion-button fill="clear">Cancel</ion-button>
<ion-button expand="block" size="large">Continue</ion-button>
<ion-button shape="round">Round</ion-button>
<ion-button disabled="true">Disabled</ion-button>
Property Values Effect
color primary, secondary, tertiary, success, warning, danger, light, medium, dark Picks a theme colour
fill solid, outline, clear Filled, bordered or text-only
size small, default, large Height and padding
expand block, full Stretch to the container width
shape round Pill-shaped corners
disabled boolean Blocks interaction
href / routerLink string Navigate like a link

When a button navigates, give it href or routerLink so it renders as an anchor with correct semantics. A button that only runs code uses (click) or onClick.

Icons can live inside buttons using slots:

HTML
<ion-button>
  <ion-icon slot="start" name="cloud-upload"></ion-icon>
  Upload
</ion-button>
<ion-button fill="clear">
  <ion-icon slot="icon-only" name="heart" aria-label="Favorite"></ion-icon>
</ion-button>

The icon-only slot makes the button a compact square. An icon-only button needs an aria-label because there is no visible text for screen readers.

Colours are semantic

You will see the palette again in theming. The important point: colours are named by role (primary, danger), not by value (blue, red). That means a theme can change the value of primary once, and every component using it follows.

Cards

A card groups related content with a title and body:

HTML
<ion-card>
  <img alt="Mountains at dawn" src="/assets/mountains.jpg" />
  <ion-card-header>
    <ion-card-subtitle>Trip</ion-card-subtitle>
    <ion-card-title>Alpine sunrise</ion-card-title>
  </ion-card-header>
  <ion-card-content>
    Start before dawn and pack a warm layer.
  </ion-card-content>
  <ion-button fill="clear">Share</ion-button>
  <ion-button fill="clear">Save</ion-button>
</ion-card>

Cards can be made clickable with button="true" or an href. They get a ripple effect on Android and a tap highlight on iOS.

Icons with Ionicons

ion-icon renders SVG icons from Ionicons, a free open-source set. Each icon has three variants: filled (heart), outline (heart-outline) and sharp (heart-sharp). In the framework flavours you import icons and register them so unused ones are not bundled:

TypeScript
import { addIcons } from 'ionicons';
import { heart, heartOutline } from 'ionicons/icons';

addIcons({ heart, 'heart-outline': heartOutline });

In React you pass the imported icon directly: <IonIcon icon={heart} />. In plain HTML with the CDN bundle you use the name string. Size and colour come from CSS:

CSS
ion-icon { font-size: 32px; color: var(--ion-color-primary); }

Because an icon is an SVG with fill: currentColor, it takes the text colour of its parent by default.

Badges and chips

HTML
<ion-badge color="danger">9</ion-badge>
<ion-chip color="success">
  <ion-icon name="checkmark-circle"></ion-icon>
  <ion-label>Verified</ion-label>
</ion-chip>

Badges show counts or status, usually inside an ion-item or tab. Chips represent attributes, filters or tags and can contain an avatar, icon and label.

Stand-in: how fill and color combine

Ionic computes button styling from color and fill. This stand-in reproduces the logic with CSS variable names so you can see the pattern. It is plain JavaScript, not Ionic's implementation.

JS Stand-in: color + fill produce styles

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Accessibility checklist

  • Icon-only buttons need aria-label.
  • Do not rely on colour alone to convey meaning (add text or an icon).
  • Keep touch targets at least 44 by 44 pixels; Ionic buttons already respect this by default, but custom ones may not.
  • Prefer real links (href) for navigation.

A badge counter you can run

Counters on tabs often cap at 99. A tiny stand-in for the display logic:

JS Stand-in: badge text with a cap

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which property makes a button stretch to full width?

    expand="block" or "full" stretches the button to its container.
  2. 2. Why does an icon-only button need aria-label?

    Without text, assistive technology cannot tell what the button does.
  3. 3. What are the three variants of an Ionicon?

    Most icons come as name, name-outline and name-sharp.
  4. 4. Which fill value draws only text without a background or border?

    fill="clear" removes background and border.

Summary

  • color, fill, size, expand and shape configure buttons.
  • Colours are semantic roles, which makes theming simple.
  • Cards combine header, title, content and actions.
  • Ionicons come in filled, outline and sharp forms; register only what you use.
  • Always label icon-only controls and do not rely on colour alone.

Next: Lists and Items