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

查看生态总览
Skip to content

Citation 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="citation": root · text · trigger · positioner · preview · preview-header · preview-title · preview-meta · quote · preview-link · dismiss-trigger · prev-trigger · next-trigger · preview-index · list · source · source-link · source-index · source-title · source-meta

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-citation>
Vue componentsXhCitationList XhCitationPositioner XhCitationPreview XhCitationRoot XhCitationSource XhCitationSourceIndex XhCitationSourceLink XhCitationSourceMeta XhCitationSourceTitle XhCitationText XhCitationTrigger
ComposableuseCitation
State machinecitationMachine
Skin@xihan-ui/styles/citation.css

Props ​

PropTypeRequired
previewModeCitationPreviewMode
openDelaynumber
closeDelaynumber
skipDelayDurationnumber
placementPlacement
offsetnumber
sourcesreadonly CitationSource[]
activeSourceIdstring | null
defaultActiveSourceIdstring | null
openboolean
defaultOpenboolean
disabledboolean
loopboolean
dirDirection
sizeSize
translationsPartial<CitationTranslations>
onActiveSourceChange(details: CitationActiveSourceChangeDetails) => void
onOpenChange(details: CitationOpenChangeDetails) => void
onSourceOpen(details: CitationSourceOpenDetails) => void

Events ​

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

EventPayload
active-source-changeCitationActiveSourceChangeDetails
open-changeCitationOpenChangeDetails
source-openCitationSourceOpenDetails

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
XhCitationPositionercontainerPortalContainer
XhCitationPreviewsourceIdstringYes
XhCitationPreviewanchorIndexnumber
XhCitationRootchildrenReactNode
XhCitationSourcesourceIdstringYes
XhCitationSourcedisabledboolean
XhCitationTriggersourceIdstring
XhCitationTriggersourceIdsreadonly string[]
XhCitationTriggercitationIdstring
XhCitationTriggeranchorIndexnumber

State ​

Public state is written to data-state.

PartValues
trigger'open' | 'closed'
positioner'open' | 'closed'
preview'open' | 'closed'
source'active' | 'inactive'
source-link'active' | 'inactive'

The following names are internal to the state machine.

States: idle · opening · closing

Events: CITATION.ACTIVATE · TRIGGER.ENTER · POINTER.LEAVE · FLOATING.ENTER · TRIGGER.FOCUS · FLOATING.FOCUS · HOVER.BLUR · after.openDelay · after.closeDelay · GROUP.STEP · DISMISS · SOURCE.ACTIVATE · SOURCE.OPEN · SOURCE.FOCUS · LIST.BLUR · OPEN.SET · PREVIEW.MEASURED · PREVIEW.LEFT

Guards: isHoverMode · isVisible · isWarm · isFocusHeld · isSameTarget

connect API ​

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

MemberType
sourcesreadonly CitationSource[]
activeSourceCitationSource | null
activeSourceIdstring | null
activeAnchorIndexnumber | null
activeGroupreadonly string[] | null
previewModeCitationPreviewMode
openboolean
focusedSourceIdstring | null
setOpen(next: boolean) => void
setActiveSource(sourceId: string) => void
getRootProps() => T['element']
getTextProps() => T['element']
getTriggerProps(props: CitationTriggerProps) => T['button']
getPositionerProps() => T['element']
getPreviewProps(props: CitationPreviewProps) => T['element']
getPreviewHeaderProps(props: CitationPreviewProps) => T['element']
getPreviewTitleProps(props: CitationPreviewProps) => T['element']
getPreviewMetaProps(props: CitationPreviewProps) => T['element']
getQuoteProps(props: CitationPreviewProps) => T['element']
getPreviewLinkProps(props: CitationPreviewProps) => T['element']
sourceMetaText(source: CitationSource | undefined) => string
previewLinkText(props: CitationPreviewProps) => string
getDismissTriggerProps(props: CitationPreviewProps) => T['button']
getPrevTriggerProps(props: CitationPreviewProps) => T['button']
getNextTriggerProps(props: CitationPreviewProps) => T['button']
getPreviewIndexProps(props: CitationPreviewProps) => T['element']
getPreviewPosition(props: CitationPreviewProps) => { index: number, total: number } | null
getListProps() => T['element']
getSourceProps(props: CitationSourceItemProps) => T['element']
getSourceLinkProps(props: CitationSourceItemProps) => T['button']
getSourceIndexProps(props: CitationSourceItemProps) => T['element']
getSourceTitleProps(props: CitationSourceItemProps) => T['element']
getSourceMetaProps(props: CitationSourceItemProps) => T['element']

Accessibility ​

Keyboard ​

Specification: [W3C APG](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/#keyboardinteraction https://www.w3.org/WAI/ARIA/apg/patterns/listbox/#keyboardinteraction). Each row is a stable behavior id that the conformance tests cover; the conditions and effects are described on the Chinese page.

KeysBehavior
Space / Entercitation.kbd.trigger
ArrowDowncitation.kbd.next
ArrowUpcitation.kbd.prev
Homecitation.kbd.first
Endcitation.kbd.last
Space / Entercitation.kbd.open
Tabcitation.kbd.hover-focus
Space / Entercitation.kbd.step
Escapecitation.kbd.escape

ARIA ​

These attributes are produced by connect.

PartAttributeValue
triggeraria-controlsid of the preview part
triggeraria-expanded'true' | 'false'
triggeraria-labellabels.citations(ids.map(sourceId => indexOf(sourceId… | labels.citation(indexOf(ids[0]!) + 1, citationSourceT…
previewaria-labellabels.preview | undefined
previewaria-labelledbycontext.get('activeTriggerId') | undefined
previewrole'region'
preview-linkaria-labelledbyid of the preview-link part id of the preview-title part
dismiss-triggeraria-labellabels.closePreview
preview-indexaria-hidden'true'
listaria-labellabels.sources
listrole'list'
sourcerole'listitem'
source-linkaria-controlsid of the preview part
source-linkaria-current'true' | undefined
source-linkaria-expanded'true' | 'false'
source-indexaria-hidden'true'

Style reference ​

Skin ​

@xihan-ui/styles/citation.css is written against [data-scope="citation"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-citation in place of data-scope (same specificity) and sits in the xihan.components and xihan.motion layers. 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-disabled'' (present only while the condition holds)
rootdata-preview-modeprops.previewMode
rootdata-sizeprops.size
triggerdata-disabled'' (present only while the condition holds)
triggerdata-state'open' | 'closed'
triggerdata-xh-action-control''
triggerdata-xh-action-display'always'
triggerdata-xh-action-profile'text'
triggerdata-xh-action-size'xs'
triggerdata-xh-action-variant'subtle'
positionerdata-hidden'' (present only while the condition holds)
positionerdata-placementactual placement computed by the positioning engine | undefined
positionerdata-positioned'' (present only while the condition holds)
positionerdata-preview-modeprops.previewMode
positionerdata-sizeprops.size
positionerdata-state'open' | 'closed'
previewdata-instant'' (present only while the condition holds)
previewdata-preview-modeprops.previewMode
previewdata-state'open' | 'closed'
previewdata-xh-material'frosted' | undefined
preview-linkdata-xh-action-control''
preview-linkdata-xh-action-display'always' | undefined
preview-linkdata-xh-action-profile'text' | undefined
preview-linkdata-xh-action-size'sm' | undefined
preview-linkdata-xh-action-variant'ghost' | undefined
dismiss-triggerdata-xh-action-control''
dismiss-triggerdata-xh-action-display'always'
dismiss-triggerdata-xh-action-profile'icon'
dismiss-triggerdata-xh-action-size'xs'
dismiss-triggerdata-xh-action-variant'ghost'
listdata-disabled'' (present only while the condition holds)
sourcedata-disabled'' (present only while the condition holds)
sourcedata-state'active' | 'inactive'
source-linkdata-current'' (present only while the condition holds)
source-linkdata-disabled'' (present only while the condition holds)
source-linkdata-state'active' | 'inactive'
source-linkdata-xh-action-control''
source-linkdata-xh-action-display'always'
source-linkdata-xh-action-profile'row'
source-linkdata-xh-action-sizeprops.size
source-linkdata-xh-action-variant'ghost'

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-citation-card-backdroppreview-webkit-backdrop-filter
backdrop-filter
preview-mode=hover
xh-material=frosted
--xh-_material-backdrop
--xh-citation-card-bgpreviewbackgroundnot([data-xh-action-control])
preview-mode=hover
xh-material=frosted
--xh-_material-bg
--xh-citation-card-borderpreviewbordernot([data-xh-action-control])
preview-mode=hover
xh-material=frosted
--xh-_material-border
--xh-citation-card-fgpreviewcolornot([data-xh-action-control])
preview-mode=hover
xh-material=frosted
--xh-_material-fg
--xh-citation-card-max-hpreviewmax-block-sizepreview-mode=hover--xh-overlay-max-h
--xh-citation-card-max-wpreviewmax-inline-sizepreview-mode=hover--xh-overlay-max-w
--xh-citation-card-quote-linespreview
quote
-webkit-line-clampnot([hidden])
preview-mode=hover
6
--xh-citation-card-radiuspreviewborder-radiuspreview-mode=hover--xh-shape-overlay
--xh-citation-card-shadowpreviewbox-shadownot([data-xh-action-control])
preview-mode=hover
xh-material=frosted
--xh-_material-shadow
--xh-citation-dismiss-trigger-radiusdismiss-triggerborder-radiusdefault--xh-shape-control
--xh-citation-fgrootcolordefault--xh-fg-default
--xh-citation-font-sizepositioner
root
font-sizedefault
preview-mode=hover
--xh-_citation-font-size
--xh-citation-gappreview
root
gap
margin-block-start
@keyframes xh-citation-preview-collapse
@keyframes xh-citation-preview-expand
default
not([data-xh-material])
xh-material
--xh-_citation-gap
--xh-citation-icon-sizepositioner
root
--xh-icon-sizeis([data-part='root'], [data-part='positioner'])--xh-_citation-icon-size
--xh-citation-index-active-bgsource
source-index
backgroundstate=active--xh-bg-brand
--xh-citation-index-active-fgsource
source-index
colorstate=active--xh-fg-on-brand
--xh-citation-index-bgsource-indexbackgrounddefault--xh-bg-subtle
--xh-citation-index-fgsource-indexcolordefault--xh-fg-muted
--xh-citation-index-font-sizesource-indexfont-sizedefault--xh-text-caption-size
--xh-citation-index-radiussource-indexborder-radiusdefault--xh-shape-circle
--xh-citation-index-sizesource-indexblock-size
min-inline-size
default--xh-control-box-sm
--xh-citation-layerpositionerz-indexpreview-mode=hover--xh-_layer
--xh-citation-link-fgpreview-linkcolordefault--xh-fg-brand
--xh-citation-list-gaplistgapdefault--xh-space-1
--xh-citation-meta-fgpreview-index
preview-meta
source-meta
colordefault--xh-fg-muted
--xh-citation-meta-font-sizepreview-index
preview-meta
source-meta
font-sizedefault--xh-text-caption-size
--xh-citation-pager-radiusnext-trigger
prev-trigger
border-radiusdefault--xh-shape-control
--xh-citation-preview-bgpreviewbackgroundnot([data-xh-material])
xh-material
--xh-bg-surface
--xh-citation-preview-borderpreviewbordernot([data-xh-material])
xh-material
--xh-border-default
--xh-citation-preview-fgpreviewcolornot([data-xh-material])
xh-material
--xh-fg-default
--xh-citation-preview-gappreviewgapdefault--xh-space-3
--xh-citation-preview-header-content-gappreview-headergapfirst-child--xh-space-0_5
--xh-citation-preview-header-gappreview-headergapdefault--xh-space-3
--xh-citation-preview-link-radiuspreview-linkborder-radiusfocus-visible--xh-shape-control
--xh-citation-preview-pxpreviewpadding-inlinedefault--xh-_citation-pad
--xh-citation-preview-pypreviewpadding-blockdefault--xh-_citation-pad
--xh-citation-preview-radiuspreviewborder-radiusnot([data-xh-material])
xh-material
--xh-shape-surface
--xh-citation-quote-borderquoteborder-inline-startdefault--xh-fg-brand
--xh-citation-quote-fgquotecolordefault--xh-fg-muted
--xh-citation-quote-font-sizequotefont-sizedefault--xh-text-secondary-size
--xh-citation-quote-psquotepadding-inline-startdefault--xh-space-3
--xh-citation-source-fgsource-linkcolordefault--xh-fg-default
--xh-citation-source-link-content-gapsource-linkgaplast-child--xh-space-0_5
--xh-citation-source-pxsource-linkpadding-inlinedefault--xh-space-3
--xh-citation-source-pysource-linkpadding-blockxh-action-profile=row--xh-space-2
--xh-citation-source-radiussource-linkborder-radiusdefault--xh-shape-control
--xh-citation-source-title-fgsource-titlecolordefault--xh-fg-default
--xh-citation-text-fgtextcolordefault--xh-fg-default
--xh-citation-title-fgpreview-titlecolordefault--xh-fg-default
--xh-citation-title-font-sizepreview-titlefont-sizedefault--xh-text-label-size
--xh-citation-title-font-weightpreview-titlefont-weightdefault--xh-font-weight-medium
--xh-citation-trigger-fgtriggercolordefault
disabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-fg-brand
--xh-citation-trigger-font-sizetriggerfont-sizedefault--xh-text-caption-size
--xh-citation-trigger-htriggerblock-size
inline-size
min-block-size
min-inline-size
default
xh-action-profile=icon
xh-action-profile=row
--xh-space-6
--xh-citation-trigger-margintriggermargin-inlinedefault--xh-space-0_5
--xh-citation-trigger-pxtriggerpadding-inlinedefault--xh-space-1
--xh-citation-trigger-radiustriggerborder-radiusdefault--xh-shape-pill

Released under The MIT License