2
votes

I'm making an material design app with the new Monaca Onsen 2.0, I used ons-toolbar and works fine, but I can't understand how to use ons-tabbar with material, some trick?

<ons-toolbar modifier="material"> WORKS FINE </ons-toolbar>

<ons-tabbar modifier="material"> NOT WORKING WITH MATERIAL </ons-tabbar>
2
I have only seen the material tabbar used with radio buttons such as in the css reference below, but I am not sure how to get it as smoothly as the 1.x tabbar. onsen.io/2/reference/css.html - John Gonzalez
You should probably rephrase your question. I am curious to understand how to get the material modifier to show up. Other material components work but for some reason this tabbar won't - John Gonzalez

2 Answers

0
votes

Your code is wrong because ons-tabbar should always contain at least one ons-tab.

Take a look at this CodePen example, everything is working fine.

Here is the code:

<ons-tabbar modifier="material">
  <ons-tab page="comments.html" label="Comments" icon="ion-chatbox-working"></ons-tab>
  <ons-tab page="tags.html" label="Tags" icon="ion-ios-pricetag"></ons-tab>
  <ons-tab page="settings.html" label="Settings" icon="ion-ios-cog"></ons-tab>
</ons-tabbar>

<ons-template id="home.html">
  <ons-toolbar>
    <div class="center">Home</div>
  </ons-toolbar>

  <p style="padding-top: 100px; color: #999; text-align: center">Page Contents</p>
</ons-template>

<ons-template id="comments.html">
  <ons-toolbar>
    <div class="center">Comments</div>
  </ons-toolbar>

  <p style="padding-top: 100px; color: #999; text-align: center">Page Contents</p>
</ons-template>

<ons-template id="tags.html">
  <ons-toolbar>
    <div class="center">Tags</div>
  </ons-toolbar>

  <p style="padding-top: 100px; color: #999; text-align: center">Page Contents</p>
</ons-template>

<ons-template id="feed.html">
  <ons-toolbar>
    <div class="center">Feed</div>
  </ons-toolbar>

  <p style="padding-top: 100px; color: #999; text-align: center">Page Contents</p>
</ons-template>

<ons-template id="settings.html">
  <ons-toolbar>
    <div class="center">Settings</div>
  </ons-toolbar>

  <p style="padding-top: 100px; color: #999; text-align: center">Page Contents</p>
</ons-template>
0
votes

Check your onsenui.js
I actually think it is possible that the project page on Monaca may not have been updated to the latest onsen ui 2.0. That appeared to be the case for me. It may say in the first line:

/*! onsenui v2.0.0-beta - 2015-11-11 */

You probably need an updated one like the one Andi Pavllo used

/*! onsenui v2.0.0-beta.2 - 2015-12-01 */

However the latest Onsen UI 2.0 on Github is actually

/*! onsenui v2.0.0-beta.5 - 2016-01-08 */

And you cannot just swap out the js you would need to install the whole package.

*Edit: I noticed after I installed the new package everything was working properly but when I tried the theme roller, it reverted back to the old tab bar. So its likely that the theme roller may not be updated.