shadimage
saastro
uiavatarsource: ok · hit

Avatar

Imagen de persona con iniciales de reserva, sobre Base UI.

npx shadcn add "https://ui.saastro.io/r/avatar.json"
free

No selection tags yet — empty means no evidence, not lack of support.

Dependencies

Bundle weight · light
ui-primitives@base-ui/react

Files1 · source cached 10/8/2026, 7:40:36 PM

registry/default/ui/avatar.tsx
"use client";

import { Avatar as AvatarPrimitive } from "@base-ui/react/avatar";

import { cn } from "@/lib/utils";

function Avatar({ className, ...props }: AvatarPrimitive.Root.Props) {
  return (
    <AvatarPrimitive.Root
      data-slot="avatar"
      className={cn(
        "relative flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-full bg-muted align-middle select-none",
        className,
      )}
      {...props}
    />
  );
}

function AvatarImage({ className, ...props }: AvatarPrimitive.Image.Props) {
  return (
    <AvatarPrimitive.Image
      data-slot="avatar-image"
      className={cn("aspect-square size-full object-cover", className)}
      {...props}
    />
  );
}

/**
 * El fallback aparece cuando la imagen no carga —o no la hay—. `delay` evita
 * el parpadeo de iniciales en el instante en que la imagen sí va a cargar:
 * sin él, una lista de avatares destella entera en cada render.
 */
function AvatarFallback({
  className,
  delay = 300,
  ...props
}: AvatarPrimitive.Fallback.Props) {
  return (
    <AvatarPrimitive.Fallback
      data-slot="avatar-fallback"
      delay={delay}
      className={cn(
        "flex size-full items-center justify-center rounded-full text-xs font-medium text-muted-foreground",
        className,
      )}
      {...props}
    />
  );
}

export { Avatar, AvatarFallback, AvatarImage };

More from saastro

Browse all components in this library →