HextaUI

Avatar: Right to left

The badge stays on the end corner, which is the left in RTL, and groups overlap from the right.

مع
ALATGH5 more
"use client"

import {
  Avatar,
  AvatarBadge,
  AvatarFallback,
  AvatarGroup,
  AvatarImage,
  getInitials,
} from "@/components/ui/avatar"

const people = [
  { name: "Ada Lovelace", image: "/preview/landscape.svg" },
  { name: "Alan Turing", image: "/preview/landscape.svg" },
  { name: "Grace Hopper", image: "/preview/landscape.svg" },
  { name: "Katherine Johnson", image: null },
  { name: "Linus Torvalds", image: null },
  { name: "Margaret Hamilton", image: null },
  { name: "Tim Berners-Lee", image: null },
  { name: "Barbara Liskov", image: null },
]

export function AvatarRtl() {
  return (
    <div dir="rtl" className="flex flex-wrap items-center gap-4">
      <Avatar size="lg">
        <AvatarFallback>{getInitials("محمد علي")}</AvatarFallback>
        <AvatarBadge status="online" />
      </Avatar>
      <AvatarGroup max={4}>
        {people.map((person) => (
          <Avatar key={person.name}>
            {person.image ? <AvatarImage src={person.image} alt="" /> : null}
            <AvatarFallback>{getInitials(person.name)}</AvatarFallback>
          </Avatar>
        ))}
      </AvatarGroup>
    </div>
  )
}

This adds the example as components/examples/avatar/rtl.tsx, together with the Avatar component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/avatar-rtl.json

To add only the component, follow the Avatar installation.

Props in this example

The Avatar props this example sets, from the API reference.

PropTypeDefault
sizeInherited from the group when omitted.
"xs" | "sm" | "default" | "lg" | "xl""default"
PropTypeDefault
src
string–
alt
string–
PropTypeDefault
statusColors the dot and labels it for assistive tech. Without it the badge uses the primary color.
"online" | "away" | "busy" | "offline"–
PropTypeDefault
maxHow many items to show, including the count. Values below 2 are raised to 2.
number–

Every prop is in the Avatar API reference.

See them all, with keyboard support and accessibility notes, on the Avatar page.