Skip to content
Myr

avatar.tsx

This file

Path

apps/web/src/components/ui/avatar.tsx

108 lines · 3.0 KiB · TypeScript

Last changed by

Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e

History of this file

Take it

Give the web its W9 dependencies, components, project nav, line and revision helpers, and a stub for every new pageoscabrielbefore adoption254268a

lines 1–47why, one step back
1"use client";
23import { Avatar as AvatarPrimitive } from "@base-ui/react/avatar";4import { cn } from "cn";5import * as React from "react";67function Avatar({8 className,9 size = "default",10 ...props11}: AvatarPrimitive.Root.Props & {12 size?: "default" | "sm" | "lg";13}) {14 return (15 <AvatarPrimitive.Root16 data-slot="avatar"17 data-size={size}18 className={cn(19 "group/avatar after:border-border 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",20 className21 )}22 {...props}23 />24 );25}2627function AvatarImage({ className, ...props }: AvatarPrimitive.Image.Props) {28 return (29 <AvatarPrimitive.Image30 data-slot="avatar-image"31 className={cn(32 "aspect-square size-full rounded-full object-cover",33 className34 )}35 {...props}36 />37 );38}3940function AvatarFallback({41 className,42 ...props43}: AvatarPrimitive.Fallback.Props) {44 return (45 <AvatarPrimitive.Fallback46 data-slot="avatar-fallback"47 className={cn(

Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e

line 48why, one step back
48 "bg-muted text-muted-foreground text-ui group-data-[size=sm]/avatar:text-label flex size-full items-center justify-center rounded-full",

Give the web its W9 dependencies, components, project nav, line and revision helpers, and a stub for every new pageoscabrielbefore adoption254268a

lines 49–92why, one step back
49 className
50 )}51 {...props}52 />53 );54}5556function AvatarBadge({ className, ...props }: React.ComponentProps<"span">) {57 return (58 <span59 data-slot="avatar-badge"60 className={cn(61 "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",62 "group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden",63 "group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2",64 "group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2",65 className66 )}67 {...props}68 />69 );70}7172function AvatarGroup({ className, ...props }: React.ComponentProps<"div">) {73 return (74 <div75 data-slot="avatar-group"76 className={cn(77 "group/avatar-group *:data-[slot=avatar]:ring-background flex -space-x-2 *:data-[slot=avatar]:ring-2",78 className79 )}80 {...props}81 />82 );83}8485function AvatarGroupCount({86 className,87 ...props88}: React.ComponentProps<"div">) {89 return (90 <div91 data-slot="avatar-group-count"92 className={cn(

Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e

line 93why, one step back
93 "bg-muted text-muted-foreground ring-background text-ui relative flex size-8 shrink-0 items-center justify-center rounded-full ring-2 group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3",

Give the web its W9 dependencies, components, project nav, line and revision helpers, and a stub for every new pageoscabrielbefore adoption254268a

lines 94–108why, one step back
94 className
95 )}96 {...props}97 />98 );99}100101export {102 Avatar,103 AvatarImage,104 AvatarFallback,105 AvatarGroup,106 AvatarGroupCount,107 AvatarBadge,108};