Avatar
uiable/avatarFreeComponent
Avatar component.
Live preview
live · rendered by the registry
Rendered by uiable on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://uiable.com/r/avatar.jsonSource
1"use client";23import { ComponentProps } from "react";45import { Avatar as AvatarPrimitive } from "@base-ui/react/avatar";67import { cn } from "@/lib/utils";89function Avatar({10 className,11 size = "default",12 ...props13}: AvatarPrimitive.Root.Props & {14 size?: "default" | "sm" | "lg";15}) {16 return (17 <AvatarPrimitive.Root18 data-slot="avatar"19 data-size={size}20 className={cn(21 "after:border-border group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",22 className23 )}24 {...props}25 />26 );27}2829function AvatarImage({ className, ...props }: AvatarPrimitive.Image.Props) {30 return (31 <AvatarPrimitive.Image32 data-slot="avatar-image"33 className={cn(34 "aspect-square size-full rounded-full object-cover",35 className36 )}37 {...props}38 />39 );40}4142function AvatarFallback({43 className,44 ...props45}: AvatarPrimitive.Fallback.Props) {46 return (47 <AvatarPrimitive.Fallback48 data-slot="avatar-fallback"49 className={cn(50 "bg-muted text-muted-foreground flex size-full items-center justify-center rounded-full text-sm group-data-[size=sm]/avatar:text-xs",51 className52 )}53 {...props}54 />55 );56}5758function AvatarBadge({ className, ...props }: ComponentProps<"span">) {59 return (60 <span61 data-slot="avatar-badge"62 className={cn(63 "bg-primary text-primary-foreground ring-background absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-blend-color ring-2 select-none",64 "group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden",65 "group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2",66 "group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2",67 className68 )}69 {...props}70 />71 );72}7374function AvatarGroup({ className, ...props }: ComponentProps<"div">) {75 return (76 <div77 data-slot="avatar-group"78 className={cn(79 "*:data-[slot=avatar]:ring-background group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2",80 className81 )}82 {...props}83 />84 );85}8687function AvatarGroupCount({88 className,89// … truncated
What it pulls in
npm packages
Files it writes
More from uiable
All 712 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | uiable | Components | Free | 2 deps | |
| Alertalert | uiable | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | uiable | Components | Free | 1 dep | |
| Aspect Ratioaspect-ratio | uiable | Components | Free | no deps | |
| Attachmentattachment | uiable | Components | Free | 2 deps | |
| Badgebadge | uiable | Components | Free | 2 deps | |
| Breadcrumbbreadcrumb | uiable | Components | Free | 2 deps | |
| Bubblebubble | uiable | Components | Free | 2 deps |
