JGuang / JGuang UI
Components组件Base UIBase UI 组件

头像

展示用户头像,并在图片不可用时提供回退内容。

中文模式已适配导航、标题、简介、目录与常用章节名称。翻译状态:部分完成;技术正文目前仍为英文。
Loading JGuang UI example…

安装

Command

Manual

Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.

安装以下依赖:

npm install @base-ui/react

将以下代码复制到你的项目中。

View complete source: components/ui/avatar.tsx

根据项目配置更新导入路径。

用法

import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.

Composition

Use the following composition to build an Avatar:

Avatar
├── AvatarImage
├── AvatarFallback
└── AvatarBadge

Use the following composition to build an AvatarGroup:

AvatarGroup
├── Avatar
│   ├── AvatarImage
│   ├── AvatarFallback
│   └── AvatarBadge
├── Avatar
│   ├── AvatarImage
│   ├── AvatarFallback
│   └── AvatarBadge
└── AvatarGroupCount

Basic

A basic avatar component with an image and a fallback.

Loading JGuang UI example…

Badge

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

Loading JGuang UI example…

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

Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.

Badge with Icon

You can also use an icon inside <AvatarBadge>.

Loading JGuang UI example…

Avatar Group

Use the AvatarGroup component to add a group of avatars.

Loading JGuang UI example…

Avatar Group Count

Use <AvatarGroupCount> to add a count to the group.

Loading JGuang UI example…

Avatar Group with Icon

You can also use an icon inside <AvatarGroupCount>.

Loading JGuang UI example…

Sizes

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

Loading JGuang UI example…

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

Loading JGuang UI example…

从右到左布局

To enable RTL support in JGuang UI, see the RTL configuration guide.

Loading JGuang UI example…

API 参考

Avatar

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

PropTypeDefault
size"default" | "sm" | "lg""default"
classNamestring-

AvatarImage

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

PropTypeDefault
srcstring-
altstring-
classNamestring-

AvatarFallback

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

PropTypeDefault
classNamestring-

AvatarBadge

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

PropTypeDefault
classNamestring-

AvatarGroup

The AvatarGroup 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.

来源: components/base/avatar.mdx

JGuang UI 技术文档。

On this page