Simple side menu
A sidebar with a logo, links with icons and account links at the bottom.
A sidebar with a logo, links with icons and account links at the bottom.
npm install @mantine/core @tabler/icons-react
First time with Mantine UI? Set it up once.
/**
* Component from Mantine UI, https://ui.mantine.dev
* MIT License, Copyright (c) 2022 Vitaly Rtischev. Full text: https://github.com/mantinedev/ui.mantine.dev/blob/master/LICENCE
* Changed for Tastebud: the Mantine logo is a plain block and the word Studio.
*/
import { useState } from 'react';
import {
Icon2fa,
IconBellRinging,
IconDatabaseImport,
IconFingerprint,
IconKey,
IconLogout,
IconReceipt2,
IconSettings,
IconSwitchHorizontal,
} from '@tabler/icons-react';
import { Box, Code, Group, Text } from '@mantine/core';
import classes from './NavbarSimple.module.css';
const data = [
{ link: '', label: 'Notifications', icon: IconBellRinging },
{ link: '', label: 'Billing', icon: IconReceipt2 },
{ link: '', label: 'Security', icon: IconFingerprint },
{ link: '', label: 'SSH Keys', icon: IconKey },
{ link: '', label: 'Databases', icon: IconDatabaseImport },
{ link: '', label: 'Authentication', icon: Icon2fa },
{ link: '', label: 'Other Settings', icon: IconSettings },
];
export function NavbarSimple() {
const [active, setActive] = useState('Billing');
const links = data.map((item) => (
<a
className={classes.link}
data-active={item.label === active || undefined}
href={item.link}
key={item.label}
onClick={(event) => {
event.preventDefault();
setActive(item.label);
}}
>
<item.icon className={classes.linkIcon} stroke={1.5} />
<span>{item.label}</span>
</a>
));
return (
<nav className={classes.navbar}>
<div className={classes.navbarMain}>
<Group className={classes.header} justify="space-between">
<Group gap={8} wrap="nowrap">
<Box w={28} h={28} bg="blue.6" style={{ borderRadius: 8 }} aria-hidden />
<Text fw={700} size="lg">
Studio
</Text>
</Group>
<Code fw={700}>v3.1.2</Code>
</Group>
{links}
</div>
<div className={classes.footer}>
<a href="#" className={classes.link} onClick={(event) => event.preventDefault()}>
<IconSwitchHorizontal className={classes.linkIcon} stroke={1.5} />
<span>Change account</span>
</a>
<a href="#" className={classes.link} onClick={(event) => event.preventDefault()}>
<IconLogout className={classes.linkIcon} stroke={1.5} />
<span>Logout</span>
</a>
</div>
</nav>
);
}
/**
* Component from Mantine UI, https://ui.mantine.dev
* MIT License, Copyright (c) 2022 Vitaly Rtischev. Full text: https://github.com/mantinedev/ui.mantine.dev/blob/master/LICENCE
* Changed for Tastebud: Mantine's PostCSS shorthands (@mixin, $mantine-breakpoint-*) are written out as
* plain CSS, so it runs without postcss-preset-mantine.
*/
.navbar {
height: 700px;
width: 300px;
padding: var(--mantine-spacing-md);
display: flex;
flex-direction: column;
border-right: 1px solid light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-4));
}
.navbarMain {
flex: 1;
}
.header {
padding-bottom: var(--mantine-spacing-md);
margin-bottom: calc(var(--mantine-spacing-md) * 1.5);
border-bottom: 1px solid light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-4));
}
.footer {
padding-top: var(--mantine-spacing-md);
margin-top: var(--mantine-spacing-md);
border-top: 1px solid light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-4));
}
.link {
display: flex;
align-items: center;
text-decoration: none;
font-size: var(--mantine-font-size-sm);
color: light-dark(var(--mantine-color-gray-7), var(--mantine-color-dark-1));
padding: var(--mantine-spacing-xs) var(--mantine-spacing-sm);
border-radius: var(--mantine-radius-sm);
font-weight: 500;
&:hover {
background-color: light-dark(var(--mantine-color-gray-0), var(--mantine-color-dark-6));
color: light-dark(var(--mantine-color-black), var(--mantine-color-white));
.linkIcon {
color: light-dark(var(--mantine-color-black), var(--mantine-color-white));
}
}
&[data-active] {
&,
&:hover {
background-color: var(--mantine-color-blue-light);
color: var(--mantine-color-blue-light-color);
.linkIcon {
color: var(--mantine-color-blue-light-color);
}
}
}
}
.linkIcon {
color: light-dark(var(--mantine-color-gray-6), var(--mantine-color-dark-2));
margin-right: var(--mantine-spacing-sm);
width: 25px;
height: 25px;
}
Changed for this site: The Mantine logo is a plain block and the word Studio. Mantine's PostCSS shorthands (@mixin, $mantine-breakpoint-*) are written out as plain CSS, so it runs without postcss-preset-mantine.