Avatar
A graphical representation of a user, commonly used in profile sections, comment threads, or user menus.
JC
import { Avatar } from '@fidely-ui/react/avatar'
export const AvatarBasics = () => {
return (
<>
<Avatar.Root size={'lg'}>
<Avatar.Fallback name="Justice Chimobi" />
<Avatar.Image
src={'https://avatars.githubusercontent.com/u/74328318?v=4'}
/>
</Avatar.Root>
</>
)
}
Usage
import { Avatar } from '@fidely-ui/react'<Avatar.Root>
<Avatar.Fallback />
<Avatar.Image />
</Avatar.Root>Sizes
You can control the size of the Avatar using the size prop.
import { Avatar } from '@fidely-ui/react/avatar'
export const AvatarSizes = () => {
return (
<>
<Avatar.Root size={'xl'}>
<Avatar.Image src={'http://bit.ly/43kBcJt'} />
</Avatar.Root>
<Avatar.Root size={'md'}>
<Avatar.Image src={'http://bit.ly/47jPX1D'} />
</Avatar.Root>
<Avatar.Root size={'xs'}>
<Avatar.Image src={'https://rb.gy/39f8mx'} />
</Avatar.Root>
</>
)
}
Fallback
When no image source is provided, the Avatar automatically renders the userβs initials and when no initial value it displays an icon.
JC
import { Avatar } from '@fidely-ui/react/avatar'
export const AvatarFallback = () => {
return (
<>
<Avatar.Root>
<Avatar.Fallback name="Justice Chimobi" />
</Avatar.Root>
<Avatar.Root>
<Avatar.Fallback />
</Avatar.Root>
</>
)
}
Props
Root
| Prop | Default | Type | Description |
|---|---|---|---|
colorPalette | gray | "red" | "blue" | "green" | "purple" | "orange" | "gray" | The color palette of the component. |
size | md | 'full' | '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | The size of the component. |
variant | subtle | 'solid' | 'subtle' | 'outline' | The variant of the component. |
shape | full | 'square' | 'rounded' | 'full' | The shape of the component. |
as | β | React.ElementType | The underlying element to render. |
asChild | false | boolean | Use the provided child element as the default rendered element, combining their props and behavior. |
unstyled | false | boolean | Whether to remove the component's style. |
ids | β | Partial<{ root: string; image: string; fallback: string }> | The ids of the elements in the avatar. Useful for composition. |
onStatusChange | β | (details: StatusChangeDetails) => void | Function called when the image loading status changes. |
borderless | false | 'true' | 'false' | Controls whether the avatar is rendered without a border. |
Fallback
| Prop | Default | Type | Description |
|---|---|---|---|
name | β | string | undefined | The name to derive the initials from. If not provided, displays a generic icon. |
as | β | React.ElementType | The underlying element to render. |
asChild | false | boolean | Use the provided child element as the default rendered element, combining their props and behavior. |
Image
| Prop | Default | Type | Description |
|---|---|---|---|
as | β | React.ElementType | The underlying element to render. |
asChild | false | boolean | Use the provided child element as the default rendered element, combining their props and behavior. |