BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/fysk/avatar

Avatar

fysk/avatar
FreeComponent

An image element with a fallback for representing the user.

Install it

npx shadcn@latest add https://fysk.dev/r/avatar.json

Source

fysk/avatar.tsxfysk.dev/r/avatar.json
1"use client"
2
3import * as React from "react"
4import * as AvatarPrimitive from "@radix-ui/react-avatar"
5import { cva, type VariantProps } from "class-variance-authority"
6
7import { cn } from "@/lib/utils"
8import { useFyskConfig } from "@/components/fysk-provider"
9
10const avatarVariants = cva(
11 "relative flex shrink-0 overflow-hidden rounded-full transition-all duration-150 active:scale-[0.98]",
12 {
13 variants: {
14 size: {
15 xs: "h-7 w-7 text-[10px]",
16 sm: "h-8 w-8 text-xs",
17 md: "h-9 w-9 text-xs",
18 lg: "h-10 w-10 text-sm",
19 xl: "h-12 w-12 text-base",
20 "2xl": "h-16 w-16 text-xl",
21 },
22 variant: {
23 default: "border border-border",
24 outline: "border-2 border-border bg-transparent",
25 ghost: "border-none bg-transparent",
26 glass: "bg-foreground/5 backdrop-blur-md border border-border/50 shadow-xs",
27 }
28 },
29 defaultVariants: {
30 size: "md",
31 variant: "default",
32 },
33 }
34)
35
36export interface AvatarProps
37 extends React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>,
38 VariantProps<typeof avatarVariants> {
39 src?: string
40 alt?: string
41 fallback?: React.ReactNode
42 state?: "idle" | "loading" | "error"
43 iconLoading?: React.ReactNode
44 iconError?: React.ReactNode
45}
46
47const Avatar = React.forwardRef<
48 React.ComponentRef<typeof AvatarPrimitive.Root>,
49 AvatarProps
50>(({ className, src, alt, fallback, size, variant, state = "idle", iconLoading: propIconLoading, iconError: propIconError, ...props }, ref) => {
51 const config = useFyskConfig()
52
53 const isLoading = state === "loading"
54 const isError = state === "error"
55
56 const finalIconLoading = propIconLoading || config.icons?.loading
57 const finalIconError = propIconError || config.icons?.error
58
59 const getInitials = (name?: string) => {
60 if (!name) return "FY"
61 return name
62 .split(" ")
63 .map((n) => n[0])
64 .join("")
65 .toUpperCase()
66 .slice(0, 2)
67 }
68
69 return (
70 <AvatarPrimitive.Root
71 ref={ref}
72 className={cn(avatarVariants({ size, variant, className }))}
73 {...props}
74 >
75 <AvatarPrimitive.Image
76 src={src}
77// … truncated

What it pulls in

npm packages

  • @radix-ui/react-avatar
  • class-variance-authority

Other registry items

  • utils
  • https://fysk.dev/r/fysk-provider.json

Files it writes

  • fysk/avatar.tsx

Facts

Registry
fysk
Type
registry:ui
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-03
Last confirmed
yesterday

Go to the source

fysk.dev ameghcoder/fysk on GitHub Raw registry item This item as JSON

More from fysk

All 18 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
BadgebadgefyskComponentsFree1 dep
ButtonbuttonfyskComponentsFree2 deps
Empty StateemptyfyskComponentsFree2 deps
FormformfyskComponentsFree4 deps
fysk-providerfysk-providerfyskComponentsFree2 deps
InputinputfyskComponentsFree1 dep
Input OTPinput-otpfyskComponentsFreeno deps
KbdkbdfyskComponentsFree1 dep
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex