• 简体中文
  • 徽标与状态

    叠在头像上的小组件。

    194299+
    import { AgentPortrait, UnreadBadge, AvatarStatusDot } from '@aora-bot/react';
    
    export default function Demo() {
      return (
        <div className="site-demo">
          {[1, 9, 42, 128].map((count) => (
            <span key={count} style={{ position: 'relative', display: 'inline-flex' }}>
              <AgentPortrait agent={{ id: `badge-${count}` }} sizePx={44} still />
              <span style={{ position: 'absolute', top: -4, insetInlineEnd: -8 }}>
                <UnreadBadge count={count} />
              </span>
            </span>
          ))}
        </div>
      );
    }

    UnreadBadge

    数字最多显示为 99+,避免过大的数字撑坏布局。完整计数仍会播报给辅助技术,所以真实数字重要时,用户不会只听到「九十九加」。

    属性类型默认值说明
    count*number——
    classNamestring——
    styleCSSProperties——

    AvatarStatusDot

    online
    busy
    away
    offline
    working
    attention
    error
    info
    import { AgentPortrait, AvatarStatusDot } from '@aora-bot/react';
    
    const tones = ['online', 'busy', 'away', 'offline', 'working', 'attention', 'error', 'info'] as const;
    
    export default function Demo() {
      return (
        <div className="site-demo">
          {tones.map((tone) => (
            <div className="site-demo__cell" key={tone}>
              <span style={{ position: 'relative', display: 'inline-flex' }}>
                <AgentPortrait agent={{ id: tone }} sizePx={44} still />
                <span style={{ position: 'absolute', bottom: 0, insetInlineEnd: 0 }}>
                  <AvatarStatusDot tone={tone} pulse={tone === 'busy'} />
                </span>
              </span>
              <span className="site-demo__label">{tone}</span>
            </div>
          ))}
        </div>
      );
    }

    共八种色调。前四种表示在线状态:online、busy、away、offline;后四种表示智能体的工作状态:working、attention、error、info。两组共用头像的同一个角,因为同时显示两者时,第二个没有位置可放;名册只显示当前这一屏上更重要的那一种。

    状态点外面有一圈页面背景色的描边,使它在头像上清晰可辨。ring 会在此基础上再加一圈向外扩散的光晕;需要引起注意的 working 和 attention 两种色调默认开启,其余默认关闭。如果状态没有同时用文字写出,请传入 label;没有 label 时,状态点是 aria-hidden,因为只靠颜色不能作为无障碍信号。

    属性类型默认值说明
    classNamestring——
    labelstring——
    pulsebooleanfalseSlow pulse, for states that mean "something is happening".
    ringboolean—Expanding halo around the dot. Defaults to on for `working` and `attention`, which are the two tones that are asking to be noticed.
    styleCSSProperties——
    toneStatusTone'offline'—

    WorkingBadge

    三个脉动的圆点,用于忙碌中的智能体,大小正好放在状态点所在的那个角。不要在同一个头像上同时使用它和状态点,改用 working 色调即可。组件及其 props 见 WorkingBadge。

    接下来