Hôm nay, mình rất vui mừng được thông báo về Ionic Framework 5! ? Bản phát hành này bao gồm các bản cập nhật cho thiết kế iOS 13, một API hoàn toàn mới để tạo các animation tùy chỉnh của riêng bạn, các Ionicon được cải tiến, màu Ionic được cập nhật, thiết kế khởi động mới, cải tiến tùy chỉnh thành phần, và nhiều hơn thế nữa!

Tất cả những thay đổi này đều được thực hiện trong phần lõi của Ionic Framework, cũng áp dụng cho việc tích hợp vào Angular, React và Vue (beta). Và nếu bạn chưa nghe về điều đó, Ionic đã khởi chạy hỗ trợ React chính thức vào tháng 10 vừa qua!

Để tham dự buổi hướng dẫn trực tiếp sắp tới của về Ionic 5, do nhóm Ionic tổ chức. Bạn có thể Đăng ký tại đây

Nâng cấp dễ dàng ⛵️

Bạn có thể sẽ lo lắng về quá trình nâng cấp do đây là bản phát hành phiên bản chính, nhưng đừng lo! Khi Ionic đã “cải tiến” tuân thủ theo quy ước Semantic Versioning. Ionic cam kết xuất bản một phiên bản chính thức khi mà có bất kỳ sự thay đổi nào từ phía API đã được giới thiệu trước đây. Trong trường hợp version 5 này, mình nghĩ phiên bản chính đã thông báo rằng những API đã được Ionic công khai thì mới được cập nhật. Và vì Ionic đang sử dụng Web Components nên các API thay đổi sẽ được xử lý một cách riêng biệt giữa các thành phần UI của Ionic và JavaScript framework.

Tóm cái váy lại là đối với những người đang dùng phiên bản 4 rồi thì việc nâng cấp lần này tương đối dễ. Bây giờ chúng ta hãy đi sau vào chi tiết cụ thể nhé.

Thiết kế trên iOS ?

Thay đổi lớn nhất trong bản phát hành lần này là Ionic đã nâng cấp thiết kế cực lớn trên các UI components của họ. Apple gần đây đã phát hành iOS 13, cập nhật thiết kế của nhiều thành phần và như thế kéo theo việc cập nhật của Ionic Framework. Hãy cùng xem một số thay đổi mà Ionic đã thực hiện được để phù hợp với iOS gốc nhé!

Những thay đổi của bản 5


The iOS Segment design changed drastically from the previous iOS version. Prior to iOS 13, borders and a filled background were used to differentiate between checked and unchecked buttons. With the latest design update, a single indicator is now used to slide between the buttons, checking the one it ends on. This update includes a gesture that can be used to drag the indicator. Below is a comparison between Ionic 4 and Ionic 5.

Segment in Ionic 4: Dark ModeSegment in Ionic 5: Dark Mode

Due to the nature of this update, there were some breaking changes introduced. Other than any updates related to the breaking changes, no changes need to be made to use the new Segment design. See the Segment documentation for usage information.


iOS introduced the idea of a collapsible header and different sized titles in previous versions. In order to support this, we’ve introduced some properties that can easily be added to the header & title components to get shrinking large titles, small titles, and collapsible buttons.

Large Title

The large title in iOS collapses into a standard-sized title when the content scrolls beyond a certain point. It can also be used without any collapsing if desired.

Large Title: Light ModeLarge Title: Dark Mode

In order to achieve this, the header needs to be added twice: a header with a standard title above the content, and a collapsible header with a large title inside of the content. In addition to being able to collapse the header, Buttons and a Searchbar inside of the collapsible header can also collapse. See the documentation on Collapsible Large Titles for usage information.

Small Title

The small title, also known as a header note, is generally used inside of a toolbar above another toolbar that contains a standard-sized title. In native apps, it is most often used in combination with Swipe to Close Modals. See the videos in the section below for a visual representation of the small title.

See the Title documentation for usage information.

Swipe to Close Modal

The Swipe to Close Modal is something often seen in iOS now. Instead of displaying a modal that covers the entire screen and requires the user to tap a button to close it, it will display a modal that is inset with the page behind it pushed back. This update also includes a gesture to drag the modal down to close it.

Swipeable Modal: Light ModeSwipeable Modal: Dark Mode

In order to enable a swipe to close modal, swipeToClose and presentingElement need to be passed upon modal creation. See the documentation on Swipeable Modals for more information.

Menu Overlay Type

In prior versions of iOS, the side menu used a "reveal" type menu which pushed the main content over to reveal the menu. The new iOS design features a menu that will overlay the content with an updated animation.

Overlay Menu: Light ModeOverlay Menu: Dark Mode

No changes need to be made to take advantage of this new menu design. However, if you prefer the old way the menu type can be set back to "reveal".


The Refresher pulling icon in iOS has been updated in native applications to be above a header with a large title. In addition to that, as you pull down on the content the spinner tick marks will gradually be displayed until the content is pulled down enough to where all ticks are seen and then it will begin to rotate. While updating the iOS refresher, we were able to use the same logic to completely redesign the Material Design refresher as well.

Refresher: Light ModeRefresher: Dark Mode

Other than moving the placement of the refresher, no changes are needed to use the new pull to refresh. See the Refresher documentation for usage information.

List Header

The lists in iOS have had many design changes. Most notably the List Header now takes on a more large and bold design. In previous versions, the List Header was uppercase and small and didn’t have the option for a bottom border. With the addition of the lines property on a List Header, it is now possible to add a border while matching the latest design.

Ionic List Header: Light ModeIonic List Header: Dark Mode
list header light modelist header light mode

Due to structural changes to support adding lines, it is recommended all text content inside of a List Header be wrapped in an <ion-label>. Additional information on this can be found in breaking changes.

Other than adding the label and lines if desired, no changes need to be made to enable the new design. See the List Header documentation for usage information. If the old design is desired, use custom CSS to achieve the previous look.

Ionic Animations ?

Ionic 5 introduces our brand new open source animations utility, Ionic Animations, that provides the tools developers need to build highly performant animations regardless of the framework they are using. Read more on the Ionic Animations blog.

Ionicons ❤️

Ionic 5 ships with the latest version of our free and open source icon library, Ionicons 5, which includes an all-new icon set!

ionicons 5 variations gif

There will immediately be some differences noticed with this upgrade:

  • One set of icons for both modes
  • Icons come in three new variants: outline, fill (default), and sharp
  • Icons will no longer switch between two different icons based on the mode
  • The ability to set them per mode will still work, but the icon for each needs to be set using the ios and md properties
  • There are still a handful of icons within Ionic that will automatically switch, such as the icon used in menu button, back button and the detail icon on items
  • The icon font has been removed from Ionicons, but it does still contain an svg sprite if loading all icons on the same page is needed

For a list of all of the icons that were removed or renamed, see the Ionicons changelog document. To search through all of the newly added icons, check out the Ionicons site. Read more on our Ionicons 5 Announcement blog.

Ionic Colors ?

Ionic has been updated with all new colors by default! If your app was not created using one of our starters and you don’t override these colors, you’ll automatically get the new colors in your app. If your app was created using an Angular or React starter, the colors are defined in the theme/variables.scss file and will need to be updated manually.

In addition to the new default colors, we’ve also provided a set of recommended colors to use with dark mode. Head over to the Dark Mode documentation for a guide detailing how to support dark mode based on user preference, including our recommended theme with code to copy & paste!

Ionic 5 Colors: Light ModeIonic 5 Colors: Dark Mode
list header light modelist header light mode

Redesigned Starters ?

With all of the changes to the design of our components, we felt it was time to update the design of our existing starters and add a new one! Take a look at the new designs and the new list starter below.

Blank Starter: Light ModeBlank Starter: Dark Mode
blank starter light modeblank starter dark mode
Menu Starter: Light ModeMenu Starter: Dark Mode
menu starter light modemenu starter dark mode
Tabs Starter: Light ModeTabs Starter: Dark Mode
tabs starter light modetabs starter dark mode
List Starter: Light ModeList Starter: Dark Mode
list starter light modelist starter dark mode

Easier Customization ?

We’ve heard you loud and clear that components are not easy to customize. One reason for this was a lack of available CSS Variables or way to style inner elements. The other reason was due to components being scoped and their Ionic styles taking priority over custom styles. In order to make it easier to style, we’ve added more CSS variables, converted some scoped components to Shadow DOM, and began adding support for Shadow Parts.

The following components were converted to Shadow DOM:

  • Back Button
  • Card
  • Segment
  • Split Pane

Why shadow DOM? One of our biggest reasons for using Shadow DOM is its ability to completely encapsulate styles and prevent them from bleeding into other components. This means we’re able to style specific elements inside of our components without affecting other components that use that element.

In addition to that, Shadow DOM allows us to use CSS custom properties (variables) within the component for easier theming. In previous versions of Ionic Framework, Sass variables were used to customize and theme an app. This requirement not only caused longer build times, but in order to have multiple themes within the same app it required generating multiple CSS files with different Sass variables. CSS variables can be updated at runtime, so an app can change the entire theme based on a CSS class or a prefers-color-scheme media query.

While scoped components allow the use of CSS variables, the selectors that are added to the component make user overrides more difficult, requiring a user to either write an overly complex selector or make use of !important in the CSS styles in order to override the Ionic components. Additionally, if users were to target an inner element of an Ionic component and we were to change the structure or class, this would break the styling of that element.

With the growing support for Shadow Parts in browsers, users will be able to target specific elements inside of our components to override their styles directly.

Learn more about customizing Ionic themes, enabling dark mode, and CSS variables in our docs!

Angular Ivy ?️

For Ionic Angular developers, Ionic 5 will bring full support for Ivy, Angular’s new renderer. Ivy enables apps to only require pieces of the renderer that they actually need, instead of the whole thing. This means that our final output will be smaller, which is better for load performance. Read more about Angular Ivy on our blog post.

Breaking Changes ?

In the past, a major release of Ionic sometimes caused many breaking changes to the end-user due to internal changes to update the framework it was built on. Our last major release, Ionic 4, was created to avoid this by building Ionic Framework with web components. This has allowed us to only make breaking changes where necessary to improve the framework. A list of all of the breaking changes for this release can be found in our breaking changes document in the ionic repository.

Quá trình cập nhật ✅

Bạn nên cập nhật lên bản Ionic 4 mới nhất (4.11.10) để xem có còn cảnh báo nào dành riêng cho ứng dụng của bạn trong mục developer console hay không. Sau khi sửa xong tất cả các cảnh báo, bạn hãy chạy các lệnh sau:

# for an angular app
npm i @ionic/angular@latest --save

# for a react app
npm i @ionic/react@latest --save
npm i @ionic/react-router@latest --save
npm i ionicons@latest --save

# for a stencil / vanilla JS app
npm i @ionic/core@latest --save

Sau đó, hãy đọc lại tài liệu này để xem liệu còn bất kỳ thay đổi nào khác nữa cần được thực hiện trong ứng dụng của bạn hay không.

Lời kết ?‍♀️

Đội ngũ phát triển Ionic muốn gửi lời cảm ơn chân thành tới các bạn đã và đang sử dụng Ionic Framework. Họ mong muốn nhận được nhiều ý kiến hơn nữa từ phía các bạn để có thể xây dựng lên một cộng đồng Ionic vững mạnh.

Chúc các bạn thành công!


Vui lòng nhập bình luận của bạn
Vui lòng nhập tên của bạn ở đây

Website này sử dụng Akismet để hạn chế spam. Tìm hiểu bình luận của bạn được duyệt như thế nào.