Skip to content
Source
Sign inSign up
fuko/trytanstackdb.com
Open History to see the last commit

avatar.tsx

51 lines1.1 KB

1import * as AvatarPrimitive from "@radix-ui/react-avatar";
2import type * as React from "react";
3​
4import { cn } from "@/lib/utils";
5​
6function Avatar({
7 className,
8 ...props
9}: React.ComponentProps<typeof AvatarPrimitive.Root>) {
10 return (
11 <AvatarPrimitive.Root
12 data-slot="avatar"
13 className={cn(
14 "relative flex size-8 shrink-0 overflow-hidden rounded-full",
15 className,
16 )}
17 {...props}
18 />
19 );
21​
22function AvatarImage({
23 className,
24 ...props
25}: React.ComponentProps<typeof AvatarPrimitive.Image>) {
26 return (
27 <AvatarPrimitive.Image
28 data-slot="avatar-image"
29 className={cn("aspect-square size-full", className)}
30 {...props}
31 />
32 );
34​
35function AvatarFallback({
36 className,
37 ...props
38}: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {
39 return (
40 <AvatarPrimitive.Fallback
41 data-slot="avatar-fallback"
42 className={cn(
43 "bg-muted flex size-full items-center justify-center rounded-full",
44 className,
45 )}
46 {...props}
47 />
48 );
50​
51export { Avatar, AvatarImage, AvatarFallback };