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

查看生态总览
Skip to content

Card ​

Data display 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="card": root · header · title · trigger · description · content · footer

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-card>
Vue componentsXhCardContent XhCardDescription XhCardFooter XhCardHeader XhCardRoot XhCardTitle XhCardTrigger
State machineNone: connect computes attributes from props directly
Skin@xihan-ui/styles/card.css

Props ​

PropTypeRequired
interactiveboolean
variantControlVariant

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhCardRootdefault—
XhCardRoottitle—
XhCardRootdescription—
XhCardRootcontent—
XhCardRootfooter—

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
XhCardRoottitleReactNode
XhCardRootdescriptionReactNode
XhCardRootcontentReactNode
XhCardRootfooterReactNode

connect API ​

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

MemberType
getRootProps() => T['element']
getHeaderProps() => T['element']
getTitleProps() => T['element']
getTriggerProps() => T['element']
getDescriptionProps() => T['element']
getContentProps() => T['element']
getFooterProps() => 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
Enter / Spacecard.kbd.activate

Style reference ​

Skin ​

@xihan-ui/styles/card.css is written against [data-scope="card"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-card 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.

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-card-bgrootbackgrounddefault
variant=subtle
--xh-bg-subtle
--xh-bg-surface
--xh-card-bg-hoverrootbackgroundhover
interactive
variant=ghost
variant=subtle
--xh-_card-host-bg-hover
--xh-bg-subtle
--xh-card-bg-pressedrootbackgroundactive
interactive
not(:has([data-scope='card'][data-part='footer']:active)
variant=ghost
variant=outline
variant=subtle
--xh-_card-host-bg-pressed
--xh-bg-subtle-hover
--xh-bg-subtle-hover-opaque
--xh-card-borderrootborderdefault--xh-border-default
--xh-card-content-fgcontentcolordefault--xh-fg-muted
--xh-card-content-font-sizecontentfont-sizedefault--xh-text-body-size
--xh-card-content-gapcontentgapdefault--xh-space-1
--xh-card-description-fgdescriptioncolordefault--xh-fg-muted
--xh-card-description-font-sizedescriptionfont-sizedefault--xh-text-secondary-size
--xh-card-description-leadingdescriptionline-heightdefault--xh-leading-normal
--xh-card-fgrootcolordefault--xh-fg-default
--xh-card-font-sizerootfont-sizedefault--xh-text-label-size
--xh-card-footer-gapfootergapdefault--xh-space-2
--xh-card-gaprootgapdefault0
--xh-card-glint-durationrootanimation@media (hover: hover) and (pointer: fine) and (forced-colors: none)
hover
interactive
material=liquid
where([data-material='liquid'])
--xh-motion-duration-glint
--xh-card-header-borderheader
root
border-block-enddefault--xh-border-subtle
--xh-card-header-hheader
root
min-block-sizedefault--xh-surface-header-h
--xh-card-header-pyheader
root
padding-blockdefault--xh-space-2
--xh-card-leadingrootline-heightdefault--xh-text-body-leading
--xh-card-pcontent
footer
header
root
padding
padding-block-end
padding-inline
default--xh-space-4
--xh-surface-pad-lg
--xh-card-radiusroot
trigger
border-radiusdefault
interactive
--xh-shape-surface
--xh-card-shadowrootbox-shadowdefault
variant=ghost
variant=subtle
--xh-elevation-raised
none
--xh-card-shadow-hoverrootbox-shadowhover
interactive
variant=outline
--xh-elevation-lifted
--xh-card-title-fgtitlecolordefault--xh-fg-default
--xh-card-title-font-sizetitlefont-sizedefault--xh-text-heading-3-size
--xh-card-title-font-weighttitlefont-weightdefault--xh-text-heading-3-weight
--xh-card-title-leadingtitleline-heightdefault--xh-leading-tight

Released under The MIT License