Closed aeon3k closed 7 years ago
I saw someone had a similar problem on Stack Overflow with paper-tab
. This is most likely what you're seeing because my bottom-tab
is derived from paper-tab
.
As they mention on SO, you should be able to have the for
attribute point to nothing and then adjust the positioning for paper-badge
with some CSS.
I'm having some trouble getting JS Bin to work but here's the code I used locally.
<style is="custom-style" include="demo-pages-shared-styles">
bottom-nav {
background-color: var(--primary-color);
color: #fff;
}
paper-badge {
--paper-badge-margin-left: 3em;
--paper-badge-margin-bottom: 3.5em;
}
</style>
</head>
<body>
<bottom-nav fixed>
<bottom-toolbar selected="0">
<bottom-tab show-label label="Movies & TV" icon="notification:ondemand-video"></bottom-tab>
<bottom-tab show-label label="Music" icon="image:music-note"></bottom-tab>
<bottom-tab show-label label="Books" icon="icons:book"></bottom-tab>
<!-- uses the label + icon attributes on bottom-tab -->
<bottom-tab show-label label="Stuff" icon="favorite">
<paper-badge for="_" label="3"></paper-badge>
</bottom-tab>
</bottom-toolbar>
</bottom-nav>
<sample-content size="10"></sample-content>
</body>
Does this work for what you're seeing?
it does work well with show-label, thanks. Without show-label, it's not as pretty. When you select the tab, the label pushes the icon upward but the badge stays at the same place.
OK, with CSS I thought bottom-tab.iron-selected paper-badge
would be an easy way to style the badge based on whether the tab was selected. I'm not really sure why but that doesn't seem to work.
Since using a badge in the nav seems like a common use case, I could add a badge
feature to bottom-tab
. That could be a span with some text that looks similar to paper-badge
. Does that sound like a good approach?
Does this work better for styling paper-badge
?
bottom-tab.iron-selected paper-badge {
padding-bottom: 2.4em;
margin-left: 2em;
}
bottom-tab:not(.iron-selected) paper-badge {
padding-bottom: 1.8em;
margin-left: 1.8em;
}
Thank you. I ll try that on tuesday at work but it looks better than what I came up with ! ;)
Hey, I'm assuming the CSS snippet worked well enough. I'm going to close the issue but feel free to re-open it if you need more help.
Hi,
thanks for your component. I tried to integrate it with paper-badge, and doesnt work.
The badge shows almost outside the tab
So I tried the following:
It works save the label, when clicked, is on top of the icon... Any idea how to fix it ?