The CAvatar component is used to visually represent a user by displaying their profile picture, initials or a fallback icon.
Chakra UI Vue exports 3 Avatar related components.
CAvatar: The image that represents the user.CAvatarBadge: A widget that displays the status of a user on the bottom-right corner of the CAvatar.CAvatarGroup: A wrapper that stacks multiple CAvatars together.import { CAvatar, CAvatarBadge } from "@chakra-ui/vue";
<c-stack is-inline>
<c-avatar name="Evan You" src="https://bit.ly/chakra-evan-you" />
<c-avatar name="Segun Adebayo" src="https://bit.ly/chakra-segun-adebayo" />
<c-avatar name="Sarah Drasner" src="https://bit.ly/chakra-sarah-drasner" />
<c-avatar name="Kelvin Omereshone" src="https://bit.ly/chakra-kelvin-omereshone" />
<c-avatar name="Mesut Koca" src="https://bit.ly/chakra-mesut-koca" />
<c-avatar name="Gift Egwuenu" src="https://bit.ly/chakra-gift-egwuenu" />
<c-avatar name="Maya Shavin" src="https://bit.ly/chakra-maya-shavin" />
<c-avatar name="Jonathan Bakebwa" src="https://bit.ly/chakra-jonathan-bakebwa" />
</c-stack>
The CAvatar component comes in 7 sizes: 2xs, xs, sm, md, lg xl and 2xl
<c-stack is-inline>
<c-avatar size="2xs" name="Evan You" src="https://bit.ly/chakra-evan-you" />
<c-avatar size="xs" name="Segun Adebayo" src="https://bit.ly/chakra-segun-adebayo" />
<c-avatar size="sm" name="Sarah Drasner" src="https://bit.ly/chakra-sarah-drasner" />
<c-avatar size="md" name="Kelvin Omereshone" src="https://bit.ly/chakra-kelvin-omereshone" />
<c-avatar size="lg" name="Mesut Koca" src="https://bit.ly/chakra-mesut-koca" />
<c-avatar size="xl" name="Maya Shavin" src="https://bit.ly/chakra-maya-shavin" />
<c-avatar size="2xl" name="Jonathan Bakebwa" src="https://bit.ly/chakra-jonathan-bakebwa" />
</c-stack>
If there was an error loading the src of the CAvatar, there are 2 fallbacks:
name prop is provided, the CAvatar component will use it to generate
initials and a random, accessible background color.name prop is provided, the CAvatar will use a default avatar.<c-stack is-inline>
<c-avatar name="Lady Tsunade" src="https://bit.ly/broken-link" />
<c-avatar name="Kaguya Otsutsuki" src="https://bit.ly/broken-link" />
<c-avatar src="https://bit.ly/broken-link" />
</c-stack>
In some products, you might need show a badge on the bottom-right corner of the CAvatar.
We call this a badge. Here's an example that shows if the user is online:
<c-stack is-inline>
<c-avatar name="Naruto Uzumaki" src="https://bit.ly/chakra-naruto-uzumaki">
<c-avatar-badge size="1.0em" bg="green.500" />
</c-avatar>
<c-avatar name="Sakura Haruno" src="https://bit.ly/chakra-sakura-haruno">
<c-avatar-badge size="1.0em" bg="green.500" />
</c-avatar>
<c-avatar name="Sasuke Uchiha" src="https://bit.ly/chakra-sasuke-uchiha">
<c-avatar-badge size="1.0em" bg="red.400" />
</c-avatar>
<c-avatar show-border name="Kakashi Hatake" src="https://bit.ly/chakra-kakashi-hatake">
<c-avatar-badge size="1.0em" bg="orange.400" />
</c-avatar>
</c-stack>
Note the use of
emfor the size of theCAvatarBadge. this is useful to size the badge relative to the avatar font size
In some cases, you might need to stack avatars in a group. Use the CAvatarGroup
component to do this
max prop. It'll truncate the
avatars and show a "+X" label (where X is the remaining number of avatars).size prop.spacing prop.
// Try editing the \`max\` prop to change the maximum number of avatars
<c-avatar-group max="3">
<c-avatar name="Evan You" src="https://bit.ly/chakra-evan-you" />
<c-avatar name="Jonathan Bakebwa" src="https://bit.ly/chakra-jonathan-bakebwa" />
<c-avatar name="Segun Adebayo" src="https://bit.ly/chakra-segun-adebayo" />
<c-avatar name="Sarah Drasner" src="https://bit.ly/chakra-sarah-drasner" />
<c-avatar name="Kelvin Omereshone" src="https://bit.ly/chakra-kelvin-omereshone" />
<c-avatar name="Mesut Koca" src="https://bit.ly/chakra-mesut-koca" />
<c-avatar name="Maya Shavin" src="https://bit.ly/chakra-maya-shavin" />
</c-avatar-group>
| Name | Type | Default | Description |
|---|---|---|---|
| size | 2xs, xs, sm, md, lg, xl, 2xl | md | The size of the avatar |
| showBorder | boolean | false | If true, the CAvatar will show a border around it. Best for a group of avatars |
| name | string | The name of the user in the avatar | |
| src | string | The image url of the CAvatar |
CAvatarcomposes theCBoxcomponent. So it also accepts allCBoxprops.CAvatarBadgecomposes theCBoxcomponent. So it also accepts allCBoxprops.CAvatarGroupcomposes theCFlexcomponent. So it also accepts allCFlexprops.
| Name | Description |
|---|---|
| default | Used for the CAvatarBadge at the bottom right corner of the CAvatar. |
Caught a mistake or want to contribute to the documentation? Edit this page on GitHub!