### Install Dependencies and Start Development Server Source: https://github.com/ionic-team/ionic-docs/blob/main/CONTRIBUTING.md Installs project dependencies using npm and starts the local development server to preview documentation changes. This is a common first step for local development. ```sh npm install npm start ``` -------------------------------- ### Install Ionic CLI and Create a New React Project Source: https://github.com/ionic-team/ionic-docs/blob/main/docs/react/overview.md This snippet demonstrates how to install the global Ionic CLI and initialize a new React-based Ionic application using the tabs template. It also covers navigating into the project directory and starting the development server. ```shell-session npm install -g @ionic/cli ionic start myApp tabs --type react cd myApp ionic serve ``` -------------------------------- ### Basic Ripple Effect Setup Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/ripple-effect/basic/index.md This example shows how to set up the ripple effect for different frameworks. Ensure the correct file paths are used for each framework's specific implementation. ```javascript import Playground from '@site/src/components/global/Playground'; import javascript from './javascript.md'; import react_main_tsx from './react/main_tsx.md'; import react_main_css from './react/main_css.md'; import vue from './vue.md'; import angular_example_component_html from './angular/example_component_html.md'; import angular_example_component_css from './angular/example_component_css.md'; import angular_example_component_ts from './angular/example_component_ts.md'; ``` -------------------------------- ### Install Ionic CLI and Create Angular App Source: https://github.com/ionic-team/ionic-docs/blob/main/docs/angular/overview.md Installs the Ionic CLI globally and creates a new Ionic Angular project with a tabs layout. It then navigates into the project directory and starts the development server. ```shell $ npm install -g @ionic/cli $ ionic start myApp tabs --type angular $ cd myApp $ ionic serve █ ``` -------------------------------- ### Ionic Toast Layout Examples (JavaScript, React, Vue, Angular) Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/toast/layout/index.md Demonstrates how to implement toast messages with different layout options across multiple frameworks. Includes examples for basic toast display and custom configurations. Ensure Ionic core and framework-specific components are installed. ```javascript import {{ toastController }} from '@ionic/core'; async function showToast() { const toast = await toastController.create({ message: 'Your toast message', duration: 2000, position: 'bottom' }); await toast.present(); } ``` ```react import {{ useIonToast }} from '@ionic/react'; function MyComponent() { const [present] = useIonToast(); const showToast = () => { present({ message: 'Your toast message', duration: 2000, position: 'bottom' }); }; return ( ); } ``` ```vue ``` ```angular import {{ Component }} from '@angular/core'; import {{ ToastController }} from '@ionic/angular'; @Component({ selector: 'app-example', templateUrl: './example.component.html', styleUrls: ['./example.component.scss'] }) export class ExampleComponent { constructor(private toastController: ToastController) {} async presentToast() { const toast = await this.toastController.create({ message: 'Your toast message', duration: 2000, position: 'bottom' }); await toast.present(); } } ``` -------------------------------- ### Ionic Modal Controller Example Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/modal/controller/index.md This example shows how to present a modal using the ModalController in Ionic. It includes setup for JavaScript, React, Vue, and Angular. ```javascript import Playground from '@site/src/components/global/Playground'; import javascript from './javascript.md'; import react from './react.md'; import vue_example from './vue/example_vue.md'; import vue_modal from './vue/modal_vue.md'; import angular_example_component_html from './angular/example_component_html.md'; import angular_example_component_ts from './angular/example_component_ts.md'; import angular_modal_example_component_ts from './angular/modal-example_component_ts.md'; import angular_modal_example_component_html from './angular/modal-example_component_html.md'; ``` -------------------------------- ### Ionic React App Initialization and Styling Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/theming/always-dark-mode/react/app_tsx.md This snippet demonstrates the setup of a new Ionic React application. It includes importing necessary Ionic components, core CSS, basic styles, optional utility CSS, and theme variables. The `setupIonicReact` function initializes Ionic, and the `App` component renders the main application structure with `IonApp` and a custom `Example` component. ```tsx import React from 'react'; import { setupIonicReact, IonApp } from '@ionic/react'; /* Core CSS required for Ionic components to work properly */ import '@ionic/react/css/core.css'; /* Basic CSS for apps built with Ionic */ import '@ionic/react/css/normalize.css'; import '@ionic/react/css/structure.css'; import '@ionic/react/css/typography.css'; /* Optional CSS utils that can be commented out */ import '@ionic/react/css/padding.css'; import '@ionic/react/css/float-elements.css'; import '@ionic/react/css/text-alignment.css'; import '@ionic/react/css/text-transformation.css'; import '@ionic/react/css/flex-utils.css'; import '@ionic/react/css/display.css'; /** * Ionic Dark Palette * ----------------------------------------------------- * For more information, please see: * https://ionicframework.com/docs/theming/dark-mode */ import '@ionic/react/css/palettes/dark.always.css'; // import '@ionic/react/css/palettes/dark.class.css'; // import '@ionic/react/css/palettes/dark.system.css'; /* Theme variables */ import './theme/variables.css'; import Example from './main'; setupIonicReact(); export default function App() { return ( ); } ``` -------------------------------- ### Ionic React App Initialization Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/theming/always-high-contrast-mode/react/app_tsx.md This snippet demonstrates the basic setup for an Ionic React application. It includes importing necessary Ionic React components, core and utility CSS files, and initializing the Ionic React framework. The `App` component renders the main application structure, including a custom `Example` component within `IonApp`. ```tsx import React from 'react'; import { setupIonicReact, IonApp } from '@ionic/react'; /* Core CSS required for Ionic components to work properly */ import '@ionic/react/css/core.css'; /* Basic CSS for apps built with Ionic */ import '@ionic/react/css/normalize.css'; import '@ionic/react/css/structure.css'; import '@ionic/react/css/typography.css'; /* Optional CSS utils that can be commented out */ import '@ionic/react/css/padding.css'; import '@ionic/react/css/float-elements.css'; import '@ionic/react/css/text-alignment.css'; import '@ionic/react/css/text-transformation.css'; import '@ionic/react/css/flex-utils.css'; import '@ionic/react/css/display.css'; /* High Contrast Palette */ import '@ionic/react/css/palettes/high-contrast.always.css'; import Example from './main'; setupIonicReact(); export default function App() { return ( ); } ``` -------------------------------- ### Install and Configure NVM for Node.js Management Source: https://github.com/ionic-team/ionic-docs/blob/main/docs/developing/tips.md Commands to install nvm, verify the installation, and set the default LTS version of Node.js. This approach avoids permission issues by managing Node.js in the user's home directory. ```shell curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash command -v nvm nvm install --lts nvm alias default lts/* node -v which npm ``` -------------------------------- ### Ionic Picker Component Example Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/picker/prefix-suffix/index.md Demonstrates the integration of the Ionic Picker component. This example showcases how to use the Playground component to display picker examples across different frameworks. ```javascript import Playground from '@site/src/components/global/Playground'; import javascript from './javascript.md'; import angular_example_component_html from './angular/example_component_html.md'; import angular_example_component_ts from './angular/example_component_ts.md'; import react from './react.md'; import vue from './vue.md'; ``` -------------------------------- ### Ionic Toolbar Examples Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/toolbar/theming/colors/javascript.md Examples of Ionic Toolbars with default and themed colors. ```APIDOC ## Ionic Toolbar Examples ### Description This section showcases the usage of the `ion-toolbar` component with various color options provided by Ionic. ### Method Not Applicable (UI Component Examples) ### Endpoint Not Applicable (UI Component Examples) ### Parameters Not Applicable (UI Component Examples) ### Request Example Not Applicable (UI Component Examples) ### Response Not Applicable (UI Component Examples) ## Default Toolbar ### Description Displays a basic toolbar with a default title. ### Code ```html Default Toolbar ``` ## Themed Toolbars ### Description Demonstrates toolbars styled with different color themes available in Ionic. ### Code Examples **Primary Toolbar:** ```html Primary Toolbar ``` **Secondary Toolbar:** ```html Secondary Toolbar ``` **Tertiary Toolbar:** ```html Tertiary Toolbar ``` **Success Toolbar:** ```html Success Toolbar ``` **Warning Toolbar:** ```html Warning Toolbar ``` **Danger Toolbar:** ```html Danger Toolbar ``` **Light Toolbar:** ```html Light Toolbar ``` **Medium Toolbar:** ```html Medium Toolbar ``` **Dark Toolbar:** ```html Dark Toolbar ``` ``` -------------------------------- ### Ionic Toggle Label Placement Examples Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/toggle/label-placement/index.md Showcases how to implement label placement for Ionic Toggles across different JavaScript frameworks. This includes basic setup and usage within each framework's context. Ensure Ionic components are correctly installed and imported. ```javascript import Playground from '@site/src/components/global/Playground'; import javascript from './javascript.md'; import react from './react.md'; import vue from './vue.md'; import angular_example_component_html from './angular/example_component_html.md'; import angular_example_component_ts from './angular/example_component_ts.md'; ``` ```react import React from 'react'; import { IonToggle, IonLabel } from '@ionic/react'; function Example() { return ( <> Default Placement Start Placement End Placement ); } export default Example; ``` ```vue ``` ```angular // src/app/example.component.html Default Placement Start Placement End Placement // src/app/example.component.ts import { Component } from '@angular/core'; @Component({ selector: 'app-example-component', templateUrl: './example.component.html', styleUrls: ['./example.component.css'] }) export class ExampleComponent { } ``` -------------------------------- ### Ionic Core Setup Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/theming/always-high-contrast-mode/javascript/index_ts.md This snippet demonstrates the essential setup for an Ionic application, including defining custom elements, adding icons, and importing necessary CSS files. ```APIDOC ## Ionic Core Setup ### Description This code snippet shows how to initialize Ionic components, add custom icons, and apply core styling to an Ionic application. ### Method N/A (Initialization Script) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ### Code Example ```typescript import { defineCustomElements } from '@ionic/core/loader'; import { addIcons } from 'ionicons'; import { personCircle, personCircleOutline, sunny, sunnyOutline } from 'ionicons/icons'; /* Core CSS required for Ionic components to work properly */ import '@ionic/core/css/core.css'; /* Basic CSS for apps built with Ionic */ import '@ionic/core/css/normalize.css'; import '@ionic/core/css/structure.css'; import '@ionic/core/css/typography.css'; /* Optional CSS utils that can be commented out */ import '@ionic/core/css/padding.css'; import '@ionic/core/css/float-elements.css'; import '@ionic/core/css/text-alignment.css'; import '@ionic/core/css/text-transformation.css'; import '@ionic/core/css/flex-utils.css'; import '@ionic/core/css/display.css'; /* Theme variables */ import './theme/variables.css'; addIcons({ personCircle, personCircleOutline, sunny, sunnyOutline }); defineCustomElements(); ``` ``` -------------------------------- ### Angular Grid Fixed Example Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/grid/fixed/index.md This Angular example demonstrates a fixed-size grid setup with HTML, CSS, and TS components. ```typescript import Playground from '@site/src/components/global/Playground'; import angular_example_component_html from './angular/example_component_html.md'; import angular_example_component_css from './angular/example_component_css.md'; import angular_example_component_ts from './angular/example_component_ts.md'; ``` -------------------------------- ### Ion Toolbar with Start and End Buttons Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/buttons/placement/angular/example_component_html.md This example shows an ion-toolbar with buttons placed in the 'start' and 'end' slots, typically used for navigation or actions. ```APIDOC ## ion-toolbar with Start and End Buttons ### Description This toolbar demonstrates placing buttons in the start and end slots. The 'start' slot is usually for navigation elements like back buttons, and the 'end' slot is for action buttons. ### Method N/A (This is a UI component example) ### Endpoint N/A ### Parameters N/A ### Request Example ```html Start Buttons End ``` ### Response N/A (This is a UI component example) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Playground with Multiple File Examples Source: https://github.com/ionic-team/ionic-docs/blob/main/src/components/global/Playground/README.md Supports single and multi-file examples for showcasing complex component structures across different frameworks. ```APIDOC ## Playground with Multiple File Examples ### Description Playground supports single file and multi-file examples to show the required code to create a sample. Use the `files` option to specify the file location and contents for a single framework target. You can mix multi-file and single file examples together. ### Method Not Applicable (Component Usage) ### Endpoint Not Applicable (Component Usage) ### Parameters #### Props - **files** (object) - Required - An object where keys are framework names (e.g., 'angular', 'react', 'vue', 'javascript') and values define the file structure for that framework. For nested files, use an object with a `files` property. - **[framework]** (object | string) - The file structure for a specific framework. - **files** (object) - For nested file structures, an object where keys are file paths and values are file contents (or imported modules). ### Request Example ```tsx import angular_example_component_html from './angular/example_component_html.md'; import angular_example_component_ts from './angular/example_component_ts.md'; import react_main_tsx from './react/main_tsx.md'; import react_main_css from './react/main_css.md'; import vue from './vue.md'; import javascript from './javascript.md'; ; ``` ### Response Not Applicable (Component Usage) ``` -------------------------------- ### IonRefresher Component Example Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/refresher/pull-properties/react.md This example demonstrates how to use the IonRefresher component to implement a pull-to-refresh feature in an Ionic application. It includes basic setup and a simulated data refresh. ```APIDOC ## IonRefresher Component ### Description The `IonRefresher` component allows users to pull down from the top of the content to trigger a refresh action. This is commonly used to update data displayed in lists or other dynamic content. ### Method Not applicable (Client-side component) ### Endpoint Not applicable (Client-side component) ### Parameters #### Component Properties - **slot** (string) - Optional - Specifies where the refresher should be placed within the DOM (e.g., `"fixed"`). - **pullFactor** (number) - Optional - The factor used to calculate the pull distance. Defaults to `0.85`. - **pullMin** (number) - Optional - The minimum distance the user must pull down to trigger the refresh. Defaults to `100`. - **pullMax** (number) - Optional - The maximum distance the user can pull down. Defaults to `200`. #### Event Handlers - **onIonRefresh** (function) - Required - A function that is called when the user completes the pull-to-refresh gesture. This function receives an event object containing a `complete()` method to signal the end of the refresh. ### Request Example ```tsx import React from 'react'; import { IonContent, IonRefresher, IonRefresherContent, RefresherCustomEvent } from '@ionic/react'; function handleRefresh(event: RefresherCustomEvent) { setTimeout(() => { // Load data here event.detail.complete(); }, 2000); } {/* Your content here */} ``` ### Response #### Event Details - **detail.complete** (function) - Call this function to complete the refresher and hide the loading indicator. #### Response Example Not applicable (This is a client-side event handler). ``` -------------------------------- ### JavaScript Card Theming Example Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/card/theming/colors/index.md Use this JavaScript example to apply color themes to Ionic cards. No specific setup is required beyond including the Ionic framework. ```javascript import Playground from '@site/src/components/global/Playground'; import javascript from './javascript.md'; import react from './react.md'; import vue from './vue.md'; import angular_example_component_html from './angular/example_component_html.md'; import angular_example_component_ts from './angular/example_component_ts.md'; ``` -------------------------------- ### Initialize and Run Ionic Project Source: https://github.com/ionic-team/ionic-docs/blob/main/docs/developer-resources/guides/first-app-v4/intro.md Commands to create a new Ionic project using the tabs template, navigate into the project directory, and start the development server for browser-based testing. ```shell ionic start photo-gallery tabs cd photo-gallery ionic serve ``` -------------------------------- ### Implementing Ionic Split Pane Theming Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/split-pane/theming/css-properties/index.md Demonstrates how to configure and theme an Ionic Split Pane component. The examples show the necessary file structures and component definitions for various web frameworks. ```javascript import { IonSplitPane, IonMenu, IonContent } from '@ionic/react'; const App = () => ( Menu Content
Main Content
); ``` ```typescript import { Component } from '@angular/core'; @Component({ selector: 'app-example', templateUrl: 'example.component.html', styleUrls: ['example.component.css'] }) export class ExampleComponent {} ``` ```css :host { --side-width: 300px; --border-color: #ccc; } ``` -------------------------------- ### Vue Tabs Implementation Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/tabs/basic/index.md Configuration for Ionic Tabs in a Vue.js project. This example assumes a basic setup. ```vue ``` -------------------------------- ### Ionic Core Setup and Icon Integration (TypeScript) Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/input/start-end-slots/javascript/index_ts.md This snippet demonstrates the essential setup for an Ionic application. It includes importing the defineCustomElements function to register custom elements, adding specific icons from Ionicon using the addIcons function, and importing various core CSS files for basic styling, structure, typography, and optional utilities. It also shows how to import dark mode palettes and theme variables. ```typescript import { defineCustomElements } from '@ionic/core/loader'; import { addIcons } from 'ionicons'; import { eye, lockClosed } from 'ionicons/icons'; /* Core CSS required for Ionic components to work properly */ import '@ionic/core/css/core.css'; /* Basic CSS for apps built with Ionic */ import '@ionic/core/css/normalize.css'; import '@ionic/core/css/structure.css'; import '@ionic/core/css/typography.css'; /* Optional CSS utils that can be commented out */ import '@ionic/core/css/padding.css'; import '@ionic/core/css/float-elements.css'; import '@ionic/core/css/text-alignment.css'; import '@ionic/core/css/text-transformation.css'; import '@ionic/core/css/flex-utils.css'; import '@ionic/core/css/display.css'; /** * Ionic Dark Palette * ----------------------------------------------------- * For more information, please see: * https://ionicframework.com/docs/theming/dark-mode */ // import '@ionic/core/css/palettes/dark.always.css'; // import '@ionic/core/css/palettes/dark.class.css'; import '@ionic/core/css/palettes/dark.system.css'; /* Theme variables */ import './theme/variables.css'; /** * On Ionicons 7.2+ these icons * get mapped to a kebab-case key. * Alternatively, developers can do: * addIcons({ 'eye': eye, 'lock-closed': lockClosed }); */ addIcons({ eye, lockClosed }); defineCustomElements(); ``` -------------------------------- ### Ionic Core Setup and Styling Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/fab/before-content/javascript/index_ts.md This snippet demonstrates the necessary imports for setting up an Ionic application. It includes defining custom elements, importing core CSS files for structure and typography, and applying optional CSS utilities. It also shows how to import theme variables. ```typescript import { defineCustomElements } from '@ionic/core/loader'; import { addIcons } from 'ionicons'; import { add } from 'ionicons/icons'; /* Core CSS required for Ionic components to work properly */ import '@ionic/core/css/core.css'; /* Basic CSS for apps built with Ionic */ import '@ionic/core/css/normalize.css'; import '@ionic/core/css/structure.css'; import '@ionic/core/css/typography.css'; /* Optional CSS utils that can be commented out */ import '@ionic/core/css/padding.css'; import '@ionic/core/css/float-elements.css'; import '@ionic/core/css/text-alignment.css'; import '@ionic/core/css/text-transformation.css'; import '@ionic/core/css/flex-utils.css'; import '@ionic/core/css/display.css'; /* Theme variables */ import './theme/variables.css'; /** * On Ionicons 7.2+ this icon * gets mapped to a "add" key. * Alternatively, developers can do: * addIcons({ 'add': add }); */ addIcons({ add }); defineCustomElements(); ``` -------------------------------- ### Ionic Vue Script Setup for Header/Footer Example Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/content/fullscreen/vue.md This script setup block for a Vue component in an Ionic application imports the necessary components from '@ionic/vue'. These components are used to build the UI elements like header, content, and footer. ```typescript import { IonContent, IonFooter, IonHeader, IonTitle, IonToolbar } from '@ionic/vue'; ``` -------------------------------- ### Implement Ionic Select with Start and End Slots Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/select/start-end-slots/index.md Demonstrates the usage of the Ionic Select component with custom start and end slots. This setup allows for flexible content placement within the select component across various frameworks. ```javascript import { IonSelect, IonSelectOption } from '@ionic/vue'; // Example usage of select with slots const SelectExample = () => (
Start Content
Option 1
End Content
); ``` ```angular
Start Content
Option 1
End Content
``` -------------------------------- ### Picker Legacy - Basic Usage Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/picker-legacy/inline/isOpen/demo.html Demonstrates how to initialize and configure the Picker Legacy component, including setting columns, buttons, and event listeners. ```APIDOC ## Picker Legacy - Basic Usage ### Description This example shows how to select and configure the `ion-picker-legacy` component. It covers setting up columns with options, defining buttons with actions, and handling the `ionPickerDidDismiss` event to close the picker. ### Method Not applicable (JavaScript API) ### Endpoint Not applicable (JavaScript API) ### Parameters This section is not applicable as this is a JavaScript API example. ### Request Example ```javascript var picker = document.querySelector('ion-picker-legacy'); picker.columns = [ { name: 'languages', options: [ { text: 'JavaScript', value: 'javascript' }, { text: 'TypeScript', value: 'typescript' }, { text: 'Rust', value: 'rust' }, { text: 'C#', value: 'c#' }, ] }, ]; picker.buttons = [ { text: 'Cancel', role: 'cancel' }, { text: 'Confirm', handler: (value) => { console.log(`You selected: ${value.languages.value}`); } }, ]; picker.addEventListener('ionPickerDidDismiss', (event) => { picker.isOpen = false; }); ``` ### Response #### Success Response (200) Not applicable (JavaScript API) #### Response Example Not applicable (JavaScript API) ``` -------------------------------- ### Ionic Platform Configuration Examples Source: https://github.com/ionic-team/ionic-docs/blob/main/docs/developing/config/per-platform/index.md Code examples demonstrating how to configure Ionic's platform features, specifically the 'animated' property, for different frameworks. This includes runtime configuration using `isPlatform`. ```APIDOC ## Ionic Platform Configuration This documentation provides examples for configuring Ionic platform features, such as animation, across various frameworks. It highlights how to set configurations at runtime and utilize platform detection. ### Angular Configuration #### app.module.ts ```ts import { isPlatform, IonicModule } from '@ionic/angular'; @NgModule({ ... imports: [ IonicModule.forRoot({ animated: !isPlatform('mobileweb') }) ], ... }) ``` ### Angular Standalone Configuration #### main.ts ```ts import { isPlatform, provideIonicAngular } from '@ionic/angular/standalone'; bootstrapApplication(AppComponent, { providers: [ ..., provideIonicAngular({ animated: !isPlatform('mobileweb') }) ] }) ``` ### React Configuration #### App.tsx ```tsx import { isPlatform, setupIonicReact } from '@ionic/react'; setupIonicReact({ animated: !isPlatform('mobileweb'), }); ``` ### Vue Configuration #### main.ts ```ts import { IonicVue, isPlatform } from '@ionic/vue'; createApp(App).use(IonicVue, { animated: !isPlatform('mobileweb'), }); ``` **Note:** Since the configuration is set at runtime, you may not have access to the Platform Dependency Injection. In such cases, you can use the underlying functions that the provider uses directly. Refer to the respective framework documentation for more details on platform detection. ``` -------------------------------- ### Vue Grid Customizing Width Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/grid/customizing/width/index.md Example of customizing grid column width using Vue. No specific setup required. ```vue import Playground from '@site/src/components/global/Playground'; import vue from './vue.md'; ``` -------------------------------- ### JavaScript Grid Customizing Width Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/grid/customizing/width/index.md Example of customizing grid column width using JavaScript. No specific setup required. ```javascript import Playground from '@site/src/components/global/Playground'; import javascript from './javascript.md'; ``` -------------------------------- ### Initialize Ionic React Project Source: https://github.com/ionic-team/ionic-docs/blob/main/docs/react/your-first-app.md Creates a new Ionic project using the tabs template and installs necessary Capacitor plugins for camera, preferences, and filesystem access. ```shell ionic start photo-gallery tabs --type=react cd photo-gallery npm install @capacitor/camera @capacitor/preferences @capacitor/filesystem npm install @ionic/pwa-elements ``` -------------------------------- ### Create and Run an Ionic React Project Source: https://github.com/ionic-team/ionic-docs/blob/main/docs/react/quickstart.md Generate a new blank Ionic React application and start the development server to view it in the browser. ```shell ionic start myApp blank --type react cd myApp ionic serve ``` -------------------------------- ### Basic Picker Implementation Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/picker/basic/index.md Demonstrates the basic structure for implementing a Picker component. This example shows how to configure the Picker for JavaScript, React, Vue, and Angular. ```javascript import Playground from '@site/src/components/global/Playground'; import javascript from './javascript.md'; import angular_example_component_html from './angular/example_component_html.md'; import angular_example_component_ts from './angular/example_component_ts.md'; import react from './react.md'; import vue from './vue.md'; ``` -------------------------------- ### Ionic Range Component Examples Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/range/labels/vue.md This snippet demonstrates the usage of the ion-range component with different label placement options: start, end, fixed, and stacked. ```APIDOC ## Ionic Range Component ### Description The `ion-range` component provides a way to select a numeric value within a specified range. It supports various label placements to enhance usability and visual appeal. ### Usage This example showcases different `label-placement` attributes for the `ion-range` component. ### Code Example ```html ``` ### Component Properties #### `label-placement` - **start** (string) - Places the label at the start of the range. - **end** (string) - Places the label at the end of the range. - **fixed** (string) - Uses a fixed width for the label. - **stacked** (string) - Stacks the label above the range. #### `label` - **(string)** - The text content for the label associated with the range. ``` -------------------------------- ### Ionic Button Basic Usage Example Source: https://github.com/ionic-team/ionic-docs/blob/main/docs/api/button.md Demonstrates the fundamental implementation of an ion-button component. This serves as a starting point for integrating buttons into an Ionic application. ```html Button Outline Button Clear Button Solid Button ``` -------------------------------- ### Basic Back Button Implementation Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/back-button/basic/javascript.md Demonstrates a simple setup for the back button, showing how it automatically appears when navigating to a new page. ```APIDOC ## Basic Back Button Implementation ### Description This example shows how to use `ion-nav-link` to navigate between pages and how `ion-back-button` is automatically displayed on the target page. ### Method N/A (Client-side navigation) ### Endpoint N/A (Client-side navigation) ### Parameters N/A ### Request Example ```html ``` ### Response N/A (Client-side rendering) ### Response Example N/A ``` -------------------------------- ### Basic Split Pane Implementation Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/split-pane/theming/css-properties/angular/example_component_html.md This example demonstrates a basic implementation of the Ionic Split Pane component, creating a master-detail view that is responsive. ```APIDOC ## Basic Split Pane Implementation ### Description This example shows how to use the `` component to create a responsive layout. The `when="xs"` attribute means the split pane will only activate on extra-small screen sizes, typically showing a menu and main content side-by-side on larger screens and stacking them on smaller screens. ### Method Not applicable (this is a UI component definition) ### Endpoint Not applicable (this is a UI component definition) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```html Menu Menu Content
Main View Main View Content
``` ### Response #### Success Response (200) Not applicable (this is a UI component definition) #### Response Example Not applicable (this is a UI component definition) ``` -------------------------------- ### IonList and IonItem Examples Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/list/lines/react.md Demonstrates the usage of IonList with different 'lines' attributes (full, inset, none) and includes basic IonItem usage. ```APIDOC ## IonList and IonItem Component Usage ### Description This section provides examples of how to implement Ionic lists with various styling options for item dividers. ### Method N/A (Component Usage) ### Endpoint N/A (Component Usage) ### Parameters N/A (Component Usage) ### Request Example N/A (Component Usage) ### Response N/A (Component Usage) ## Examples of IonList with different 'lines' attributes: ### Full Lines ```tsx Full Lines Full Lines Full Lines ``` ### Inset Lines ```tsx Inset Lines Inset Lines Inset Lines ``` ### No Lines ```tsx No Lines No Lines No Lines ``` ``` -------------------------------- ### Ionic Vue Checkbox Form Example Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/checkbox/helper-error/vue.md This snippet shows a complete example of using the IonCheckbox component within a Vue.js form. It includes template structure with event handling and binding, script setup for component logic, state management for checkbox status and validation, and a submit function to process the form data. The example utilizes Ionic Vue components like IonCheckbox and IonButton. ```html ``` ```typescript ``` -------------------------------- ### Ionic Input Examples Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/item/inputs/vue.md Demonstrates different label placements for Ionic input fields. ```APIDOC ## Ionic Input Components ### Description Examples showcasing various label placements for Ionic input fields, including default, fixed, stacked, and floating. ### Method N/A (UI Component Examples) ### Endpoint N/A (UI Component Examples) ### Parameters N/A (UI Component Examples) ### Request Example N/A (UI Component Examples) ### Response N/A (UI Component Examples) ``` -------------------------------- ### Ionic Popover: Left Alignment Example Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/popover/customization/positioning/angular/example_component_html.md This snippet illustrates an Ionic Popover positioned to the left of a trigger element with start alignment. It depends on the Ionic Framework and HTML. ```html
Side=Left, Alignment=Start Hello World!
``` -------------------------------- ### Ionic Popover: Bottom Alignment Example Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/popover/customization/positioning/angular/example_component_html.md This snippet demonstrates an Ionic Popover positioned to the bottom of a trigger element with start alignment. It utilizes Ionic Framework components and HTML. ```html
Side=Bottom, Alignment=Start Hello World!
``` -------------------------------- ### Creating and Controlling Animations Source: https://github.com/ionic-team/ionic-docs/blob/main/static/usage/v8/animations/basic/react.md This example demonstrates how to create a basic animation using `createAnimation` and control its playback with buttons. ```APIDOC ## Creating and Controlling Animations ### Description This section shows how to use the `createAnimation` utility to define an animation that targets an element and control its playback (play, pause, stop) via user interaction. ### Method N/A (Client-side JavaScript) ### Endpoint N/A (Client-side JavaScript) ### Parameters N/A ### Request Example N/A ### Response N/A ### Code Example ```tsx import React, { useEffect, useRef } from 'react'; import { IonButton, IonCard, IonCardContent, createAnimation } from '@ionic/react'; import type { Animation } from '@ionic/react'; function Example() { const cardEl = useRef(null); const animation = useRef(null); useEffect(() => { if (animation.current === null) { animation.current = createAnimation() .addElement(cardEl.current!) .duration(1500) .iterations(Infinity) .fromTo('transform', 'translateX(0px)', 'translateX(100px)') .fromTo('opacity', '1', '0.2'); } }, [cardEl]); const play = () => { animation.current?.play(); }; const pause = () => { animation.current?.pause(); }; const stop = () => { animation.current?.stop(); }; return ( <> Card Play Pause Stop ); } export default Example; ``` ``` -------------------------------- ### Install Capacitor Plugins and PWA Elements Source: https://github.com/ionic-team/ionic-docs/blob/main/docs/vue/your-first-app.md Installs necessary native plugins for camera, preferences, and filesystem access, along with the PWA elements library for web support. ```shell npm install @capacitor/camera @capacitor/preferences @capacitor/filesystem npm install @ionic/pwa-elements ```