1import { Avatar as AvatarPrimitive } from "radix-ui";
2import * as React from "react";
3
4import { cn } from "@/lib/utils";
5
6const Avatar = React.forwardRef<
7 React.ElementRef<typeof AvatarPrimitive.Root>,
8 React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
9>(({ className, ...props }, ref) => (
10 <AvatarPrimitive.Root
11 ref={ref}
12 className={cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", className)}
13 {...props}
14 />
15));
16Avatar.displayName = AvatarPrimitive.Root.displayName;
17
18const AvatarImage = React.forwardRef<
19 React.ElementRef<typeof AvatarPrimitive.Image>,
20 React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
21>(({ className, ...props }, ref) => (
22 <AvatarPrimitive.Image
23 ref={ref}
24 className={cn("aspect-square h-full w-full", className)}
25 {...props}
26 />
27));
28AvatarImage.displayName = AvatarPrimitive.Image.displayName;
29
30const AvatarFallback = React.forwardRef<
31 React.ElementRef<typeof AvatarPrimitive.Fallback>,
32 React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
33>(({ className, ...props }, ref) => (
34 <AvatarPrimitive.Fallback
35 ref={ref}
36 className={cn(
37 "flex h-full w-full items-center justify-center rounded-full bg-muted text-xs font-medium",
38 className,
39 )}
40 {...props}
41 />
42));
43AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
44
45export { Avatar, AvatarImage, AvatarFallback };