mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-07-07 14:08:47 +00:00
72 lines
1.3 KiB
Plaintext
72 lines
1.3 KiB
Plaintext
---
|
|
title: Avatar
|
|
description: An image element with a fallback for representing the user.
|
|
base: base
|
|
component: true
|
|
links:
|
|
doc: https://www.radix-ui.com/docs/primitives/components/avatar
|
|
api: https://www.radix-ui.com/docs/primitives/components/avatar#api-reference
|
|
---
|
|
|
|
<ComponentPreview
|
|
styleName="base-nova"
|
|
name="avatar-demo"
|
|
title="Avatar"
|
|
description="An avatar with a fallback."
|
|
/>
|
|
|
|
## Installation
|
|
|
|
<CodeTabs>
|
|
|
|
<TabsList>
|
|
<TabsTrigger value="cli">CLI</TabsTrigger>
|
|
<TabsTrigger value="manual">Manual</TabsTrigger>
|
|
</TabsList>
|
|
<TabsContent value="cli">
|
|
|
|
```bash
|
|
npx shadcn@latest add avatar
|
|
```
|
|
|
|
</TabsContent>
|
|
|
|
<TabsContent value="manual">
|
|
|
|
<Steps>
|
|
|
|
<Step>Install the following dependencies:</Step>
|
|
|
|
```bash
|
|
npm install @base-ui/react
|
|
```
|
|
|
|
<Step>Copy and paste the following code into your project.</Step>
|
|
|
|
<ComponentSource
|
|
name="avatar"
|
|
title="components/ui/avatar.tsx"
|
|
styleName="base-nova"
|
|
/>
|
|
|
|
<Step>Update the import paths to match your project setup.</Step>
|
|
|
|
</Steps>
|
|
|
|
</TabsContent>
|
|
|
|
</CodeTabs>
|
|
|
|
## Usage
|
|
|
|
```tsx showLineNumbers
|
|
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
|
|
```
|
|
|
|
```tsx showLineNumbers
|
|
<Avatar>
|
|
<AvatarImage src="https://github.com/shadcn.png" />
|
|
<AvatarFallback>CN</AvatarFallback>
|
|
</Avatar>
|
|
```
|