How to make BottomNavigation
component sticky? Why it's not sticky by default?
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".
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With