生态产品多个设计器现已发布候选版本

查看生态总览
Skip to content

MessageFeed alpha ​

AI chat component. This page is the API reference, generated from the source code. Usage guidance and live examples are on the Chinese page.

Anatomy ​

Parts in bold are required.

data-scope="message-feed": root · viewport · list · item · item-label · separator · pending-indicator · scroll-to-end-trigger · unread-count · live-region

API reference ​

Descriptions of individual props, events and slots are written in Chinese and appear on the Chinese page.

Artifacts ​

LayerValue
Custom element<xh-message-feed>
Vue componentsXhMessageFeedItem XhMessageFeedItemLabel XhMessageFeedList XhMessageFeedLiveRegion XhMessageFeedPendingIndicator XhMessageFeedRoot XhMessageFeedScrollToEndTrigger XhMessageFeedSeparator XhMessageFeedUnreadCount XhMessageFeedViewport
ComposableuseMessageFeed
State machinemessageFeedMachine
Skin@xihan-ui/styles/message-feed.css

Props ​

PropTypeRequired
countnumber
statusMessageFeedStatus
thresholdnumber
loopboolean
sizeSize
translationsPartial<MessageFeedTranslations>
onStickChange(details: MessageFeedStickChangeDetails) => void
onItemFocus(details: MessageFeedItemFocusDetails) => void

Events ​

Custom elements put the payload in detail; Vue emits an event of the same name.

EventPayload
stick-changeMessageFeedStickChangeDetails
item-focusMessageFeedItemFocusDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhMessageFeedRootdefaultMessageFeedRootSlotProps

React adapter props ​

Only the props each component declares itself: DOM attributes inherited from ComponentPropsWithRef are left out, and root props already listed in the Props table are not repeated. The Vue counterpart is the slot table above.

React componentPropTypeRequired
XhMessageFeedItemitemIdstringYes
XhMessageFeedItemitemIndexnumber | stringYes
XhMessageFeedItemitemRoleMessageFeedItemRole
XhMessageFeedItemitemStreamingboolean
XhMessageFeedRootchildrenSlotChildren<MessageFeedRootSlotProps>

State ​

Public state is written to data-state.

PartValues
rootprops.status
pending-indicatorprops.status
scroll-to-end-trigger'hidden' | 'visible'

The following names are internal to the state machine.

States: idle

Events: STICK.CHANGE · SCROLL_TO_BOTTOM · ITEM.FOCUS · FEED.BLUR · PRESS.START · PRESS.END · ARRIVALS.TRACKED · TRIGGER.RENDERED

Guards: canPress

connect API ​

getXxxProps() returns the host attributes of the matching part.

MemberType
statusMessageFeedStatus
atBottomboolean
stickingboolean
focusedIdstring | null
showScrollToEndTriggerboolean
unreadCountnumber
scrollToBottom() => void
scrollToItem(id: string) => void
focusItem(id: string) => void
getRootProps() => T['element']
getViewportProps() => T['element']
getListProps() => T['element']
getItemProps(props: MessageFeedItemProps) => T['element']
getItemLabelProps(props: Pick<MessageFeedItemProps, 'id'>) => T['element']
getScrollToEndTriggerProps() => T['button']
getUnreadCountProps() => T['element']
getSeparatorProps() => T['element']
getPendingIndicatorProps() => T['element']
getLiveRegionProps() => T['element']

Accessibility ​

Keyboard ​

Specification: W3C APG. Each row is a stable behavior id that the conformance tests cover; the conditions and effects are described on the Chinese page.

KeysBehavior
PageDownmessage-feed.kbd.next
PageUpmessage-feed.kbd.prev
Control+Endmessage-feed.kbd.exit-after
Control+Homemessage-feed.kbd.exit-before
Tabmessage-feed.kbd.tab
ArrowUp / ArrowDown / Home / Endmessage-feed.kbd.scroll
Enter / Spacemessage-feed.kbd.scroll-to-end-trigger
Enter / Spacemessage-feed.kbd.press

ARIA ​

These attributes are produced by connect.

PartAttributeValue
listaria-labeltranslations.feed
listrole'feed'
itemaria-labelundefined | itemLabel(item.index + 1, count ?? -1, item.role)
itemaria-labelledbyscope.partId('message-feed', item-label:${item.id}) | undefined
itemaria-posinsetitem.index + 1
itemaria-setsizeprops.count
itemrole'article'
separatoraria-hidden'true'
pending-indicatoraria-hidden'true'
scroll-to-end-triggeraria-labeltranslations.scrollToBottomUnread(unreadCount) | translations.scrollToBottom
unread-countaria-hidden'true'
live-regionaria-atomic'true'
live-regionaria-live'polite'

Style reference ​

Skin ​

@xihan-ui/styles/message-feed.css is written against [data-scope="message-feed"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-message-feed in place of data-scope (same specificity) and sits in the xihan.components layer. Put overrides in xihan.overrides; the part selectors work as usual.

Data attributes ​

Produced by connect; valueless attributes are omitted while their condition does not hold.

PartAttributeValue
rootdata-sizeprops.size
rootdata-stateprops.status
listdata-instant'' (present only while the condition holds)
itemdata-roleitem.role
itemdata-streaming'' (present only while the condition holds)
pending-indicatordata-stateprops.status
scroll-to-end-triggerdata-pressed'' (present only while the condition holds)
scroll-to-end-triggerdata-state'hidden' | 'visible'
scroll-to-end-triggerdata-xh-action-control''
scroll-to-end-triggerdata-xh-action-display'always'
scroll-to-end-triggerdata-xh-action-profile'floating'
scroll-to-end-triggerdata-xh-action-sizefloatingSizeBelow(prop('size'))
scroll-to-end-triggerdata-xh-action-variant'ghost'
scroll-to-end-triggerdata-xh-liquid''
scroll-to-end-triggerdata-xh-material'frosted'

CSS variables ​

The public override slots, generated from what the standalone skin actually consumes.

VariablePartCSS propertyStateDefault from
--xh-message-feed-gaplistgapdefault--xh-_message-feed-gap
--xh-message-feed-icon-sizescroll-to-end-trigger--xh-icon-sizedefault--xh-_action-profile-glyph-size
--xh-message-feed-item-gapitemgapdefault--xh-space-1
--xh-message-feed-item-radiusitemborder-radiusdefault--xh-shape-surface
--xh-message-feed-label-fgitem-labelcolordefault--xh-fg-muted
--xh-message-feed-label-font-sizeitem-labelfont-sizedefault--xh-text-caption-size
--xh-message-feed-plist
pending-indicator
margin-block-end
margin-inline-start
padding
default--xh-_message-feed-p
--xh-message-feed-pending-indicator-colorpending-indicatorbackgrounddefault--xh-fg-muted
--xh-message-feed-pending-indicator-radiuspending-indicatorborder-radiusdefault--xh-shape-circle
--xh-message-feed-pending-indicator-sizepending-indicatorblock-size
inline-size
default--xh-space-2
--xh-message-feed-scroll-to-end-trigger-bgscroll-to-end-trigger--xh-ink-surface
background-color
default
disabled
focus-visible
xh-ink-surface
--xh-_material-bg
--xh-_material-bg-focus
--xh-message-feed-scroll-to-end-trigger-bg-hoverscroll-to-end-triggerbackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_material-bg-hover
--xh-message-feed-scroll-to-end-trigger-borderscroll-to-end-triggerborder
border-color
default
disabled
focus-visible
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_material-border
--xh-message-feed-scroll-to-end-trigger-fgscroll-to-end-triggercolordefault
disabled
focus-visible
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_material-fg
--xh-message-feed-scroll-to-end-trigger-insetscroll-to-end-triggerinset-block-end
inset-inline-end
default--xh-space-4
--xh-message-feed-scroll-to-end-trigger-radiusscroll-to-end-triggerborder-radiusdefault--xh-shape-circle
--xh-message-feed-scroll-to-end-trigger-shadowscroll-to-end-triggerbox-shadowdefault
disabled
focus-visible
hover
is(:active, [data-pressed])
is(:hover, [data-loading])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_material-shadow
--xh-message-feed-scroll-to-end-trigger-sizescroll-to-end-triggerblock-size
inline-size
default
xh-action-profile=floating
--xh-_action-profile-visual-size
--xh-message-feed-separator-fgseparatorcolordefault--xh-fg-subtle
--xh-message-feed-separator-font-sizeseparatorfont-sizedefault--xh-text-caption-size
--xh-message-feed-separator-gapseparatorgapdefault--xh-space-3
--xh-message-feed-separator-lineseparatorborder-block-startdefault--xh-border-subtle
--xh-message-feed-unread-count-bgunread-countbackgrounddefault--xh-bg-brand
--xh-message-feed-unread-count-fgunread-countcolordefault--xh-fg-on-brand
--xh-message-feed-unread-count-font-sizeunread-countfont-sizedefault--xh-text-caption-size
--xh-message-feed-unread-count-pxunread-countpadding-inlinedefault--xh-space-1
--xh-message-feed-unread-count-radiusunread-countborder-radiusdefault--xh-shape-pill
--xh-message-feed-unread-count-sizeunread-countblock-size
line-height
min-inline-size
default--xh-space-4

Released under The MIT License