Theme-Based Rendering - 图1

Theme Based Rendering

When we develop Framework7 app for multiple platforms with mutliple themes (ios, md, aurora) we need to control which elements will appear for one or another theme, like showing different icon for iOS and MD themes.

There are special classes that allow to control this:

  • if-ios - element will be rendered only for iOS theme
  • if-not-ios - element will be removed/hidden for theme other than iOS
  • if-md - element will be rendered only for MD theme
  • if-not-md - element will be removed/hidden for theme other than MD
  • if-aurora - element will be rendered only for Aurora theme
  • if-not-aurora - element will be removed/hidden for theme other than Aurora

This is, for example how we hide Navbar’s back button text for MD theme:

  1. <div class="navbar">
  2. <div class="navbar-inner sliding">
  3. <div class="left">
  4. <a href="#" class="link back">
  5. <i class="icon icon-back"></i>
  6. <!-- back button text will be visible only in iOS and Aurora themes -->
  7. <span class="if-not-md">Back</span>
  8. </a>
  9. </div>
  10. ...
  11. </div>
  12. </div>