Skip to content
Nacre
Color palette
中文

Softphone and CallStatusCard

experimentalCallStatusCard · CallPanelHeaderOpen in playground
CallStatusCard
Runs the real component in your browser.

A sidebar hotline card and a header for incoming calls and dialing panels. Only ringing tints the card. A connected call and the panel title use neutral surfaces.

Status: experimental · Components: CallStatusCard, CallPanelHeader

import { CallStatusCard, CallPanelHeader } from 'nacre/call'

Switch between offline, idle, ringing and connected. Answer or end the call using the card actions.

import { Text, View, signal } from 'nsh'
import { Button, Segmented, ToolbarButton, TEXT_SIZE } from 'nacre'
import { CallStatusCard } from 'nacre/call'
import type { CallStatusCardProps } from 'nacre/call'
export function CallStatusCardUsage() {
const phase = signal<CallStatusCardProps['phase']>('connected')
const muted = signal(false)
const hotline = 'Hong Kong hotline'
const labels = {
offline: 'Offline', idle: 'Idle',
ringing: 'Ringing', connected: 'Connected',
}
return (
<View class="items-start gap-3">
<Segmented accessibilityLabel="Call state" value={phase()}
onChange={(value) => { phase.set(value); muted.set(false) }}
options={(Object.keys(labels) as (keyof typeof labels)[]).map((value) => ({ value, label: labels[value] }))} />
<View class="w-60">
<CallStatusCard testID="demo-hotline" phase={phase()} hotline={hotline} accessibilityLabel={hotline}
headerEnd={<Text class={`flex-1 text-right ${TEXT_SIZE.small} text-muted-foreground`}>{labels[phase()]}</Text>}>
<If when={phase() === 'connected' || phase() === 'ringing'}>
<Text class={`${TEXT_SIZE.title} text-foreground`}>+852 5555 0123</Text>
<If when={phase() === 'connected'} else={<Button variant="primary" size="sm" onPress={() => phase.set('connected')}>Answer</Button>}>
<Text class={`${TEXT_SIZE.small} text-muted-foreground tabular-nums`}>01:05</Text>
<ToolbarButton variant="control" icon="headset" label={muted() ? 'Unmute' : 'Mute'}
pressed={muted()} onPress={() => muted.set(!muted())} />
<Button testID="demo-hotline-end" variant="primary" tone="danger" size="sm" onPress={() => { phase.set('idle'); muted.set(false) }}>End call</Button>
</If>
</If>
</CallStatusCard>
</View>
</View>
)
}

Show a title and hotline for incoming calls, or a caller ID and close action on the dialer. The header shares the panel surface.

import { Text, View, signal } from 'nsh'
import { Button, Icon, IconButton, TEXT_SIZE } from 'nacre'
import { CallPanelHeader } from 'nacre/call'
export function CallPanelHeaderExample() {
const hotline = 'Hong Kong hotline'
const dialer = signal(true)
return (
<View class="flex-row flex-wrap gap-3">
<View class="w-64 rounded-lg border border-border bg-popover overflow-hidden">
<CallPanelHeader testID="demo-incoming-header" title="Incoming call" meta={hotline}
icon={(glyph) => <Icon name="phone" size={glyph.size} color={glyph.color} />} />
<Text class={`px-4 py-3 ${TEXT_SIZE.body} text-popover-foreground`}>+852 5555 0123</Text>
</View>
<If when={dialer()} else={<Button size="sm" onPress={() => dialer.set(true)}>Open dialer</Button>}>
<View class="w-64 rounded-lg border border-border bg-popover overflow-hidden">
<CallPanelHeader title={hotline} subtitle="+852 5555 0100"
actions={<IconButton icon="close" label="Close" onPress={() => dialer.set(false)} />} />
</View>
</If>
</View>
)
}
Key Action
Tab Move to the next action in the card
  • Use text, icons and actions to convey call state.
  • Give the card and each action an accessible name.

Do

  • Handle call events and timekeeping in the application
  • Place dialer and seat controls in headerEnd

Don’t

  • Use a full brand fill for a connected call or panel header

Property descriptions follow the Chinese source comments.

Prop Type Default Description
phase * 'offline' | 'idle' | 'ringing' | 'connected' —
hotline * string —
icon IconRender — 线路图标;默认电话听筒,图标是装饰,状态由卡内文案说明。
headerEnd JSX.Element — 线路名右侧的坐席状态、拨号盘和开关。
children JSX.Element — 卡内放坐席、联系人、计时、操作和告警。
accessibilityLabel string —
viewRef (node: ViewRef) => void —
obscured boolean —
testID string —

* required

Prop Type Default Description
title * string —
subtitle string —
meta string —
icon IconRender —
actions JSX.Element —
testID string —
subtitleTestID string —

* required