ChatDatePill
Separators and navigation in a conversation: the date pill, a wrapping system notice, the unread divider (the unread boundary when the chat was opened) and the jump-to-latest pill (when away from the bottom or newer messages exist). How days split, where unread starts and whether pressing loads the latest page first are the app’s call (after coss ChatDatePill / ChatUnreadDivider / ChatJumpToLatestButton).
Status: experimental · Components: ChatDatePill, ChatSystemPill, ChatUnreadDivider, ChatJumpToLatestButton
Import
Section titled “Import”import { ChatDatePill, ChatSystemPill, ChatUnreadDivider, ChatJumpToLatestButton } from 'nacre/chat'ChatSystemPill wraps system notices. Place a date pill where the day changes; the unread divider sits above the first unread message, placed from a snapshot taken when the chat opened, and stays after reading. The first message after a separator starts a group without the group gap (afterSeparator).
import { Text, View } from 'nsh'import { TEXT_SIZE } from 'nacre'import { ChatBubble, ChatDatePill, ChatMessage, ChatSystemPill, ChatUnreadDivider, chatTextClass } from 'nacre/chat'
export function ChatTimelineUsage() { const line = (side: 'incoming' | 'outgoing', s: string, first = false, afterSeparator = false) => ( <ChatMessage side={side} first={first} afterSeparator={afterSeparator}> <ChatBubble side={side} first={first}> <Text class={`${TEXT_SIZE.body} ${chatTextClass(side)}`}>{s}</Text> </ChatBubble> </ChatMessage> ) return ( <View testID="demo-timeline" class="w-full max-w-[480px] pb-3 rounded-lg border border-border bg-background"> <ChatDatePill testID="demo-date" label="Yesterday" /> {line('incoming', 'When will the funds come back?', true, true)} {line('outgoing', 'Usually 1–3 business days', true)} <ChatDatePill label="Today" /> {line('incoming', 'It hasn’t arrived yet', true, true)} <ChatSystemPill testID="demo-system-pill" label="A ticket was created for the customer" /> <ChatUnreadDivider testID="demo-unread" label="New messages" /> {line('incoming', 'Could you check for me?', true, true)} {line('incoming', 'Reference T0123')} </View> )}Examples
Section titled “Examples”System notices
Section titled “System notices”System events such as ticket creation wrap within the width of the timeline.
import { View } from 'nsh'import { ChatSystemPill } from 'nacre/chat'
export function ChatTimelineNotice() { return ( <View class="w-[180px] gap-2"> <ChatSystemPill testID="demo-notice-short" label="Ticket created" /> <ChatSystemPill testID="demo-notice-long" label="A follow-up ticket was created. Support will contact the customer on the next business day." /> </View> )}Jump to latest
Section titled “Jump to latest”Shows while the reader scrolls back through history, floating at the bottom center of the conversation; with new messages it carries a count. It only fades in and out, and new arrivals never pull the reader back to the bottom.
import { Text, View, signal } from 'nsh'import { Button, TEXT_SIZE } from 'nacre'import { ChatJumpToLatestButton } from 'nacre/chat'
export function ChatTimelineJump() { const away = signal(true) const fresh = signal(3) return ( <View class="gap-2"> <View class="relative w-full max-w-[480px] h-[120px] rounded-lg border border-border bg-background items-center justify-center"> <Text class={`${TEXT_SIZE.small} text-muted-foreground`}>(Reading history)</Text> <ChatJumpToLatestButton testID="demo-jump" labelTestID="demo-jump-label" visible={away()} label="Back to latest" text={fresh() > 0 ? `${fresh()} $new messages` : undefined} onPress={() => away.set(false)} /> </View> <View class="flex-row gap-2"> <Button size="xs" testID="demo-jump-away" onPress={() => away.set(true)}> Scroll up </Button> <Button size="xs" variant="ghost" onPress={() => fresh.update((n) => n + 1)}> A new message </Button> </View> </View> )}Keyboard
Section titled “Keyboard”| Key | Action |
|---|---|
| Space / Return | On jump to latest: go to the newest message |
Accessibility
Section titled “Accessibility”- Dates and the unread divider are text and are read as is.
- Jump to latest reads its label (“Back to latest”), followed by the count.
Do / Don’t
Section titled “Do / Don’t”Do
- Let the app format the date (Today, Yesterday, 11-23)
- Snapshot the unread boundary when the chat opens
- While the reader is in history, only update the count for new messages
Don’t
- Draw a date on every message
- Remove the divider once read (the content jumps)
- Scroll to the bottom while the reader is in history
Property descriptions follow the Chinese source comments.
ChatDatePill
Section titled “ChatDatePill”| Prop | Type | Default | Description |
|---|---|---|---|
label * |
string |
— | |
testID |
string |
— |
* required
ChatSystemPill
Section titled “ChatSystemPill”| Prop | Type | Default | Description |
|---|---|---|---|
label * |
string |
— | |
class |
string |
— | |
testID |
string |
— |
* required
ChatUnreadDivider
Section titled “ChatUnreadDivider”| Prop | Type | Default | Description |
|---|---|---|---|
label * |
string |
— | |
testID |
string |
— | |
inset |
number |
16 |
* required
ChatJumpToLatestButton
Section titled “ChatJumpToLatestButton”| Prop | Type | Default | Description |
|---|---|---|---|
visible * |
boolean |
— | |
label * |
string |
— | 读屏名与悬停提示,如「回到底部」 |
text |
string |
— | 胶囊文字,如「3 条新消息」;不给时只有箭头 |
onPress * |
() => void |
— | |
testID |
string |
— | |
labelTestID |
string |
— | 胶囊文字的 testID |
* required