avatar.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. "use client"
  2. import * as React from "react"
  3. import * as AvatarPrimitive from "@radix-ui/react-avatar"
  4. import { cn } from "@/lib/utils"
  5. function Avatar({
  6. className,
  7. ...props
  8. }: React.ComponentProps<typeof AvatarPrimitive.Root>) {
  9. return (
  10. <AvatarPrimitive.Root
  11. data-slot="avatar"
  12. className={cn(
  13. "relative flex size-8 shrink-0 overflow-hidden rounded-full",
  14. className
  15. )}
  16. {...props}
  17. />
  18. )
  19. }
  20. function AvatarImage({
  21. className,
  22. ...props
  23. }: React.ComponentProps<typeof AvatarPrimitive.Image>) {
  24. return (
  25. <AvatarPrimitive.Image
  26. data-slot="avatar-image"
  27. className={cn("aspect-square size-full", className)}
  28. {...props}
  29. />
  30. )
  31. }
  32. function AvatarFallback({
  33. className,
  34. ...props
  35. }: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {
  36. return (
  37. <AvatarPrimitive.Fallback
  38. data-slot="avatar-fallback"
  39. className={cn(
  40. "bg-muted flex size-full items-center justify-center rounded-full",
  41. className
  42. )}
  43. {...props}
  44. />
  45. )
  46. }
  47. export { Avatar, AvatarImage, AvatarFallback }