@material-ui/core#BottomNavigation JavaScript Examples
The following examples show how to use
@material-ui/core#BottomNavigation.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: layout.js From dscbppimt-official-website with MIT License | 6 votes |
Layout = (props) => {
const classes = useStyles()
const router = useRouter()
return(
<Box>
<Box style={{minHeight : '100vh', display : 'flex', flexDirection : 'column'}}>
<Navbar />
<div style={{flex : '1'}}>
{props.children}
</div>
<Box className={styles.bottomNav}>
<BottomNavigation position="sticky" showLabels component="nav" className={classes.bottomNavigation}>
<BottomNavigationAction component='div' label="About" icon={<InfoIcon />} onClick={() => router.push('/about')}/>
<BottomNavigationAction component='div' label="Events" icon={<BookIcon />} onClick={() => router.push('/events')}/>
<BottomNavigationAction component='div' label="Home" icon={<HomeIcon />} onClick={() => router.push('/')}/>
<BottomNavigationAction component='div' label="Blogs" icon={<BookIcon />} onClick={() => router.push('/blogs')}/>
<BottomNavigationAction component='div' label="Contact" icon={<ContactsIcon />} onClick={() => router.push('/contact')}/>
</BottomNavigation>
</Box>
<Footer />
</Box>
</Box>)
}
Example #2
Source File: Navigation.js From pwa with MIT License | 6 votes |
export default function Navigation() {
const location = useLocation();
// https://{domain-name}:{port}/{pathname}
// location.pathname returns pathname in url
return (
<BottomNavigation value={location.pathname}>
{routes.map((route) => (
<BottomNavigationAction
key={route.to}
value={route.to}
component={Link}
{...route}
/>
))}
</BottomNavigation>
);
}
Example #3
Source File: index.js From Recess with MIT License | 5 votes |
function BottomNavBar({ user }) {
const classes = useStyles();
const history = useHistory();
const [value, setValue] = useState("home");
const handleChange = (e, newValue) => {
history.push(`/${newValue}`);
setValue(newValue);
};
useEffect(() => {
setValue(window.location.pathname.substring(1));
return history.listen(() => {
setValue(window.location.pathname.substring(1));
});
}, []);
return (
<Hidden smUp>
<div className={classes.footer}>
<ThemeProvider theme={createMuiTheme(darkTheme)}>
<BottomNavigation
value={value}
onChange={handleChange}
className={classes.root}
>
<BottomNavigationAction
label="Home"
value="home"
icon={<HomeRounded />}
/>
{user?.displayName && (
<BottomNavigationAction
label="Upload"
value="upload"
icon={<AddCircleRounded />}
/>
)}
<BottomNavigationAction
label="Explore"
value="explore"
icon={<ExploreRounded />}
/>
</BottomNavigation>
</ThemeProvider>
</div>
</Hidden>
);
}
Example #4
Source File: Footer.js From hk-independent-bus-eta with GNU General Public License v3.0 | 5 votes |
Footer = () => {
const { t, i18n } = useTranslation()
const location = useLocation()
const { selectedRoute } = useContext ( AppContext )
const classes = useStyles()
const history = useHistory()
const handleClick = (link) => {
vibrate(1)
setTimeout(() => history.push(link), 0)
}
return (
<BottomNavigation
value={location.pathname}
showLabels={true}
className={classes.root}
>
<BottomNavigationAction
label={t("常用")}
onClick={() => handleClick(`/${i18n.language}`)}
value={`/${i18n.language}`}
icon={<HomeIcon />}
/>
<BottomNavigationAction
label={t("搜尋")}
onClick={() => handleClick(`/${i18n.language}/search`)}
value={`/${i18n.language}/search`}
icon={<SearchIcon />}
/>
<BottomNavigationAction
label={selectedRoute.split('+')[0]}
onClick={() => handleClick(`/${i18n.language}/route/${selectedRoute}`)}
value={`/${i18n.language}/route/${selectedRoute}`}
icon={<TimerIcon />}
/>
<BottomNavigationAction
label={t("設定")}
onClick={() => handleClick(`/${i18n.language}/settings`)}
value={`/${i18n.language}/settings`}
icon={<SettingsIcon />}
/>
</BottomNavigation>
)
}