Add drop-down menu to Avatar

This commit is contained in:
Daniel S. Hansen
2025-07-14 12:23:26 -07:00
parent 1223ecc0b6
commit bc83710acc
2 changed files with 21 additions and 6 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ export default function CanvasHeader() {
as="header" as="header"
position="sticky" position="sticky"
top="0" top="0"
zIndex="banner" // zIndex="banner"
bg="white" bg="white"
borderBottom="1px solid" borderBottom="1px solid"
borderColor="gray.200" borderColor="gray.200"
+20 -5
View File
@@ -1,5 +1,5 @@
import { Box, Button, Avatar, HStack, Stack, Text } from "@chakra-ui/react" import { Box, Button, Avatar, HStack, Stack, Text, Menu, Portal } from "@chakra-ui/react"
export default function Header() { export default function Header() {
return ( return (
@@ -20,10 +20,25 @@ export default function Header() {
<Text color="#19332D" fontWeight="bold" textStyle="lg">{user.name}</Text> <Text color="#19332D" fontWeight="bold" textStyle="lg">{user.name}</Text>
<Text color="fg.muted" textStyle="sm">{user.email}</Text> <Text color="fg.muted" textStyle="sm">{user.email}</Text>
</Stack> </Stack>
<Avatar.Root> {/* Add a drop down menu to the avatar */}
<Avatar.Fallback name={user.name} /> <Menu.Root>
<Avatar.Image src={user.avatar} /> <Menu.Trigger rounded="full" focusRing="outside">
</Avatar.Root> <Avatar.Root>
<Avatar.Fallback name={user.name} />
<Avatar.Image src={user.avatar} />
</Avatar.Root>
</Menu.Trigger>
<Portal>
<Menu.Positioner zIndex="popover">
<Menu.Content>
<Menu.Item value="account">Account</Menu.Item>
<Menu.Item value="settings">Settings</Menu.Item>
<Menu.Item value="logout">Logout</Menu.Item>
</Menu.Content>
</Menu.Positioner>
</Portal>
</Menu.Root>
</HStack> </HStack>
</Button> </Button>
</Box> </Box>