Skip to content
Nacre
Color palette
中文

Presence

stablePresenceDot · PillOpen in playground
PresenceDot
Runs the real component in your browser.

An agent’s Online / Break / Offline status: PresenceDot is an 8pt dot (it can sit on an avatar), and Pill is a capsule with a dot and text; a Pill without a status is a plain-text group or skill tag.

Status: stable · Components: PresenceDot, Pill

import { PresenceDot, Pill } from 'nacre'
import { Text, View } from 'nsh'
import { Pill, PresenceDot, TEXT_SIZE } from 'nacre'
export function PresenceUsage() {
return (
<View class="flex-row items-center gap-2">
<PresenceDot kind="online" label="Online" />
<Text class={`${TEXT_SIZE.small} text-foreground`}>Lin Jiayi</Text>
<Pill label="HK account opening" />
</View>
)
}

Five kinds: online / break / offline / neutral / error; offline is a hollow ring, so color isn’t the only cue; error means signed in but not receiving routed work (dispatch paused after a missed call), a solid red dot, not the hollow offline ring. A dot has no text, so label is required.

import { Text, View } from 'nsh'
import { PresenceDot, TEXT_SIZE } from 'nacre'
export function PresenceDots() {
return (
<View class="flex-row flex-wrap items-center gap-4">
<View class="flex-row items-center gap-1.5">
<PresenceDot kind="online" label="Online" />
<Text class={`${TEXT_SIZE.small} text-muted-foreground`}>Online</Text>
</View>
<View class="flex-row items-center gap-1.5">
<PresenceDot kind="break" label="Break" />
<Text class={`${TEXT_SIZE.small} text-muted-foreground`}>Break</Text>
</View>
<View class="flex-row items-center gap-1.5">
<PresenceDot kind="offline" label="Offline" />
<Text class={`${TEXT_SIZE.small} text-muted-foreground`}>Offline</Text>
</View>
<View class="flex-row items-center gap-1.5">
<PresenceDot kind="neutral" label="Unknown" />
<Text class={`${TEXT_SIZE.small} text-muted-foreground`}>Unknown</Text>
</View>
<View class="flex-row items-center gap-1.5">
<PresenceDot kind="error" label="Dispatch paused" />
<Text class={`${TEXT_SIZE.small} text-muted-foreground`}>Dispatch paused</Text>
</View>
</View>
)
}

With kind, a Pill is a status dot plus text; without kind, it’s a plain-text capsule for an agent’s groups and skills. Text longer than 160 truncates.

import { View } from 'nsh'
import { Pill } from 'nacre'
export function PresencePills() {
return (
<View class="gap-2">
<View class="flex-row flex-wrap items-center gap-2">
<Pill kind="online" label="Online" />
<Pill kind="break" label="Break" />
<Pill kind="offline" label="Offline" />
</View>
<View class="flex-row flex-wrap items-center gap-2">
<Pill label="Hong Kong team" />
<Pill label="US stock trading" />
<Pill label="High-net-worth desk" />
</View>
</View>
)
}

On a solid primary surface, use surface=“inverse” to give the pill foreground text and a subtle foreground tint.

import { Text, View } from 'nsh'
import { Pill, TEXT_SIZE } from 'nacre'
export function PresenceInverse() {
return (
<View class="flex-row items-center gap-2">
<View class="h-7 px-2 rounded-lg bg-primary flex-row items-center gap-1.5">
<Pill testID="presence-pill-inverse" surface="inverse" label="Priority" />
<Text class={`${TEXT_SIZE.small} font-medium text-primary-foreground`}>Pending</Text>
</View>
<View class="h-7 px-2 rounded-lg border border-border flex-row items-center gap-1.5">
<Pill testID="presence-pill-default" label="Priority" />
</View>
</View>
)
}

ring enlarges the dot to 12 and adds a background-colored outline, so it sits at the bottom right as the Avatar’s badge.

import { View } from 'nsh'
import { Avatar, PresenceDot } from 'nacre'
export function PresenceOnAvatar() {
return (
<View class="flex-row items-center gap-3">
<Avatar name="Lin Jiayi" size={36} badge={<PresenceDot ring kind="online" label="Online" />} />
<Avatar name="Chen Zhiyuan" size={36} badge={<PresenceDot ring kind="break" label="Break" />} />
<Avatar name="Wang Simin" size={36} badge={<PresenceDot ring kind="offline" label="Offline" />} />
</View>
)
}
  • PresenceDot is its own screen reader node and reads its label (“Online”); give it a label even when the same text is next to it.
  • A Pill reads its text; the status dot isn’t read separately.

Do

  • Distinguish dots by shape as well as color (offline is hollow)
  • Add ring when it sits on an avatar
  • Use Pill for people, skills and groups

Don’t

  • Use it for business status (use Tag)
  • Leave a standalone dot without a label

Property descriptions follow the Chinese source comments.

Prop Type Default Description
kind * PresenceKind —
label * string — 不带文字时必须给,读屏用
ring boolean — 叠在头像上时加一圈底色描边
testID string —

* required

Prop Type Default Description
kind PresenceKind —
label * string —
surface 'default' | 'inverse' — default 白卡与 plane 上;inverse 主色实底上:前景色的淡底、前景色字
testID string —

* required