# Avatar URL: /docs/components/avatar Source: https://raw.githubusercontent.com/goorm-dev/vapor-ui/refs/heads/main/apps/website/content/docs/components/(components)/avatar.mdx Avatar는 사용자가 설정한 프로필 이미지 혹은 텍스트를 UI상에 나타냅니다. *** title: 'Avatar' site\_name: 'Avatar - Vapor Core' description: 'Avatar는 사용자가 설정한 프로필 이미지 혹은 텍스트를 UI상에 나타냅니다.' ----------------------------------------------------------- ```tsx import { Avatar } from '@vapor-ui/core'; import { VAPOR_LOGO_URL } from '~/constants/image-urls'; export default function DefaultAvatar() { return ; } ``` ## Property *** ### Shape Avatar의 모양을 설정합니다. ```tsx import { Avatar, HStack, Text, VStack } from '@vapor-ui/core'; import { VAPOR_LOGO_URL } from '~/constants/image-urls'; export default function AvatarShape() { return ( square circle ); } ``` ### Size Avatar의 크기를 설정합니다. ```tsx import { Avatar, HStack, Text, VStack } from '@vapor-ui/core'; import { VAPOR_LOGO_URL } from '~/constants/image-urls'; export default function AvatarSize() { return ( sm md lg xl ); } ``` ## Examples *** ### Fallback 이미지가 없거나 로드에 실패한 경우, alt 텍스트의 첫 글자가 자동으로 표시됩니다. 배경색은 alt 문자열을 기반으로 결정됩니다. ```tsx import { Avatar, HStack } from '@vapor-ui/core'; export default function AvatarFallback() { return ( ); } ``` ### Custom Fallback FallbackPrimitive에 children을 전달하여 커스텀 fallback 콘텐츠를 표시합니다. ```tsx import { Avatar, HStack, Text, VStack } from '@vapor-ui/core'; export default function AvatarCustomFallback() { return ( auto initial custom text JD ); } ``` ### Custom Image `children`으로 `Avatar.ImagePrimitive`와 `Avatar.FallbackPrimitive`를 전달하면 각 슬롯에 직접 props를 적용할 수 있습니다. `src`, `alt`, `crossOrigin` 등 이미지 관련 props는 `Avatar.Root`에 전달하면 내부 Primitive로 자동 전달됩니다. ```tsx import { Avatar, HStack, Text, VStack } from '@vapor-ui/core'; const IMAGE_URL = 'https://avatars.githubusercontent.com/u/217160984?v=4'; export default function AvatarCustomImage() { return ( ImagePrimitive FallbackPrimitive JD ); } ``` ## Props Table *** ### Avatar.Root > ⚠️ Spec file not found: `avatar-root.json` #### Avatar.ImagePrimitive > ⚠️ Spec file not found: `avatar-image-primitive.json` #### Avatar.FallbackPrimitive > ⚠️ Spec file not found: `avatar-fallback-primitive.json`