21

Right now the ionic app renders with android styling by default. Instead of using the ?ionicplatform=ios param every single time I'd like that to be the default option.

I looked for hints in the config.xml as well as the config settings in app.module.ts such as:

IonicModule.forRoot(
      MyApp, 
      {
        swipeBackEnabled: true,
        platforms: {
          ios: {
            swipeBackEnabled: true,
            statusbarPadding: false
          }
        }
      }
    ),

and was unable to find an elegant way of doing it...Any ideas?

10 Answers 10

33

You just need to do this:

app.module.ts

imports: [
IonicModule.forRoot(MyApp,{
    mode: 'ios'
})
],

Note: From @sebaferreras

Btw, by setting this config the app will use the ios styles and components even if you run it on an Android device. Please notice that ?ionicplatform=ios is just used to see how the app looks like when using the browser, but does not affect how the app is built. But setting mode: 'ios' will force the ios mode and apply the ios styles even if you build and create a .apk file.

Sign up to request clarification or add additional context in comments.

6 Comments

Ok, works! Btw, for anyone reading this with the intention to do the opposite, the alternative mode to ios is not android but 'md' // material design
Glad to hear that it helped :)
Btw @DavidHaddad, by setting this config the app will use the ios styles and components even if you run it on an Android device. Please notice that?ionicplatform=ios is just used to see how the app looks like when using the browser, but does not affect how the app is built. But setting mode: 'ios' will force the ios mode and apply the ios styles even if you build and create a .apk file.
Thanks for the note! There’s an override for the node within platform Android section which sets mode to ‘md’. The reason why the question was asked was to override the styles when the app is seen on the web :-)
You can use this CLI too: --lab, -l Test your apps on multiple platform types in the browser
|
15

in index.html just define mode (this is not recommended).

For iOS

<html lang="en" mode="ios">

For android

<html lang="en" mode="md">

Please just modify the mode in IonicModule (ios/md)

imports: [
  IonicModule.forRoot(MyApp,{
    mode: 'ios'
  })
],

1 Comment

this one save me. ionic documentation tell us to use class="ios". which is should be mode="ios". thank you !
12

Using @ionic/react this is how you go:

import {setupConfig} from '@ionic/react'

setupConfig({mode: 'ios'})

Alternatively for enforcing Material Design:

setupConfig({mode: 'md'})

You could place this code in your main App.js/App.tsx file.

See also https://ionicframework.com/docs/react/config for further global settings.

Comments

6

Ionic v6 (React)

Go to your app.tsx

  • To force Android style (Material Design)

setupIonicReact({ mode: 'md' })

  • To force iOS style

setupIonicReact({ mode: 'ios' })

Reference: https://ionicframework.com/docs/react/config

Ionic v6 (Angular)

Go to your app.module.ts

  • To force Android style (Material Design)

imports: [ IonicModule.forRoot({ mode: 'md' }) ]

  • To force iOS style

imports: [ IonicModule.forRoot({ mode: 'ios' }) ]

https://ionicframework.com/docs/angular/config

Comments

5

For anybody using the new Vue.js support for Ionic, forcing the rendering mode can be achieved by doing this when you import Vue:

import Vue from 'vue';

// ios
Vue.use(Ionic, {
  mode: 'ios'
});

// material design
Vue.use(Ionic, {
  mode: 'md'
});

Comments

4

Just adding to Ben Everard's answer, if you are using more recent version of Ionic (4.8.0 in my case)

IonicModule.forRoot -> 

will not accept two parameters. Just drop the first parameter making it as:

IonicModule.forRoot({ mode: 'ios' }),

Comments

2

Please try this in your index.html file

I tried the below html code in ionic 4 and it works

Use the below one for getting styled your apk same as ios.

<html lang="en" dir="ltr" class="plt-iphone plt-ios plt-phablet plt-mobile ios" mode="ios">

Use the below one for getting styled your ios app same as android.

<html lang="en" dir="ltr" class="plt-android plt-mobile md" mode="md">

Comments

1

For Vue 3 and Ionic 6

import { createApp } from "vue";
import App from "./App.vue";
import { IonicVue } from "@ionic/vue";


const app = createApp(App);
app.use(IonicVue, {mode: "ios"});
app.mount("#app");

Comments

0

Ionic V6 - VUE

createApp(App).use(IonicVue, {
  mode: 'ios',
});

Documentation: https://ionicframework.com/docs/vue/config

Comments

0

If you are using bootstrapApplication() in Angular, you can modify the global configuration of Ionic using provideIonicAngular() like this in main.ts file

bootstrapApplication(AppComponent, {
  providers: [
    // other providers
    provideIonicAngular({ mode: 'ios' }),
  ]
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.