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

查看生态总览
Skip to content

Typography ​

General 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="typography": root · heading · paragraph · text · link · prose

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-typography>
Vue componentsXhTypographyHeading XhTypographyLink XhTypographyParagraph XhTypographyProse XhTypographyRoot XhTypographyText
State machineNone: connect computes attributes from props directly
Skin@xihan-ui/styles/typography.css

Props ​

PropTypeRequired
alignTypographyAlign
sizeSize
weightTypographyWeight

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
XhTypographyHeadinglevelTypographyLevel | string
XhTypographyHeadingasElementType
XhTypographyProseasElementType
XhTypographyTexttoneTone
XhTypographyTextvariantTypographyVariant
XhTypographyTextweightTypographyWeight
XhTypographyTextstrikethroughboolean
XhTypographyTextunderlineboolean
XhTypographyTextmarkboolean
XhTypographyTextasElementType

connect API ​

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

MemberType
getRootProps() => T['element']
getHeadingProps(props?: TypographyHeadingProps) => T['element']
getParagraphProps() => T['element']
getTextProps(props?: TypographyTextProps) => T['element']
getLinkProps() => T['element']
getProseProps() => 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.

No keyboard interaction: the component takes no focus, or focus behavior comes entirely from native elements.

Style reference ​

Skin ​

@xihan-ui/styles/typography.css is written against [data-scope="typography"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-typography 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-alignprops.align
rootdata-sizeprops.size
rootdata-weightprops.weight
headingdata-levellevelAttr(heading.level)
textdata-marked'' (present only while the condition holds)
textdata-strikethrough'' (present only while the condition holds)
textdata-tonetext.tone
textdata-underline'' (present only while the condition holds)
textdata-varianttext.variant
textdata-weighttext.weight

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-typography-block-gapheading
paragraph
margin-block-startis([data-part='heading'], [data-part='paragraph'])--xh-_typography-block-gap
--xh-typography-code-bgprose
text
backgroundvariant=code
where(code)
--xh-bg-subtle
--xh-typography-code-fgprose
text
colorvariant=code
where(code)
--xh-fg-muted
--xh-typography-code-fontprose
text
font-familyvariant=code
where(code)
where(pre)
--xh-font-family-mono
--xh-typography-code-font-sizeprose
text
font-sizevariant=code
where(code)
where(pre)
--xh-_typography-code-size
--xh-typography-code-pxprose
text
padding-inlinevariant=code
where(code)
--xh-space-2
--xh-typography-code-pyprose
text
padding-blockvariant=code
where(code)
--xh-space-0_5
--xh-typography-code-radiusprose
text
border-radiusvariant=code
where(code)
--xh-shape-inset
--xh-typography-fgrootcolordefault--xh-fg-default
--xh-typography-font-sizerootfont-sizedefault--xh-_typography-body-size
--xh-typography-font-weightrootfont-weightdefault
weight=bold
weight=medium
weight=regular
weight=semibold
--xh-font-weight-bold
--xh-font-weight-medium
--xh-font-weight-regular
--xh-font-weight-semibold
--xh-text-body-weight
--xh-typography-gradient-directiontextbackground-imagevariant=gradientto right
--xh-typography-gradient-fromtextbackground-imagevariant=gradient--xh-_typography-gradient-from
--xh-typography-gradient-totextbackground-imagevariant=gradient--xh-_typography-gradient-to
--xh-typography-heading-fgheadingcolordefault--xh-fg-default
--xh-typography-heading-font-sizeheadingfont-sizedefault
level=1
level=2
level=3
level=4
level=5
level=6
--xh-_typography-h1
--xh-_typography-h2
--xh-_typography-h3
--xh-_typography-h4
--xh-_typography-h5
--xh-_typography-h6
--xh-typography-heading-font-weightheadingfont-weightdefault--xh-font-weight-medium
--xh-typography-heading-gapheading
paragraph
margin-block-startis([data-part='heading'], [data-part='paragraph'])--xh-_typography-heading-gap
--xh-typography-heading-leadingheadingline-heightdefault--xh-leading-tight
--xh-typography-leadingrootline-heightdefault--xh-text-body-leading
--xh-typography-link-fglink
prose
colordefault
where(a)
--xh-fg-brand
--xh-typography-link-fg-hoverlinkcolor@media (hover: hover)
hover
--xh-fg-brand-strong
--xh-typography-link-radiuslink
prose
border-radiusdefault
where(a)
--xh-shape-inset
--xh-typography-link-underline-offsetlink
prose
text-underline-offsetdefault
where(a)
--xh-space-0_5
--xh-typography-mark-bgtextbackgroundmarked
tone
--xh-_tone-subtle
--xh-bg-mark
--xh-typography-mark-fgtextcolormarked
tone
--xh-_tone-fg
--xh-fg-default
--xh-typography-mark-pxtextpadding-inlinemarked--xh-space-0_5
--xh-typography-mark-radiustextborder-radiusmarked--xh-shape-inset
--xh-typography-measurerootmax-inline-sizedefault--xh-_typography-measure
--xh-typography-prose-block-gapprosemargin-block-startwhere(h1, h2, h3, h4, h5, h6, p, ul, ol, pre, blockquote, table, hr)--xh-_typography-block-gap
--xh-typography-prose-cell-borderproseborder-block-endwhere(th, td)--xh-border-subtle
--xh-typography-prose-cell-pxprosepadding-inlinewhere(th, td)--xh-space-3
--xh-typography-prose-cell-pyprosepadding-blockwhere(th, td)--xh-space-2
--xh-typography-prose-fgprosecolordefault--xh-fg-default
--xh-typography-prose-font-sizeprosefont-sizedefault--xh-_typography-body-size
--xh-typography-prose-h1prosefont-sizewhere(h1)--xh-_typography-h1
--xh-typography-prose-h2prosefont-sizewhere(h2)--xh-_typography-h2
--xh-typography-prose-h3prosefont-sizewhere(h3)--xh-_typography-h3
--xh-typography-prose-h4prosefont-sizewhere(h4)--xh-_typography-h4
--xh-typography-prose-h5prosefont-sizewhere(h5)--xh-_typography-h5
--xh-typography-prose-h6prosefont-sizewhere(h6)--xh-_typography-h6
--xh-typography-prose-heading-fgprosecolorwhere(h1, h2, h3, h4, h5, h6)--xh-fg-default
--xh-typography-prose-heading-font-weightprosefont-weightwhere(h1, h2, h3, h4, h5, h6)--xh-font-weight-medium
--xh-typography-prose-heading-gapprosemargin-block-startwhere(h1, h2, h3, h4, h5, h6)
where(h1, h2, h3, h4, h5, h6, p, ul, ol, pre, blockquote, table, hr)
--xh-_typography-heading-gap
--xh-typography-prose-item-gapprosemargin-block-startwhere(li + li)
where(li)
where(ul, ol)
--xh-space-1
--xh-typography-prose-leadingproseline-heightdefault--xh-text-prose-leading
--xh-typography-prose-link-fgprosecolorwhere(a)--xh-typography-link-fg
--xh-typography-prose-link-radiusproseborder-radiuswhere(a)--xh-typography-link-radius
--xh-typography-prose-link-underline-offsetprosetext-underline-offsetwhere(a)--xh-typography-link-underline-offset
--xh-typography-prose-list-psprosepadding-inline-startwhere(ul, ol)--xh-space-5
--xh-typography-prose-pre-bgprosebackgroundwhere(pre)--xh-bg-subtle
--xh-typography-prose-pre-paddingprosepaddingwhere(pre)--xh-space-4
--xh-typography-prose-pre-radiusproseborder-radiuswhere(pre)--xh-shape-surface
--xh-typography-prose-quote-borderproseborder-inline-startwhere(blockquote)--xh-border-strong
--xh-typography-prose-quote-fgprosecolorwhere(blockquote)inherit
--xh-typography-prose-quote-psprosepadding-inline-startwhere(blockquote)--xh-space-2
--xh-typography-prose-rule-borderproseborder-block-startwhere(hr)--xh-border-subtle
--xh-typography-prose-strong-font-weightprosefont-weightwhere(strong)--xh-font-weight-medium
--xh-typography-prose-th-font-weightprosefont-weightwhere(th)--xh-font-weight-semibold
--xh-typography-text-fg-mutedtextcolorvariant=muted--xh-fg-muted
--xh-typography-text-fg-tonetextcolortone--xh-_tone-fg
--xh-typography-text-font-weighttextfont-weightvariant=strong--xh-font-weight-medium
--xh-typography-text-underline-offsettexttext-underline-offsetunderline--xh-space-0_5

Released under The MIT License