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
Prop | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
user? | { name: string; email: string; avatar: string } | User data to display and edit. Object shape:
| |||||||||||||||
orders? | Order[] | Array of orders to display in the order history. Object shape:
| |||||||||||||||
onProfileSave? | (user: { name: string; email: string; avatar: string }) => void | Callback fired when the profile is saved. | |||||||||||||||
onOrderView? | (orderId: string) => void | Callback fired when an order is viewed. | |||||||||||||||
className? | string | Optional additional class names for the root container. |