avatar
9ui/avatarFreeComponent
9ui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by 9ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://9ui.dev/r/avatar.jsonSource
1"use client"23import * as React from "react"4import { Avatar as AvatarBase } from "@base-ui/react/avatar"5import { cva, VariantProps } from "class-variance-authority"67import { cn } from "@/lib/utils"89const avatarVariants = cva(10 "relative flex shrink-0 overflow-hidden rounded-full",11 {12 variants: {13 size: {14 sm: "size-8 text-sm",15 md: "size-10",16 lg: "size-12 text-lg",17 },18 },19 defaultVariants: {20 size: "md",21 },22 }23)2425function Avatar({26 className,27 size,28 ...props29}: React.ComponentProps<typeof AvatarBase.Root> &30 VariantProps<typeof avatarVariants>) {31 return (32 <AvatarBase.Root33 data-slot="avatar"34 className={cn(avatarVariants({ size }), className)}35 {...props}36 />37 )38}3940function AvatarImage({41 className,42 ...props43}: React.ComponentProps<typeof AvatarBase.Image>) {44 return (45 <AvatarBase.Image46 data-slot="avatar-image"47 className={cn("size-full object-cover", className)}48 {...props}49 />50 )51}5253function AvatarFallback({54 className,55 ...props56}: React.ComponentProps<typeof AvatarBase.Fallback>) {57 return (58 <AvatarBase.Fallback59 data-slot="avatar-fallback"60 className={cn(61 "bg-muted flex size-full items-center justify-center rounded-full select-none",62 className63 )}64 {...props}65 />66 )67}6869export { Avatar, AvatarImage, AvatarFallback }
Files it writes
More from 9ui
All 56 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | 9ui | Components | Free | no deps | |
| alertalert | 9ui | Components | Free | no deps | |
| alert-dialogalert-dialog | 9ui | Components | Free | no deps | |
| aspect-ratioaspect-ratio | 9ui | Components | Free | no deps | |
| autocompleteautocomplete | 9ui | Components | Free | no deps | |
| badgebadge | 9ui | Components | Free | no deps | |
| breadcrumbsbreadcrumbs | 9ui | Components | Free | no deps | |
| buttonbutton | 9ui | Components | Free | no deps |
