Device

Framework7 comes with Device detection library with which contains useful information about device and platform.

It is available as a device property of Framework7 class (Framework7.device) and same property on initialized app instance (app.device):

  1. // If we need it in place where we don't have access to app instance or before we init the app
  2. if (Framework7.device.ios) {
  3. console.log('It is iOS device');
  4. }
  5. // After we init the app we can access it as app instance property
  6. var app = new Framework7({ /*...*/ });
  7. if (app.device.android) {
  8. console.log('It is android device');
  9. }

Methods & Properties

Properties
iostrue for iOS device
androidtrue for Android device
desktoptrue for desktop browser
iphonetrue for iPhone
ipodtrue for iPod
ipadtrue for iPad
cordovatrue when app running in cordova environment
phonegapalias for cordova prop
windowstrue for desktop windows
macostrue for desktop macOs
ietrue for Internet Explorer browser
edgetrue for Edge browser
electrontrue when app is running under Electron environment
nwjstrue when app is running under NW.js environment
webViewtrue if app runs in web view - webapp installed to home screen, valid for desktop PWAs installed to desktop
standaloneSame as webView
osContains OS can be ios, android, macos, windows
osVersionContains OS version, e.g. 11.2.0
pixelRatioDevice pixel ratio
Methods
prefersColorScheme()Returns preferred user system color scheme. Returns “light” or “dark” where this feature supported or undefined otherwise. This feature support is based on (prefers-color-scheme) media query support.

Device Related Classes

Device detecting library adds additional classes on <html> element which can help you with different CSS styles for different OS and platforms.

In other words classes calculated by the following rule:

  1. device-[os]
  2. device-desktop
  3. device-macos - if desktop macOS device
  4. device-windows - if desktop windows device
  5. device-pixel-ratio-[pixel ratio]
  6. device-cordova - if app running under cordova

← Utils

Support →