跳至正文

Avatar

Named image or fallback initials for a person.

浏览器
Chrome 123+Firefox 121+Safari 17.5+
层级
0
压缩后大小
293 B
强制布局预算
0 ms
axe 预算
0
支持 SSR
是
公开契约
测试环境

交互示例

Avatar

Ada Lovelace

示例

Sizes

The root exposes its size through data-size.

Ada Lovelace
import { Avatar } from "@gunkin/uiify";

export default function Example() {
  return (
    <>
      <Avatar aria-hidden="true" name="Ada Lovelace" fallback="AL" size="sm" />
      <Avatar aria-hidden="true" name="Ada Lovelace" fallback="AL" size="md" />
      <Avatar aria-hidden="true" name="Ada Lovelace" fallback="AL" size="lg" />
      <span>Ada Lovelace</span>
    </>
  );
}

API

Avatar

属性类型默认值说明
name*string—Accessible name for the person represented by the avatar.
fallback*string—Text shown when src is omitted; provide meaningful initials or a short name.
srcstring—Image URL; the image is rendered only when supplied.
size"sm" | "md" | "lg"—Visual scale written to data-size; omitted when unset.
aria-hidden"true"—Hide the avatar from assistive technology when adjacent visible text already names the person.
classNamestring—应用于根元素的类名。
styleCSSProperties—Native root styles.
refRef<HTMLElement>—Ref forwarded to the rendered root element.
renderReactElement | ((props, state) => ReactElement)—替换渲染元素,同时保留行为和无障碍连接关系。

键盘

按键操作

无障碍

The root is named as an image and the fallback is hidden from assistive technology. Keep a visible name beside decorative avatars and set aria-hidden when that text already names the person. A supplied src renders an image; image-load failures do not trigger a replacement fallback.

样式钩子

data-uiify-avatardata-partdata-size
本页由机器翻译,尚未经人工审核。