ComponentsUser Account Avatar

User Account Avatar

Component that displays a user's avatar and allows the user to edit their profile information and order history.

Code

1

Install with shadcn Beta

Terminal

npx shadcn@latest add "https://smoothui.dev/r/user-account-avatar.json"

Or install the demo

Terminal

npx shadcn@latest add "https://smoothui.dev/r/user-account-avatar-demo.json"

How to use

Demo.tsx

"use client"

import React, { useState } from "react"

import UserAccountAvatar, {
  Order,
  UserData,
} from "@/components/smoothui/ui/UserAccountAvatar"

const demoUser: UserData = {
  name: "Jane Doe",
  email: "[email protected]",
  avatar: "https://github.com/educlopez.png",
}

const demoOrders: Order[] = [
  { id: "ORD100", date: "2024-06-01", status: "delivered", progress: 100 },
  { id: "ORD101", date: "2024-06-10", status: "shipped", progress: 60 },
]

const UserAccountAvatarDemo = () => {
  const [user, setUser] = useState<UserData>(demoUser)
  const [orders] = useState<Order[]>(demoOrders)

  return (
    <UserAccountAvatar
      user={user}
      orders={orders}
      onProfileSave={(updated) => {
        setUser(updated)
        alert(`Profile saved: ${updated.name} (${updated.email})`)
      }}
      onOrderView={(orderId) => alert(`View order: ${orderId}`)}
    />
  )
}

export default UserAccountAvatarDemo

Props

PropTypeDescription
user?{ name: string; email: string; avatar: string }User data to display and edit.
Object shape:
FieldTypeDescription
namestringUser's name
emailstringUser's email
avatarstringAvatar image URL
orders?Order[]Array of orders to display in the order history.
Object shape:
FieldTypeDescription
idstringOrder ID
datestringOrder date
status"processing" | "shipped" | "delivered"Order status
progressnumberOrder progress percent
onProfileSave?(user: { name: string; email: string; avatar: string }) => voidCallback fired when the profile is saved.
onOrderView?(orderId: string) => voidCallback fired when an order is viewed.
className?stringOptional additional class names for the root container.