Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MUI BottomNavigation is not sticky by default

Tags:

How to make BottomNavigation component sticky? Why it's not sticky by default?

like image 265
Kris MP Avatar asked Mar 07 '18 07:03

Kris MP


People also ask

Is there navbar in material UI?

The navigation bar is one of the most vital aspects of building an app. It tells users about the information and actions relating to the current screen. It is very easy to create a navigation bar in React using Material UI as there's already a component made for these and this component is called "App bar".

What is Toolbar MUI?

The Toolbar is a flex container, allowing flex item properites to be used to lay out the children. classes. object. Override or extend the styles applied to the component.


1 Answers

You can make BottomNavigation stick to the bottom of your screen with the following CSS:

const styles = {   stickToBottom: {     width: '100%',     position: 'fixed',     bottom: 0,   }, }; 

And then applying it to your BottomNavigation component:

<BottomNavigation className={classes.stickToBottom}> 

You should be aware that the position: 'fixed' will cause the the bottom navigation component to cover up your content (similarly, the AppBar stickied to the top of your screen also covers up content if you do not use a margin). You'll need to provide a marginBottom or some other kind of padding to ensure none of your content is hidden.

You can also play around with some of the other position options, such as sticky or absolute. However, in my experience, fixed is the option that most closely suits your needs.

like image 60
Jules Dupont Avatar answered Nov 02 '22 23:11

Jules Dupont