Skip to content

Button ​

Buttons provide a clickable element for actions anywhere in an app. They can show text, icons, or both, and are styled through Fill, Expand, Shape, Size, and Color.

IonButtons groups buttons inside an IonToolbar slot.

Basic usage ​

razor
<IonButton>Default</IonButton>
<IonButton Disabled="true">Disabled</IonButton>

Expand ​

By default a button is inline (display: inline-block). Expand="block" stretches it to the full width with rounded corners; Expand="full" also removes the corners and side borders.

razor
<IonButton Expand="block">Block</IonButton>
<IonButton Expand="full">Full</IonButton>

Shape ​

Shape="round" gives the button pill-shaped corners.

razor
<IonButton>Default</IonButton>
<IonButton Shape="round">Round</IonButton>

Fill ​

Fill sets the background and border: solid (default), outline, or clear. Inside IonButtons or an IonListHeader a button without an explicit Fill defaults to clear.

razor
<IonButton>Default</IonButton>
<IonButton Fill="clear">Clear</IonButton>
<IonButton Fill="outline">Outline</IonButton>
<IonButton Fill="solid">Solid</IonButton>

Size ​

Size changes the height, padding, and font size: small, default, or large.

razor
<IonButton Size="small">Small</IonButton>
<IonButton Size="default">Default</IonButton>
<IonButton Size="large">Large</IonButton>

Icons ​

Buttons have three named slots for icons: IconOnly (a square, text-less button), Start (before the label), and End (after the label). When you use a named slot, put the label in <ChildContent>.

razor
@* Icon-only: put the icon in the IconOnly slot (the button becomes square). *@
<IonButton>
    <IconOnly>
        <IonIcon Icon="@Ionicons.Heart" />
    </IconOnly>
</IonButton>

@* Leading / trailing icons: Start and End slots around the label. *@
<IonButton>
    <Start>
        <IonIcon Icon="@Ionicons.Star" />
    </Start>
    <ChildContent>Left Icon</ChildContent>
</IonButton>

<IonButton>
    <End>
        <IonIcon Icon="@Ionicons.Heart" />
    </End>
    <ChildContent>Right Icon</ChildContent>
</IonButton>

Colors ​

Color takes a palette name. Colors come from the theme's palette — see Theming.

razor
<IonButton Color="primary">Primary</IonButton>
<IonButton Color="secondary">Secondary</IonButton>
<IonButton Color="tertiary">Tertiary</IonButton>
<IonButton Color="success">Success</IonButton>
<IonButton Color="warning">Warning</IonButton>
<IonButton Color="danger">Danger</IonButton>
<IonButton Color="light">Light</IonButton>
<IonButton Color="medium">Medium</IonButton>
<IonButton Color="dark">Dark</IonButton>

Handling taps ​

OnClick is an EventCallback; it is not raised while Disabled is true.

razor
<IonButton Strong="true" OnClick="Increment">Tapped @_count times</IonButton>

@code {
    private int _count;

    // The component re-renders after the handler returns; no StateHasChanged() needed.
    private void Increment() => _count++;
}

Buttons in a toolbar ​

Wrap toolbar buttons in IonButtons and place the group in the toolbar's Start or End slot. The slot decides the position — IonButtons itself does not move the group.

razor
@* Position comes from the toolbar slot (Start / End). Inside IonButtons a button defaults to
   the clear fill and the denser toolbar metrics. *@
<IonToolbar>
    <Start>
        <IonButtons>
            <IonButton>Cancel</IonButton>
        </IonButtons>
    </Start>
    <ChildContent>
        <IonTitle>Edit</IonTitle>
    </ChildContent>
    <End>
        <IonButtons>
            <IonButton Strong="true">Save</IonButton>
        </IonButtons>
    </End>
</IonToolbar>

API ​

Every component also accepts Class (extra CSS classes), Style (an inline Style object) and Id (the root element's id) — see Conventions.

IonButton ​

ParameterTypeDefaultDescription
Colorstring?nullNamed palette color (Ionic color): "primary", "danger", …. Stamped as an ion-color-* class the stylesheet maps to fill / text color.
DisabledboolfalseWhen true, the button is dimmed and non-interactive (Ionic disabled).
Expandstring?nullWidth expansion (Ionic expand): "block" (full-width) or "full" (full-width, square corners, no side borders).
Fillstring?nullFill style (Ionic fill): "solid" (default), "outline", or "clear". Null defaults to clear inside toolbar button groups and list headers, otherwise solid.
Hrefstring?nullRoute to navigate to (Ionic href). When set, the native surface is an a, and a tap raises OnClick and then navigates through the app's NavigationManager with the mode's page transition, like IonItem.
RouterDirectionstring?nullNavigation direction when Href is clicked (mirrors Ionic's routerDirection): "forward" (default — push with transition), "back" (pop-style reverse transition), or "root" (clear the history stack, no transition).
Shapestring?nullCorner shape (Ionic shape): "round" for pill corners.
Sizestring?nullSize (Ionic size): "small", "default", or "large".
StrongboolfalseWhen true, uses a heavier font weight (Ionic strong).
EventTypeDescription
OnClickEventCallbackRaised when the button is tapped (skipped when disabled).
SlotTypeDescription
ChildContentRenderFragment?Content placed between the component's tags.
EndRenderFragment?Content for Ionic's end slot — placed after the label (right in LTR, left in RTL). Typically a trailing icon.
IconOnlyRenderFragment?Content for Ionic's icon-only slot — an icon in a button that has no text. When set (and no text/start/end content), the host gets the button-has-icon-only class so it renders as a square icon button.
StartRenderFragment?Content for Ionic's start slot — placed before the label (left in LTR, right in RTL). Typically a leading icon.

IonButtons ​

ParameterTypeDefaultDescription
Slotstring"start"Ionic's slot attribute on ion-buttons: "start" (default) or "end", stamped as a buttons-start / buttons-end class. It does not move the group — the IonToolbar slot it is placed in (Start, End, Primary, Secondary) decides the position.
SlotTypeDescription
ChildContentRenderFragment?Content placed between the component's tags.

Styling ​

Theme tokens ​

Theme token IonicTheme.Button (ButtonToken). Assign only the values you want to change — the rest keep the mode defaults below. App-wide: builder.AddIonic(o => o.Theme.Button = new ButtonToken { … }); for one subtree: a ConfigProvider. See Theming.

TokenTypemdios
BorderRadiusfloat414
ColorColor#0054e9#0054e9
FontSizefloat1416
FontWeightFontWeightFontWeight.MediumFontWeight.Medium
IconOnlyIconSizefloat22.418
IconOnlyMinSizefloat4040
LargeBorderRadiusfloat416
LargeFontSizefloat2020
LargeIconOnlyIconSizefloat2818
LargeIconOnlyMinSizefloat5050
LargeMinHeightLength2.8em3.1em
LargePaddingBottomLength14px17px
LargePaddingTopLength14px17px
LargePaddingXLength1em1em
LetterSpacingLength0.06em0px
MinHeightLength36px3.1em
OutlineBorderWidthLength2px1px
PaddingBottomLength8px13px
PaddingEndLength1.1em1em
PaddingStartLength1.1em1em
PaddingTopLength8px13px
RoundBorderRadiusfloat999999
SmallBorderRadiusfloat46
SmallFontSizefloat1313
SmallIconOnlyIconSizefloat1617
SmallIconOnlyMinSizefloat2828
SmallMinHeightLength2.1em2.1em
SmallPaddingBottomLength4px4px
SmallPaddingTopLength4px4px
SmallPaddingXLength0.9em0.9em
SolidBackgroundColor#0054e9#0054e9
SolidBoxShadowList<BoxShadow>0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12)none
SolidColorColor#ffffff#ffffff
StrongFontWeightFontWeightFontWeight.BoldFontWeight.SemiBold
TextColorColor#0054e9#0054e9
TextTransformTextTransformTextTransform.UppercaseTextTransform.None
  • Color: Convenience alias for the default solid button color.

CSS classes ​

App stylesheet rules always win over Ionic's own rules (see Theming), so these classes can be targeted directly from GlobalStyles.cs.

SelectorElement
.ion-buttonThe host. Also carries the mode (md / ios) and the state classes below.
.ion-button .button-nativeThe painted, clickable surface: background, border, radius, padding.
.ion-button .button-innerThe row that centers the slotted content.
.button-solid, .button-outline, .button-clearThe resolved Fill.
.button-block, .button-fullExpand.
.button-small, .button-largeSize.
.button-roundShape="round".
.button-strong, .button-disabledStrong, Disabled.
.button-has-icon-onlyA button whose only content is in the IconOnly slot.
.ion-color-{name}Color (e.g. .ion-color-danger).
.in-toolbar, .in-buttonsThe button sits in a toolbar / an IonButtons group.
.ion-buttonsThe IonButtons group.
csharp
// GlobalStyles.cs — a brand-specific "cta" variant: <IonButton Class="cta">…</IonButton>
[".ion-button.cta .button-native"] = new()
{
    BackgroundColor = Color.FromHex("#0e7490"),
    BorderRadius = new BorderRadius(12),
},

Released under the MIT License.