Ionic Overview
Ionic is a complete open-source SDK for hybrid mobile app development created by Max Lynch, Ben Sperry, and Adam Bradley of Drifty Co. in 2013. Ionic provides tools and services for developing hybrid mobile apps using Web technologies like CSS, HTML5, and Sass.
Key Features
- Cross-Platform: Build for iOS, Android, and web.
- Web Standards: Uses HTML, CSS, and JavaScript.
- UI Components: Pre-built mobile-optimized components.
- Capacitor: Native runtime and plugin system.
- Framework Agnostic: Works with React, Angular, Vue.
- CLI: Powerful command-line interface.
- Community: Large ecosystem of plugins.
Common Use Cases
Hybrid Mobile Apps
Apps that run on multiple platforms.
Progressive Web Apps
Web apps with native-like features.
Enterprise Apps
Internal business applications.
Prototyping
Quickly build app prototypes.
Example Code
// Ionic React component example
import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar, IonButton } from '@ionic/react';
import React, { useState } from 'react';
const Home: React.FC = () => {
const [count, setCount] = useState(0);
return (
<IonPage>
<IonHeader>
<IonToolbar>
<IonTitle>Ionic React App</IonTitle>
</IonToolbar>
</IonHeader>
<IonContent className="ion-padding">
<p>Count: {count}</p>
<IonButton onClick={() => setCount(count + 1)}>Increment</IonButton>
</IonContent>
</IonPage>
);
};
export default Home;
// Ionic Angular component example
/*
import { Component } from '@angular/core';
import { AlertController } from '@ionic/angular';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
constructor(private alertController: AlertController) {}
async showAlert() {
const alert = await this.alertController.create({
header: 'Alert',
message: 'This is an alert!',
buttons: ['OK']
});
await alert.present();
}
}
*/
// Ionic Vue component example
/*
<template>
<ion-page>
<ion-header>
<ion-toolbar>
<ion-title>Ionic Vue App</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-button @click="increment">Count: {{ count }}</ion-button>
</ion-content>
</ion-page>
</template>
<script>
import { ref } from 'vue';
import { IonPage, IonHeader, IonToolbar, IonTitle, IonContent, IonButton } from '@ionic/vue';
export default {
components: { IonPage, IonHeader, IonToolbar, IonTitle, IonContent, IonButton },
setup() {
const count = ref(0);
const increment = () => count.value++;
return { count, increment };
}
}
</script>
*/