Material-UI: Adding Badge to a Tab in material-ui Tabbar (Tabs) - reactjs

I have Material-UI Tabs component with 5 Tab components as children. I would like to display a Badge on the Tab. Badge would display unread items under each tab.
I have two versions of tab bar. One for desktop with icon and text and one for mobile containing just icon. How could I position Badge so that it places properly on both versions. Also Badge should be visible even if tab is not selected (if I set Badge as a child to a Tab it will be hidden when tab is not selected).

You can do it like this:
<Tab label={<Badge badgeContent={this.state.messageCount} color="primary">
Messages
</Badge>} value="/messages" />

Related

How can I make navbar hide further/disappear when keyboard is opened?

I would like to completely hide the react navigation bottom tab navbar when my keyboard appears.
I've already added tabBarHideOnKeyboard: true to my Tab.Navigator, but the issue is that a one of the tabs sticks out when the navbar hides.

how to highlight active nav menu when scrolled in reactjs?

how will I show all the nav menus if they don't have any space to show?
I want to make my navbar like site have https://restoranserisentosapj.weeat.asia/cust/#/goods
what I make is https://srbistro.netlify.app/ (please check in the phone or phone view)

scroll to top when tapping on the active tab in react native

I know there is a hook for that https://reactnavigation.org/docs/use-scroll-to-top/ . But at the beginning of my project, i created my own bottom tab component instead of using createBottomTabNavigator(). So i have a code like that <BottomNavigator selected={'Explore'} /> at the bottom of five screen. I want to scroll to top when active tab tapped. I can understand that if active tab is tapped but i get that information in BottomNavigator component. So i have no idea how to retrieve that information back to current screen and scroll to top.

Codename One toolbar sidemenu issue

I created a list using table layout which contains checkbox and message.The list is scroll-able . When i scroll down everything works fine,Where as when i check the check box and scroll down the toolbar side menu is expanding.
My requirement is to open the toolbar sidemenu only on the sidemenu toogle button click other than any click on the screen side menu should be in close mode.

What is AppBar vs ToolBar?

All the material-ui examples show Toolbar inside Appbar. Why not just Appbar? What's the difference between the two?
https://material.io/design/components/ does not have Toolbar component, only "App bars: top".
https://material.io/develop/web/components/toolbar/ says "The existing MDCToolbar component and styles will be removed in a future release"
So will material-ui Toolbar go away eventually?
I was looking at the default CSS properties produced by each component. The main purpose of Toolbar is to display its children with an inline display (elements are placed next to each other), something Appbar doesn't do. The AppBar component uses display: flex and flex-direction: column, that means direct descendants are stacked on top of each other. On the other hand Toolbar uses display: flex too, but doesn't set flex-direction, which means it uses its default value: row. That being said, the Button component uses display: inline-block. That is the reason why elements are placed next to each other inside Toolbar components.
Let say, for example, we have an Appbar with a Toolbar with two Buttons as children:
<AppBar>
<Toolbar>
<Button variant="outlined" color="inherit" >
Button 1
</Button>
<Button variant="outlined" color="inherit">
Button 2
</Button>
</Toolbar>
</AppBar>
The result of this code is:
But, if we remove the Toolbar and place the Buttons directly under the AppBar component:
<AppBar>
<Button variant="outlined" color="inherit" >
Button 1
</Button>
<Button variant="outlined" color="inherit">
Button 2
</Button>
</AppBar>
the result will be very different as shown below, because now the buttons are direct descendants of the AppBar component and so, they will be stacked on top of each other.
As you see, AppBar and Toolbar have different purposes. Thats why I think Toolbar will never go away.
The AppBar is used to structure your document. You put in content what you would normally place inside a tag e.g the title of your page and navigation links. If you examine your page by pressing F12 you will notice the AppBar created a <header> tag.
-> So the AppBar is used to give your page a place to put in introductional and navigational content
You can visualize the Toolbar as a real life tool belt. In the virtual world instead of tools we place icons and buttons on it. You can also add your brand name inside the tool bar just like manufacturers do that on their belts.
-> The toolbar is a wrapper where you can place elements in a horizontal line.
AppBar can be used without a Toolbar and a Toolbar doesn't have to be placed inside a AppBar. If you want your header to look like a toolbar it makes sense to do <AppBar><Toolbar>...</Toolbar></AppBar>. If you want a bar at the center of the page just to show off icons a Toolbar without a AppBar would make sense.

Resources