ionic-expert
Original:🇺🇸 English
Translated
A comprehensive starting point for AI agents to work with the Ionic Framework. Covers core concepts, components, CLI, theming, layout, lifecycle, navigation, and framework-specific patterns for Angular, React, and Vue. Pair with the other Ionic skills in this collection for deeper topic-specific guidance like app creation, framework integration, and upgrades.
23installs
Sourcecapawesome-team/skills
Added on
NPX Install
npx skill4agent add capawesome-team/skills ionic-expertTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Ionic Expert
Comprehensive reference for Ionic Framework development — core concepts, components, theming, lifecycle, navigation, framework-specific patterns (Angular, React, Vue), upgrading, and Capawesome Cloud integration.
Core Concepts
Ionic Framework is a UI toolkit for building cross-platform apps with web technologies. It provides 80+ pre-built UI components as Web Components prefixed with (e.g., , ).
ion-<ion-button><ion-content>- Platform modes: Components adapt styling to the platform. iOS devices use mode; Android and all other platforms use
ios(Material Design). Themdelement receives a class (<html>orios).md - Capacitor integration: Ionic handles the UI; Capacitor handles native device APIs. See the skill for Capacitor guidance.
capacitor-app-development - Framework support: Ionic integrates with Angular (), React (
@ionic/angular), and Vue (@ionic/react).@ionic/vue
Creating a New App
bash
npm install -g @ionic/cli
ionic start <name> <template> --type=<framework> --capacitor --package-id=<id> | Framework |
|---|---|
| Angular (NgModules) |
| Angular (Standalone Components) |
| React |
| Vue |
| Template | Description |
|---|---|
| Empty project, single page |
| Tab-based layout |
| Side menu layout |
For details, see ionic-app-creation.
Ionic CLI
Run for the full and always up-to-date command list.
ionic --help| Command | Description |
|---|---|
| Scaffold a new Ionic project. |
| Start a local dev server with live reload (port 8100). |
| Build the web app for production. |
| Generate pages, components, services (framework-dependent). |
| Print system/environment info. |
| Remove and recreate dependencies and platform files. |
Useful flags: (all network interfaces), , , .
ionic serve--external--port=<port>--prod--no-openComponents Overview
Ionic provides 80+ UI components organized by category. For full API reference (properties, events, methods, slots, CSS custom properties), see the linked reference files.
Layout
ion-appion-contention-headerion-footerion-toolbarion-titleion-buttonsion-back-buttonion-gridion-rowion-colion-split-paneKey usage:
html
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button defaultHref="/home"></ion-back-button>
</ion-buttons>
<ion-title>Page Title</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<!-- Scrollable content -->
</ion-content>For details, see components-layout.md.
Navigation
ion-tabsion-tab-barion-tab-buttonion-menuion-menu-buttonion-menu-toggleion-router-outletion-navion-breadcrumbsFor details, see components-navigation.md.
Form
ion-inpution-textareaion-selection-select-optionion-checkboxion-toggleion-radioion-radio-groupion-rangeion-datetimeion-datetime-buttonion-searchbarion-segmention-segment-buttonion-input-otpKey properties shared by most form components: , (, , , ), (, ), , , , , .
labellabelPlacementfloatingstackedfixedstartfilloutlinesoliderrorTexthelperTextdisabledvalueplaceholderKey events:
- — fires on each keystroke (use for
ionInput/ion-input).ion-textarea - — fires when value is committed (use for
ionChange,ion-select,ion-toggle,ion-checkbox).ion-range
html
<ion-input label="Email" labelPlacement="floating" fill="outline"
type="email" placeholder="you@example.com"
errorText="Invalid email" helperText="Enter your email">
</ion-input>
<ion-select label="Country" labelPlacement="floating" fill="outline" interface="popover">
<ion-select-option value="us">United States</ion-select-option>
<ion-select-option value="de">Germany</ion-select-option>
</ion-select>For details, see components-form.md.
Overlays
ion-modalion-alertion-toastion-action-sheetion-loadingion-popoverAll overlays share: prop for declarative control, prop to open from a button ID, , , and lifecycle events (, , , ).
isOpentriggerbackdropDismissanimateddidPresentdidDismisswillPresentwillDismissSheet modal (bottom sheet):
html
<ion-modal [isOpen]="isOpen" [breakpoints]="[0, 0.5, 1]" [initialBreakpoint]="0.5" [handle]="true">
<ion-content>Sheet content</ion-content>
</ion-modal>For details, see components-overlay.md.
Data Display
ion-listion-itemion-item-slidingion-item-optionsion-item-optionion-cardion-card-headerion-card-contention-accordionion-accordion-groupion-chipion-badgeion-labelion-noteFor details, see components-data-display.md.
Scroll
ion-refresherion-refresher-contention-infinite-scrollion-infinite-scroll-contention-reorder-groupion-reorderFor details, see components-scroll.md.
Actions & Media
ion-buttonion-fabion-fab-buttonion-iconion-avatarion-thumbnailion-spinnerion-skeleton-textion-progress-barFor details, see components-action.md and components-media.md.
Theming
Colors
Nine default colors: , , , , , , , , . Apply via the attribute:
primarysecondarytertiarysuccesswarningdangerlightmediumdarkcolorhtml
<ion-button color="primary">Save</ion-button>
<ion-button color="danger">Delete</ion-button>Customize a color by overriding all six CSS variables in :
:rootcss
:root {
--ion-color-primary: #3880ff;
--ion-color-primary-rgb: 56, 128, 255;
--ion-color-primary-contrast: #ffffff;
--ion-color-primary-contrast-rgb: 255, 255, 255;
--ion-color-primary-shade: #3171e0;
--ion-color-primary-tint: #4c8dff;
}Global CSS Variables
Key variables: , , , , , .
--ion-background-color--ion-text-color--ion-font-family--ion-safe-area-top/right/bottom/left--ion-margin--ion-paddingDark Mode
Three approaches (import from , , or ):
@ionic/angular/css/@ionic/react/css/@ionic/vue/css/- System preference (default):
@import '@ionic/<framework>/css/palettes/dark.system.css'; - Always dark:
@import '@ionic/<framework>/css/palettes/dark.always.css'; - CSS class toggle: then add
@import '@ionic/<framework>/css/palettes/dark.class.css';to.ion-palette-dark.<html>
Platform Styles
Target platform-specific styles in CSS using the mode class on :
<html>css
.ios ion-toolbar { --background: #f8f8f8; }
.md ion-toolbar { --background: #ffffff; }Preview a specific mode in the browser:
http://localhost:8100/?ionic:mode=iosLayout
Grid System
12-column flexbox grid: , , . Columns expand evenly unless (1-12) is specified.
ion-gridion-rowion-colsize| Breakpoint | Min Width | Property Suffix |
|---|---|---|
| 0 | |
| 576px | |
| 768px | |
| 992px | |
| 1200px | |
CSS Utility Classes
- Padding: ,
.ion-padding,.ion-padding-top/bottom/start/end.ion-no-padding - Margin: ,
.ion-margin,.ion-margin-top/bottom/start/end.ion-no-margin - Text: ,
.ion-text-center,.ion-text-start,.ion-text-end,.ion-text-wrap.ion-text-nowrap - Display: ,
.ion-display-none,.ion-display-block.ion-display-flex - Flex: ,
.ion-justify-content-center,.ion-align-items-center,.ion-flex-row.ion-flex-column
All utility classes support responsive suffixes: (applies at 768px+).
.ion-text-md-centerPage Lifecycle
Ionic provides four lifecycle hooks that fire during page transitions. These exist because caches pages in the DOM — framework-native lifecycle hooks (, , ) only fire once on first creation, not on every page visit.
ion-router-outletngOnInituseEffectonMounted| Hook | Fires When | Use For |
|---|---|---|
| Page about to enter (pre-animation) | Refresh data on every visit |
| Page fully entered (post-animation) | Start animations, focus inputs |
| Page about to leave (pre-animation) | Save state, pause subscriptions |
| Page fully left (post-animation) | Clean up off-screen resources |
Critical rules:
- Only fire on components directly mapped to a route via .
ion-router-outlet - Child components do not receive these events.
- The component must use the framework-specific page wrapper (see framework sections below).
Framework-Specific Patterns
Angular
For full details, see ionic-angular.
Detect architecture: Check for (standalone) vs (NgModule).
src/main.tsbootstrapApplicationplatformBrowserDynamic().bootstrapModule| Aspect | Standalone | NgModule |
|---|---|---|
| Ionic setup | | |
| Component imports | Each from | |
| Lazy loading | | |
| Icons | | Automatic |
Navigation: Use from for animated navigation (, , , ). Use with in templates.
NavController@ionic/angularnavigateForwardnavigateBacknavigateRootbackrouterLinkrouterDirectionLifecycle: Implement interfaces , , , from :
ViewWillEnterViewDidEnterViewWillLeaveViewDidLeave@ionic/angulartypescript
import { ViewWillEnter } from '@ionic/angular';
@Component({ /* ... */ })
export class HomePage implements ViewWillEnter {
ionViewWillEnter() {
this.loadData(); // Runs on every page visit
}
}For navigation details, see angular/navigation.md. For lifecycle details, see angular/lifecycle.md.
React
For full details, see ionic-react.
Key setup differences:
- Call before rendering in
setupIonicReact().src/main.tsx - Use (from
IonReactRouter) instead of@ionic/react-router.BrowserRouter - Use to contain routes with the
IonRouterOutletprop (notcomponentorrender).children - Every page must render as root — required for transitions and lifecycle hooks.
IonPage
Navigation: Use hook for programmatic navigation:
useIonRoutertypescript
import { useIonRouter } from '@ionic/react';
const router = useIonRouter();
router.push('/detail/123', 'forward', 'push');
router.goBack();Lifecycle hooks (from ):
@ionic/reacttypescript
import { useIonViewWillEnter } from '@ionic/react';
useIonViewWillEnter(() => {
fetchData(); // Runs on every page visit
});Overlay hooks: , , , , , , .
useIonAlertuseIonToastuseIonActionSheetuseIonLoadinguseIonModaluseIonPopoveruseIonPickerForm events: Use for /, for ///. Access values via .
onIonInputIonInputIonTextareaonIonChangeIonSelectIonToggleIonCheckboxIonRangee.detail.valueFor routing details, see react/routing.md. For hooks, see react/hooks.md.
Vue
For full details, see ionic-vue.
Key setup differences:
- Install plugin in
IonicVue:src/main.ts.createApp(App).use(IonicVue).use(router) - Import from
createRouter(not from@ionic/vue-router).vue-router - Every page must use as root template element — without it, transitions and lifecycle hooks silently fail.
IonPage - Import all Ionic components from .
@ionic/vue - Use kebab-case for event names in templates (,
@ion-change).@ion-input - Import icons as SVG references from — never as strings.
ionicons/icons
Navigation: Use composable:
useIonRoutervue
<script setup lang="ts">
import { useIonRouter } from '@ionic/vue';
const ionRouter = useIonRouter();
ionRouter.push('/detail/123');
ionRouter.back();
</script>Declarative:
<ion-button router-link="/detail" router-direction="forward">Go</ion-button>Lifecycle hooks (from ):
@ionic/vuevue
<script setup lang="ts">
import { onIonViewWillEnter } from '@ionic/vue';
onIonViewWillEnter(() => {
fetchData(); // Runs on every page visit
});
</script>Composables: , , , , .
useIonRouter()useBackButton(priority, handler)useKeyboard()isPlatform(name)getPlatforms()Access Web Component methods via : .
$elcontentRef.value.$el.scrollToBottom(300)For navigation details, see vue/navigation.md. For composables, see vue/composables.md.
Navigation Patterns
Tab Navigation
Each framework uses with and child routes per tab. Each tab maintains its own navigation stack.
ion-tabsion-tab-barRules:
- The attribute on
tabmust match the child route path.ion-tab-button - Never navigate between tabs programmatically — only the tab bar buttons should switch tabs.
- For shared views across tabs, use instead of cross-tab routing.
ion-modal
Side Menu
Use with matching the on . Wrap menu items in to auto-close after selection. Use for top-level menu navigation.
ion-menucontentIdidion-router-outletion-menu-togglerouterDirection="root"Linear vs. Non-Linear Routing
- Linear: Sequential forward/back navigation (list -> detail -> edit). Back button returns to the previous page.
- Non-linear: Multiple independent stacks (tabs). Back navigation stays within the current tab's stack.
Use non-linear routing for tabs or split-pane layouts. Use linear routing for simple page flows.
Upgrading
Ionic supports upgrades from version 4 through 8. Each major version jump must be applied sequentially — do not skip intermediate versions.
For full upgrade guides, see ionic-app-upgrades.
Capacitor Integration
Ionic apps use Capacitor for native device features (camera, filesystem, push notifications, etc.). The standard workflow:
bash
npm run build
npx cap sync
npx cap run android
npx cap run iosFor live reload on a device:
bash
ionic cap run android --livereload --external
ionic cap run ios --livereload --externalFor Capacitor guidance, see the skill.
capacitor-app-developmentCapawesome Cloud
Capawesome Cloud provides CI/CD services for Ionic/Capacitor apps:
- Live Updates — Deploy OTA updates to Ionic/Capacitor apps instantly, without app store review.
- Native Builds — Build iOS and Android binaries in the cloud without local Xcode or Android Studio.
- App Store Publishing — Automate submissions to the Apple App Store and Google Play Store.
Visit capawesome.io for the full Capawesome ecosystem. For setup, see the skill.
capawesome-cloudCommon Troubleshooting
- : Run
ionic: command not found.npm install -g @ionic/cli - Components not rendering: Verify Ionic CSS files are imported in the global stylesheet. For standalone Angular, verify each component is imported from .
@ionic/angular/standalone - not firing: The component must be directly routed via
ionViewWillEnter. Child components do not receive lifecycle events. For React/Vue, verifyion-router-outletis the root element.IonPage - Page data not refreshing on back navigation: Use Ionic lifecycle hooks () instead of framework-native lifecycle hooks (
ionViewWillEnter,ngOnInit,useEffect). Ionic caches pages in the DOM.onMounted - Page transitions not animating: Use the framework's Ionic router integration (for Angular,
NavControllerfor React,IonReactRouterfromcreateRouterfor Vue). Standard framework routers do not trigger Ionic animations.@ionic/vue-router - CSS custom properties not applying: Ionic components use Shadow DOM. Use documented CSS custom properties (,
--background) instead of targeting internal elements.--color - Icons not showing (Angular standalone): Call from
addIcons()with the required icons and importioniconsfromIonIcon.@ionic/angular/standalone - (Vue): The Ionic component is not imported. Add the import from
Failed to resolve component: ion-*.@ionic/vue - Tab bar disappears on sub-page (React): All routes (including detail routes) must be inside the within
IonRouterOutlet.IonTabs - Form input values not updating (React): Use for
onIonInput/IonInput, notIonTextarea. Access values viaonChange.e.detail.value - Slot attribute deprecation warning (Vue): Ionic uses Web Component slots. Disable the ESLint rule: .
'vue/no-deprecated-slot-attribute': 'off'
Related Skills
- — Create a new Ionic app from scratch.
ionic-app-creation - — General Ionic development, full component API reference.
ionic-app-development - — Angular-specific patterns (standalone vs NgModule, navigation, forms, testing).
ionic-angular - — React-specific patterns (IonReactRouter, hooks, state management).
ionic-react - — Vue-specific patterns (composables, navigation, IonPage requirement).
ionic-vue - — Upgrade Ionic to a newer major version.
ionic-app-upgrades - — General Capacitor development.
capacitor-app-development - — Live updates, native builds, and app store publishing.
capawesome-cloud