avatar.tsx 1.0 KB

1234567891011121314151617181920212223242526
  1. import * as AvatarPrimitive from '@radix-ui/react-avatar';
  2. import * as React from 'react';
  3. import { cn } from '@/common/helpers/cn';
  4. function Avatar({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Root>) {
  5. return (
  6. <AvatarPrimitive.Root data-slot="avatar" className={cn('relative flex size-8 shrink-0 overflow-hidden rounded-full', className)} {...props} />
  7. );
  8. }
  9. function AvatarImage({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Image>) {
  10. return <AvatarPrimitive.Image data-slot="avatar-image" className={cn('aspect-square size-full', className)} {...props} />;
  11. }
  12. function AvatarFallback({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {
  13. return (
  14. <AvatarPrimitive.Fallback
  15. data-slot="avatar-fallback"
  16. className={cn('flex size-full items-center justify-center rounded-full bg-muted', className)}
  17. {...props}
  18. />
  19. );
  20. }
  21. export { Avatar, AvatarFallback, AvatarImage };