ReScript Shadcn
Get started
  • Installation
Components
  • Accordion
  • Alert
  • AlertDialog
  • AspectRatio
  • Attachment
  • Avatar
  • Badge
  • Breadcrumb
  • Bubble
  • Button
  • ButtonGroup
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Collapsible
  • Combobox
  • Command
  • ContextMenu
  • DataTable
  • DatePicker
  • Dialog
  • Direction
  • Drawer
  • DropdownMenu
  • Empty
  • Field
  • HoverCard
  • Input
  • InputGroup
  • InputOtp
  • Item
  • Kbd
  • Label
  • Marker
  • Menubar
  • Message
  • MessageScroller
  • NativeSelect
  • NavigationMenu
  • Pagination
  • Popover
  • Progress
  • RadioGroup
  • Resizable
  • ScrollArea
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Skeleton
  • Slider
  • Sonner
  • Spinner
  • Switch
  • Table
  • Tabs
  • Textarea
  • Toast
  • Toggle
  • ToggleGroup
  • Tooltip
  • Typography

Avatar

An image element with a fallback for representing the user.

CNER
CNLRER
+3

Installation#

npx shadcn@latest add @rescript-shadcn/Avatar

Usage#

<Avatar>
  <Avatar.Image src="https://github.com/shadcn.png" alt="@shadcn" />
  <Avatar.Fallback> {"CN"->React.string} </Avatar.Fallback>
</Avatar>

Examples#

Basic#

A basic avatar component with an image and a fallback.

CN

Badge#

Use the Avatar.Badge component to add a badge to the avatar. The badge is positioned at the bottom right of the avatar.

CN

Use the className prop to add custom styles to the badge such as custom colors, sizes, etc.

<Avatar>
  <AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
  <AvatarFallback> {"CN"->React.string} </AvatarFallback>
  <AvatarBadge className="bg-green-600 dark:bg-green-800" />
</Avatar>

Badge with Icon#

You can also use an icon inside <Avatar.Badge>.

PP

Avatar Group#

Use the Avatar.Group component to add a group of avatars.

CNLRER

Avatar Group Count#

Use <Avatar.GroupCount> to add a count to the group.

CNLRER
+3

Avatar Group with Icon#

You can also use an icon inside <Avatar.GroupCount>.

CNLRER

Sizes#

Use the size prop to change the size of the avatar.

CNCNCN

Dropdown#

You can use the Avatar component as a trigger for a dropdown menu.

API Reference#

Avatar#

The Avatar component is the root component that wraps the avatar image and fallback.

PropTypeDefault
sizeDefault | Sm | LgDefault
classNamestring-

AvatarImage#

The Avatar.Image component displays the avatar image. It accepts all Base UI Avatar Image props.

PropTypeDefault
srcstring-
altstring-
classNamestring-

AvatarFallback#

The Avatar.Fallback component displays a fallback when the image fails to load. It accepts all Base UI Avatar Fallback props.

PropTypeDefault
classNamestring-

AvatarBadge#

The Avatar.Badge component displays a badge indicator on the avatar, typically positioned at the bottom right.

PropTypeDefault
classNamestring-

Avatar.Group#

The Avatar.Group component displays a group of avatars with overlapping styling.

PropTypeDefault
classNamestring-

AvatarGroupCount#

The AvatarGroupCount component displays a count indicator in an avatar group, typically showing the number of additional avatars.

PropTypeDefault
classNamestring-

For more information about Base UI Avatar props, see the Base UI documentation.

@react.component
let make = () =>
  <div className="flex flex-row flex-wrap items-center gap-6 md:gap-12">
@react.component
let make = () =>
  <Avatar>
@react.component
let make = () =>
  <Avatar>
@react.component
let make = () =>
  <Avatar className="grayscale">
@react.component
let make = () =>
  <Avatar.Group className="grayscale">
@react.component
let make = () =>
  <Avatar.Group className="grayscale">
@react.component
let make = () =>
  <Avatar.Group className="grayscale">
@react.component
let make = () =>
  <div className="flex flex-wrap items-center gap-2 grayscale">
@react.component
let make = () => {
  <DropdownMenu>