OnsenUI
Mobile app development framework and SDK using HTML5 and JavaScript. Create beautiful and performant cross-platform mobile apps. Based on Web Components, and provides bindings for Angular 1, 2, React and Vue.js.
Top Related Projects
Full featured HTML framework for building iOS & Android apps
A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
Quasar Framework - Build high-performance VueJS user interfaces in record time
⚡ Empowering JavaScript with native platform APIs. ✨ Best of all worlds (TypeScript, Swift, Objective C, Kotlin, Java, Dart). Use what you love ❤️ Angular, Capacitor, Ionic, React, Solid, Svelte, Vue with: iOS (UIKit, SwiftUI), Android (View, Jetpack Compose), Dart (Flutter) and you name it compatible.
access core functions on Android, iPhone and Blackberry using JavaScript
Quick Overview
Onsen UI is a popular open-source UI framework and components for HTML5 hybrid mobile app development. It provides a rich set of UI components and responsive layout for building cross-platform mobile applications using web technologies like HTML, CSS, and JavaScript.
Pros
- Cross-platform compatibility (iOS and Android)
- Rich set of UI components with native look and feel
- Integrates well with popular frameworks like Angular, React, and Vue.js
- Active community and regular updates
Cons
- Learning curve for developers new to hybrid mobile development
- Performance may not match native apps for complex applications
- Limited customization options for some components
- Dependency on Cordova/PhoneGap for certain native features
Code Examples
- Creating a simple page with a toolbar:
<ons-page>
<ons-toolbar>
<div class="center">My App</div>
</ons-toolbar>
<p>This is the content of the page.</p>
</ons-page>
- Adding a button with an event listener:
<ons-button id="myButton">Click me!</ons-button>
<script>
document.getElementById('myButton').addEventListener('click', () => {
ons.notification.alert('Button clicked!');
});
</script>
- Creating a tabbar navigation:
<ons-tabbar>
<ons-tab page="home.html" label="Home" icon="ion-home" active></ons-tab>
<ons-tab page="settings.html" label="Settings" icon="ion-gear-a"></ons-tab>
</ons-tabbar>
Getting Started
To get started with Onsen UI, follow these steps:
- Include Onsen UI in your project:
<link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsenui.css">
<link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsen-css-components.min.css">
<script src="https://unpkg.com/onsenui/js/onsenui.min.js"></script>
- Create a basic page structure:
<!DOCTYPE html>
<html>
<head>
<title>My Onsen UI App</title>
<!-- Include Onsen UI files here -->
</head>
<body>
<ons-page>
<ons-toolbar>
<div class="center">My App</div>
</ons-toolbar>
<p>Hello, Onsen UI!</p>
</ons-page>
</body>
</html>
- Start building your app by adding more components and functionality as needed.
Competitor Comparisons
Full featured HTML framework for building iOS & Android apps
Pros of Framework7
- More comprehensive ecosystem with additional tools and plugins
- Better documentation and extensive examples
- Larger community and more frequent updates
Cons of Framework7
- Steeper learning curve due to its extensive feature set
- Larger file size, which may impact performance on slower devices
- Less flexibility for custom designs outside of its Material and iOS themes
Code Comparison
OnsenUI:
ons.ready(function() {
ons.createElement('ons-button', { innerHTML: 'Click Me' })
.appendTo(document.body);
});
Framework7:
var app = new Framework7({
el: '#app',
routes: [
{ path: '/', component: HomePage },
]
});
Both frameworks offer component-based architecture, but Framework7 provides a more structured approach with routing built-in. OnsenUI focuses on simplicity and ease of use, while Framework7 offers a more comprehensive solution for building mobile apps.
Framework7 excels in providing a complete ecosystem and detailed documentation, making it suitable for larger projects. OnsenUI, on the other hand, is more lightweight and easier to integrate into existing projects, making it a good choice for simpler applications or when you need more control over the design.
A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
Pros of Ionic Framework
- Larger community and ecosystem, with more resources and third-party plugins
- Better integration with Angular and official support for React and Vue
- More comprehensive UI components and native-like animations
Cons of Ionic Framework
- Steeper learning curve, especially for beginners
- Larger bundle size, which may impact performance on low-end devices
- More opinionated framework, potentially limiting flexibility in some cases
Code Comparison
Onsen UI (Vue.js):
<template>
<v-ons-page>
<v-ons-toolbar>
<div class="center">Onsen UI</div>
</v-ons-toolbar>
<v-ons-button>Click me!</v-ons-button>
</v-ons-page>
</template>
Ionic Framework (Vue.js):
<template>
<ion-page>
<ion-header>
<ion-toolbar>
<ion-title>Ionic Framework</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-button>Click me!</ion-button>
</ion-content>
</ion-page>
</template>
Both frameworks offer similar component-based structures, but Ionic's syntax is more aligned with web standards. Onsen UI's approach is more concise, while Ionic provides a more detailed and structured layout.
Quasar Framework - Build high-performance VueJS user interfaces in record time
Pros of Quasar
- More comprehensive ecosystem with CLI, desktop app support, and SSR
- Larger community and more frequent updates
- Better integration with Vue.js and its ecosystem
Cons of Quasar
- Steeper learning curve due to more features and options
- Potentially heavier bundle size for simpler applications
- Less focus on native-like mobile UI compared to Onsen UI
Code Comparison
Onsen UI component example:
<template>
<v-ons-page>
<v-ons-toolbar>
<div class="center">Onsen UI</div>
</v-ons-toolbar>
<v-ons-button>Click me!</v-ons-button>
</v-ons-page>
</template>
Quasar component example:
<template>
<q-page>
<q-header>
<q-toolbar>
<q-toolbar-title>Quasar</q-toolbar-title>
</q-toolbar>
</q-header>
<q-btn color="primary" label="Click me!" />
</q-page>
</template>
Both frameworks offer component-based development for mobile and web applications. Onsen UI focuses more on creating native-like mobile UIs, while Quasar provides a broader set of tools and components for various platforms. Quasar's integration with Vue.js is tighter, making it a popular choice for Vue developers. However, Onsen UI's simplicity and mobile-first approach can be advantageous for certain projects.
⚡ Empowering JavaScript with native platform APIs. ✨ Best of all worlds (TypeScript, Swift, Objective C, Kotlin, Java, Dart). Use what you love ❤️ Angular, Capacitor, Ionic, React, Solid, Svelte, Vue with: iOS (UIKit, SwiftUI), Android (View, Jetpack Compose), Dart (Flutter) and you name it compatible.
Pros of NativeScript
- True native performance with direct access to native APIs
- Supports both Angular and Vue.js frameworks
- Allows sharing code between web and mobile applications
Cons of NativeScript
- Steeper learning curve, especially for developers new to mobile development
- Smaller community and ecosystem compared to OnsenUI
- More complex setup and configuration process
Code Comparison
OnsenUI (JavaScript):
ons.ready(function() {
var menu = document.getElementById('menu');
menu.open();
});
NativeScript (TypeScript):
import { Application } from "@nativescript/core";
Application.run({ moduleName: "app-root" });
OnsenUI focuses on creating hybrid mobile apps using web technologies, while NativeScript builds truly native apps using JavaScript or TypeScript. OnsenUI offers a simpler approach with a gentler learning curve, making it ideal for web developers transitioning to mobile development. NativeScript provides better performance and access to native APIs but requires more in-depth knowledge of mobile development concepts.
OnsenUI's code is more HTML and CSS-centric, while NativeScript uses a more programmatic approach. OnsenUI is better suited for rapid prototyping and simpler apps, whereas NativeScript excels in creating complex, high-performance native applications.
access core functions on Android, iPhone and Blackberry using JavaScript
Pros of PhoneGap
- Broader platform support, including iOS, Android, Windows, and more
- Extensive plugin ecosystem for accessing native device features
- Mature and well-established framework with a large community
Cons of PhoneGap
- Performance can be slower compared to native apps
- UI may not feel as native or smooth as platform-specific designs
- Steeper learning curve for developers new to web technologies
Code Comparison
OnsenUI example:
ons.ready(function() {
var app = new Vue({
el: '#app',
template: '<ons-page>Hello World!</ons-page>'
});
});
PhoneGap example:
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
// PhoneGap is now ready
console.log('Running cordova-' + cordova.platformId + '@' + cordova.version);
}
OnsenUI focuses on UI components and is more Vue.js friendly, while PhoneGap provides a wrapper for accessing native device features and requires event listeners for device readiness.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Onsen UI - Cross-Platform Hybrid App and PWA Framework
Onsen UI is an open source framework that makes it easy to create native-feeling Progressive Web Apps (PWAs) and hybrid apps.
The core library is written in pure Javascript (on top of Web Components) and is framework agnostic, which means you can use it with your favorite framework and its tools. We provide some extra binding packages to make it easy to use Onsen UI's API with many popular frameworks:
React |
Angular 2+ |
Vue |
AngularJS 1.x |
Some other frameworks are supported by community packages (not tested or implemented by the core team): Aurelia, EmberJS.
Both flat (iOS) and Material (Android) designs are included. The components are optionally auto-styled based on the platform, which makes it possible to support both iOS and Android with the same source code.
Getting started
We have several resources to help you get started creating hybrid apps and PWAs with Onsen UI:
- The official docs: We provide guides and references for all of the components and bindings, as well as how to publish your app. These are our Getting Started guides:
- Components overview: a list of included CSS components in both flat and Material Design. Note that these components are just pure and performant CSS without JavaScript behavior. Some extra details (such as dragging or ripple effect) are added by Onsen UI custom elements.
- Playground: an interactive Onsen UI tutorial where you can learn how to use Onsen UI and play around with the components.
- Blog: there are lots of great tutorials and guides published in our official Onsen UI blog and we are adding new content regularly.
- Support: if you are having trouble using some component the best place to get help is the Onsen UI Forum or the community-run Discord Chat. We are also available to answer short questions on Twitter at @Onsen_UI.
Get Onsen UI
Download the latest released version
We have a distribution repository with changelog. Onsen UI is also available in npm and jspm. Example:
npm install onsenui
This downloads the core Onsen UI library. To install bindings, you can install react-onsenui
, vue-onsenui
, ngx-onsenui
or angularjs-onsenui
.
Download or request from a CDN
You can also take the necessary files from a CDN. Some of the options are unpkg, jsDelivr and cdnjs.
Get the latest development build
Optionally, you can download the latest development build here. Be careful, usually everything there is already tested but it might be unstable sometimes.
Examples with source code
There are lots of sample applications written using Onsen UI. Here are some examples with source code and tutorials to give you an idea of what kind of apps you can create.
Onsen UI ecosystem
Because sometimes a UI framework may not be enough to make hybrid app development easy, Onsen UI comes with a complete ecosystem of well integrated tools. Meet Monaca.
Developed by the Onsen UI team, Monaca is a toolkit that makes hybrid mobile app development with PhoneGap / Cordova simple and easy: Onsen UI Cordova templates, debugging suite, push notifications, remote build, back-end solutions, encryption, version control, continuous integration and more. Furthermore, it provides multiple development environments with everything already configured and ready to go:
Cloud IDE - Command Line Interface - Localkit GUI
Example with CLI:
$ [sudo] npm -g install monaca
$ monaca create helloworld # And choose the starter template
$ monaca preview # Preview on the browser
$ monaca debug # Preview on a real device
$ monaca remote build --browser # Production build on the cloud
See the Onsen UI Getting Started Page for more information.
Browser Support
Onsen UI is tested to work with the following browsers and mobile OS.
- Android 4.4.4+
- iOS 9+
- Chrome
- Safari
Contribution
We welcome your contribution, no matter how big or small! Please have a look at the contribution guide for details about project structure, development environment, test suite, code style, etc. All the version updates are mentioned in the changelog.
Top Related Projects
Full featured HTML framework for building iOS & Android apps
A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
Quasar Framework - Build high-performance VueJS user interfaces in record time
⚡ Empowering JavaScript with native platform APIs. ✨ Best of all worlds (TypeScript, Swift, Objective C, Kotlin, Java, Dart). Use what you love ❤️ Angular, Capacitor, Ionic, React, Solid, Svelte, Vue with: iOS (UIKit, SwiftUI), Android (View, Jetpack Compose), Dart (Flutter) and you name it compatible.
access core functions on Android, iPhone and Blackberry using JavaScript
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot