avatar.tsx 1.1 KB

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