跳转到内容
Page

Avatar Group

堆叠或展开的头像组,可显示溢出数量。

JA
MP
LK
+2
JA
MP
LK
SL
+1
import { Avatars } from "@pelagornis/page/components";

上方预览渲染的就是这个文件。把它复制到 src/components/ 即可开始使用。

src/components/AvatarsExample.tsx
import { Avatars, Stack } from "@pelagornis/page/components";
const team = [
{ alt: "Jihoon Ahn" },
{ alt: "Mina Park" },
{ alt: "Leo Kim" },
{ alt: "Sora Lee" },
{ alt: "Ren Ito" },
];
export default function AvatarsDemo() {
return (
<Stack gap="sizeLarge">
<Avatars avatars={team} max={3} />
<Avatars avatars={team} size="lg" layout="spread" max={4} />
</Stack>
);
}

Avatar Group 可以直接写在 .mdx 页面中。在 frontmatter 下方导入即可。它在服务器端渲染,不需要 client 指令。

src/content/docs/example.mdx
---
title: Example
---
import { Avatars } from "@pelagornis/page/components";
<Avatars avatars={[{ alt: "Jihoon Ahn" }, { alt: "Mina Park" }, { alt: "Leo Kim" }]} max={2} />

pageMarkdoc() 会为这个组件注册 avatars 标签。在 markdoc.config.mjs 中添加一次预设(见在 Markdoc 中使用),就能在任意 .mdoc 页面中使用该标签。

src/content/docs/example.mdoc
{% avatars avatars=[{alt: "Jihoon Ahn"}, {alt: "Mina Park"}, {alt: "Leo Kim"}] max=2 /%}

属性的名称和取值与 React props 相同。

每个 variant prop 可接受的取值。

Prop取值
sizexs sm md lg xl
layoutstack spread

组件的组成部分,以及每个部分渲染的 data-refineui 角色。

部件角色
rootavatars