ChatReplyReference
A quoted message: the quote block inside a bubble (press to go back to the original) and the “Reply to someone: …” bar above the composer (with cancel). It only draws and reports presses; finding, scrolling to and flashing the original are the app’s job (after coss ChatReplyReference).
Status: experimental · Components: ChatReplyReference
Import
Section titled “Import”import { ChatReplyReference } from 'nacre/chat'Goes after the text inside a bubble: the author and a two-line preview; on press the app scrolls to the original and flashes it.
import { Text, View, signal } from 'nsh'import { TEXT_SIZE } from 'nacre'import { ChatBubble, ChatReplyReference, chatTextClass } from 'nacre/chat'
export function ChatReplyUsage() { const located = signal(0) return ( <View class="flex-row flex-wrap items-center gap-4"> <ChatBubble side="outgoing" first> <Text class={`${TEXT_SIZE.body} ${chatTextClass('outgoing')}`}>After the change, new trades settle in HKD</Text> <ChatReplyReference testID="demo-reply" author="Lin Jiayi" preview="Change the settlement currency in “Assets › Cash › Settlement currency”" onPress={() => located.update((n) => n + 1)} /> </ChatBubble> <Text testID="demo-reply-located" class={`${TEXT_SIZE.small} text-muted-foreground`}>{`$Located ${located()}`}</Text> </View> )}Examples
Section titled “Examples”Images, files, recalled
Section titled “Images, files, recalled”Images and videos put a thumbnail in leading with no preview; files give an icon and the file name; when the original was recalled it is disabled, and hovering says why.
Phone: Images and videos put a thumbnail in leading with no excerpt; files show an icon and file name; a recalled original is dimmed and not tappable.
import { Text, View } from 'nsh'import { Icon, TEXT_SIZE } from 'nacre'import { ChatBubble, ChatReplyReference, chatTextClass } from 'nacre/chat'
export function ChatReplyKinds() { return ( <View class="flex-row flex-wrap items-start gap-4"> <ChatBubble side="incoming" first> <Text class={`${TEXT_SIZE.body} ${chatTextClass('incoming')}`}>This one</Text> <ChatReplyReference author="Chen Zhiyuan" leading={ <View class="w-10 h-10 rounded bg-muted items-center justify-center"> <Icon name="image" size={16} color="text-tertiary" /> </View> } /> </ChatBubble> <ChatBubble side="incoming" first> <Text class={`${TEXT_SIZE.body} ${chatTextClass('incoming')}`}>Did you get the file?</Text> <ChatReplyReference leading={<Icon name="file" size={16} color="muted-foreground" />} preview="statement.pdf" /> </ChatBubble> <ChatBubble side="outgoing" first> <Text class={`${TEXT_SIZE.body} ${chatTextClass('outgoing')}`}>The original was recalled</Text> <ChatReplyReference testID="demo-reply-disabled" author="Chen Zhiyuan" preview="Add me on WeChat" disabled disabledHint="The original was recalled" onPress={() => {}} /> </ChatBubble> </View> )}The composer bar
Section titled “The composer bar”variant=“composer”: a 28pt bar with “Reply to author:” and a one-line preview; pressing the preview goes to the original, × cancels the quote.
import { View, signal } from 'nsh'import { Button } from 'nacre'import { ChatReplyReference } from 'nacre/chat'
export function ChatReplyComposer() { const quoting = signal(true) return ( <View class="w-[420px] max-w-full gap-2"> <If when={quoting()} else={<Button testID="demo-reply-again" size="xs" onPress={() => quoting.set(true)}>Quote again</Button>}> <ChatReplyReference variant="composer" testID="demo-reply-bar" prefix="Reply to" author="Chen Zhiyuan" preview="What’s the allotment rate, roughly?" onPress={() => {}} onDismiss={() => quoting.set(false)} dismissLabel="Cancel quote" /> </If> </View> )}Keyboard
Section titled “Keyboard”| Key | Action |
|---|---|
| Tab | Focus the quote block or the bar’s preview |
| Space / Return | Go to the original message |
Accessibility
Section titled “Accessibility”- The quote block reads as a button; in the composer variant the pressable area reads “Reply to author” and the cancel button reads dismissLabel.
- A recalled quote cannot be pressed; hovering says why.
Do / Don’t
Section titled “Do / Don’t”Do
- Use plain text for the preview (strip Markdown)
- On press, scroll first and flash the original once it settles
Don’t
- Put interactive content inside the quote block
- Keep it pressable when the original cannot be viewed
Property descriptions follow the Chinese source comments.
ChatReplyReference
Section titled “ChatReplyReference”| Prop | Type | Default | Description |
|---|---|---|---|
variant |
'message' | 'composer' |
— | message:气泡里被引用的原消息(点了回到原文); composer:输入区上方「回复 某人:…」条,带取消 |
author |
string |
— | 原消息作者 |
preview |
string |
— | 原消息摘要(文字、文件名);图片等用 leading 放缩略图,可不给 |
leading |
JSX.Element |
— | 摘要前的缩略图或类型图标(message 变体) |
prefix |
string |
— | composer 变体作者前的动词,如「回复」 |
disabled |
boolean |
— | 原消息不可回看(已撤回):不可点,悬停说明原因 |
disabledHint |
string |
— | |
onPress |
() => void |
— | |
onDismiss |
() => void |
— | composer 变体的取消 |
dismissLabel |
string |
— | |
accessibilityLabel |
string |
— | |
testID |
string |
— | 根节点;可点区 ${testID}-open、取消钮 ${testID}-dismiss、摘要 ${testID}-text |
class |
string |
— |
* required