Logo

dev-resources.site

for different kinds of informations.

Ionic v8 - Create Even Better Hybrid Apps

Published at
4/2/2024
Categories
ionic
angular
webdev
news
Author
danielsogl
Categories
4 categories in total
ionic
open
angular
open
webdev
open
news
open
Author
10 person written this
danielsogl
open
Ionic v8 - Create Even Better Hybrid Apps

Today, the Ionic team released Ionic v8 RC 0 to the public. Let's explore the changes and new features of this major release of the popular mobile UI framework.

Introducing Built-in Dark Mode and High Contrast Theme

Currently, developers must define the default dark mode colors manually by defining and overriding CSS variables.

:root {
   --ion-item-background: white;
}

@media (prefers-color-scheme: dark) {
  body {
    /* global app variables */
  }

  .ios body {
     --ion-item-background: black;
  }

  .md body {
     --ion-item-background: black;
  }
}
Enter fullscreen mode Exit fullscreen mode

With Ionic v8, the need for multiple CSS files or the definition of multiple color variables can be eliminated by importing a new default theme file.

@import '@ionic/angular/css/palettes/dark.system.css';

 /* use dark theme exclusiv */
@import '@ionic/angular/css/palettes/dark.always.css';
Enter fullscreen mode Exit fullscreen mode

This sets the application colors and stepped colors when the CSS media query for prefers-color-scheme is dark. The dark theme is now applied to the :root selector instead of the body selector. The [:root](https://developer.mozilla.org/en-US/docs/Web/CSS/:root) selector represents the <html> element and is identical to the selector html, except that its specificity is higher. Of course, we can still add our own dark mode styles if we need to.

@media (prefers-color-scheme: dark) {
  :root {
    --ion-item-background: black;
  }
}
Enter fullscreen mode Exit fullscreen mode

If you're interested in learning more about the additional theming features, I recommend reading the updated dark mode docs.

High Contrast Theme

To enhance the readability of our apps, Ionic has introduced a new high-contrast theme and revised the default colors for new Ionic projects. The Ionic team ensured that the new default colors align with the Web Content Accessibility Guidelines. If you wish to apply these colors immediately to your existing Ionic application, you can visit the updated color generator.

@import '@ionic/angular/css/palettes/dark.class.css';

...

.ion-palette-dark {
  --ion-item-background: black;
}
Enter fullscreen mode Exit fullscreen mode

To improve the readability of our apps, Ionic has added a new high contrast theme and revisited the default colors when creating a new Ionic project. The Ionic team made sure the new default colors match the Web Content Accessibility Guidelines. If you'd like to use the colors right away in your existing Ionic application, you can visit the updated color generator website.

ionic high contrast theme

To improve the contrasts even more, Ionic added new stepper tokens that allow us developers to control text and background colors more independently.

:root {
  --ion-text-color-step-50: #f2f2f2; /* only used for text */
  --ion-background-color-step-50: #0d0d0d; /* only used for background */
}

button {
- background: var(--ion-color-step-50);
+ background: var(--ion-background-color-step-50);
}
Enter fullscreen mode Exit fullscreen mode

Dynamic Fonts

Ionic v8 now include dynamic font scaling enabled by default, replacing the --ion-default-dynamic-font variable with --ion-dynamic-font. To deactivate dynamic fonts, set the variable to --ion-dynamic-font: initial. Dynamic fonts will be enabled by default for projects created with the v8 CLI. For a more detailed explanation of dynamic fonts, I recommend reading the updated documentation.

iOS 17 Action Sheet

Ionic has always tried to keep up with recent changes added to Material Design on Android and the Human Interface Guidelines for iOS. With Ionic v8, the Ionic team updated the action sheet component to follow the latest iOS 17 and Material Design changes. Developers are now able to disable action sheet buttons if needed.

new action sheet component

Enhanced Picker Component

One feature that I missed in the previous releases is an easy-to-use, user-friendly picker component. Because I was not the only developer expressing this need, the Ionic team added the requested component in v8.

new picker component

The new component is not only simpler to use across all supported web frameworks, but it also has improved performance, which is important when the picker displays a long list of possible options. Here, you can see an example from the official Ionic blog post, showing the simple template to define the picker UI in your template.

<ion-picker>
  <ion-picker-column value="red">
    @for (option of options) {
      <ion-picker-column-option [value]="option.value">
        {{ option.text }}
      </ion-picker-column-option>
    }
  </ion-picker-column>
</ion-picker>
Enter fullscreen mode Exit fullscreen mode

Upgrading from v7 and Breaking Changes

Ionic v8 requires some changes to our existing applications. As the list of each component that has changed would be too long, I will provide a brief overview. If you wish to read through the full list of changes, I recommend you consult the upgrade guide.

  • Ionic v8 requires Angular 16+, React 17+ or Vue 3.0.6+
  • The list of supported browsers have been updated
  • The component APIs, such as inputs, items, checkboxes, etc., deprecated in Ionic v7 have been removed. The modern form control syntax introduced in v7 must now be used.

Conclusion

So, Ionic v8 is here and it's packed with new features and improvements. It'll help devs build slicker, more user-friendly mobile apps. They've finally simplified adding a dark mode and a high contrast theme to your apps. They've also thrown in dynamic fonts and leveled up the picker component, which definitely improves the user experience. Plus, they've made sure your apps are up-to-date with the latest versions of Angular, React, and Vue. Ionic continues to assist developers in building fast, native-looking apps with modern web technology standards, especially with the upcoming release of Capacitor v6. More details about this future release will be shared later this month.

ionic Article's
30 articles in total
Favicon
Parental Control Solutions: iOS VPNs for Family Safety
Favicon
Domina el arte de la personalización en Ionic: Crea paletas de colores únicas paso a paso
Favicon
Implementacion de videollamadas multiplataforma iOS - Android
Favicon
Ionic: Angular 18, CapacitorJS & SQLite
Favicon
Crafting the Face of the Web: 10 Quotes on Front-End Development
Favicon
Hello ionic
Favicon
How to Easily Notify Users About Task Progress in Angular
Favicon
Quick Guide to Installing Android SDK Platform Tools on macOS and Windows
Favicon
How to edit angular ionic app in locally? the project angular version 13 and ionic version 5?
Favicon
how to: open a component like a sheet modal using ionic 7
Favicon
Why Ionic Outperforms Flutter in 2024: 7 Data-Driven Reasons to Choose Ionic
Favicon
Besoin d'aide pour créer une application d'enquête générique
Favicon
Desktop Application Development: Why It Still Matters in a Digital World?
Favicon
Integrating Capacitor with Next.js: A Step-by-Step Guide
Favicon
Top Ionic Interview Questions and Answers
Favicon
How to Build a Vue App To Show Your GitHub Repositories
Favicon
How To Easily Expand or Collapse All Accordion Items in IonAccordionGroup at Once Without Adding Complexity
Favicon
Ionic loader, without clicking event (loading.dismiss())
Favicon
How I built a rhymes dictionary ?
Favicon
Building Native Applications with Capacitor and ReactJS
Favicon
Setting Up ESLint and Prettier in an Ionic Angular Project
Favicon
Remède V1.1.5
Favicon
Creating a Mobile App with Ionic and Vue.js 🚀📱
Favicon
Running a Phaser Game on Mobile Devices
Favicon
Working with Scenes and Data in Phaser
Favicon
Diving Into Capacitor 6: What’s New, What’s Improved, and How to Upgrade
Favicon
Announcing Ionstarter
Favicon
Ionic v8 - Create Even Better Hybrid Apps
Favicon
Ionic + Capacitor Security Tips
Favicon
Responsive Ionic app development services

Featured ones: