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

查看生态总览
Skip to content

SideNav ​

Navigation 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="side-nav": root · input · list · item · group · group-label · group-list · branch · branch-trigger · branch-text · branch-indicator · positioner · branch-content · link · link-text · empty

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-side-nav>
Vue componentsXhSideNavBranch XhSideNavBranchContent XhSideNavBranchIndicator XhSideNavBranchText XhSideNavBranchTrigger XhSideNavEmpty XhSideNavGroup XhSideNavGroupLabel XhSideNavGroupList XhSideNavInput XhSideNavItem XhSideNavLink XhSideNavLinkText XhSideNavList XhSideNavRoot XhSideNavTooltip
ComposableuseSideNav
State machinesideNavMachine
Skin@xihan-ui/styles/side-nav.css

Props ​

PropTypeRequired
collectionSideNavNode[]
valuestring | null
defaultValuestring | null
expandedValuestring[]
defaultExpandedValuestring[]
accordionboolean
collapsedboolean
collapsedPopoutboolean
disabledboolean
loopboolean
dirDirection
toneTone
sizeSize
filterSideNavFilter
translationsPartial<SideNavTranslations>
onValueChange(details: SideNavValueChangeDetails) => void
onExpandedValueChange(details: SideNavExpandedValueChangeDetails) => void

SideNavNode ​

Elements of collection.

FieldTypeRequired
valuestringYes
labelstring
disabledboolean
toneTone
hrefstring
childrenSideNavNode[]

Events ​

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

EventPayload
value-changeSideNavValueChangeDetails
expanded-value-changeSideNavExpandedValueChangeDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhSideNavRootdefaultSideNavRootSlotProps

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
XhSideNavBranchvaluestringYes
XhSideNavBranchContentcontainer() => Element | null
XhSideNavGroupvaluestringYes
XhSideNavGroupLabelvaluestringYes
XhSideNavLinkvaluestringYes
XhSideNavRootchildrenSlotChildren<SideNavRootSlotProps>
XhSideNavTooltipcontainer() => Element | null

State ​

Public state is written to data-state.

PartValues
branch'open' | 'closed'
branch-trigger'open' | 'closed'
branch-indicator'open' | 'closed'
branch-content'open' | 'closed'
popout-positioner'open' | 'closed'

The following names are internal to the state machine.

States: idle · popout

Events: VALUE.SET · LINK.SELECT · EXPANDED.SET · BRANCH.EXPAND · BRANCH.COLLAPSE · BRANCH.TOGGLE · NODE.FOCUS · FOCUS.CLEAR · POPOUT.OPEN · POPOUT.CLOSE · POPOUT.HOVER · POPOUT.HOVER_END · PRESENCE.SET · PRESS.START · PRESS.END · COLLAPSE.SETTLED · INPUT.CHANGE · TOOLTIP.TARGET · TOOLTIP.OPEN_CHANGE

Guards: canChange · canPopout · canPress

connect API ​

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

MemberType
valuestring | null
expandedValuestring[]
collapsedboolean
popoutValuestring | null
openPopout(value: string) => void
closePopout() => void
focusedValuestring | null
isSelected(value: string) => boolean
isExpanded(value: string) => boolean
isActiveBranch(value: string) => boolean
select(value: string) => void
setValue(next: string | null) => void
setExpandedValue(next: string[]) => void
expand(value: string) => void
collapse(value: string) => void
inputValuestring
setInputValue(next: string) => void
searchingboolean
emptyboolean
translationsSideNavTranslations
getRootProps() => T['element']
getListProps() => T['element']
getInputProps() => T['input']
getEmptyProps() => T['element']
getItemProps(props?: SideNavItemProps) => T['element']
getGroupProps(props: SideNavGroupProps) => T['element']
getGroupLabelProps(props: SideNavNodeProps) => T['element']
getGroupListProps(props: SideNavNodeProps) => T['element']
getBranchProps(props: SideNavNodeProps) => T['element']
getBranchTriggerProps(props: SideNavNodeProps) => T['button']
getBranchTextProps() => T['element']
getBranchIndicatorProps(props: SideNavNodeProps) => T['element']
isPopoutPanel(value: string) => boolean
getPopoutPositionerProps(props: SideNavNodeProps) => T['element']
getBranchContentProps(props: SideNavNodeProps) => T['element']
getLinkProps(props: SideNavNodeProps) => T['element']
getLinkTextProps() => T['element']
tooltipTextstring
getTooltipPositionerProps() => T['element']
getTooltipContentProps() => 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 / Spaceside-nav.kbd.press
Enter / Spaceside-nav.kbd.activate
Enterside-nav.kbd.link
ArrowDownside-nav.kbd.down
ArrowUpside-nav.kbd.up
ArrowRightside-nav.kbd.expand
ArrowLeftside-nav.kbd.collapse
Homeside-nav.kbd.home
Endside-nav.kbd.end
ArrowRight / Enter / Spaceside-nav.kbd.popout-open
ArrowLeft / Escapeside-nav.kbd.popout-close
printable charactersside-nav.kbd.search-type
ArrowDown / Enterside-nav.kbd.search-to-list
Tab / ArrowDown / ArrowUp / Home / Endside-nav.kbd.tooltip-show
Escapeside-nav.kbd.tooltip-escape
Escapeside-nav.kbd.search-escape

ARIA ​

These attributes are produced by connect.

PartAttributeValue
rootaria-labeltranslations.root
rootrole'navigation'
inputaria-controlsscope.partId('side-nav', 'list')
inputaria-labeltranslations.input
group-listaria-labelledbyid of the group-label part
branch-triggeraria-controlsid of the content part
branch-triggeraria-disabled'true' | 'false'
branch-triggeraria-expanded'true' | 'false'
branch-indicatoraria-hidden'true'
branch-contentaria-hidden!open || undefined
linkaria-current'page' | undefined
linkaria-disabled'true' | undefined
emptyrole'status'
popout-positioneraria-hidden!open || undefined
tooltip-contentaria-hidden'true'
tooltip-contentroleundefined

Style reference ​

Skin ​

@xihan-ui/styles/side-nav.css is written against [data-scope="side-nav"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-side-nav 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-animating'' (present only while the condition holds)
rootdata-collapsed'' (present only while the condition holds)
rootdata-disabled'' (present only while the condition holds)
rootdata-sizeprops.size
rootdata-toneprops.tone
inputdata-collapsed'' (present only while the condition holds)
inputdata-disabled'' (present only while the condition holds)
inputdata-xh-field-input''
listdata-collapsed'' (present only while the condition holds)
group-labeldata-collapsed'' (present only while the condition holds)
branchdata-disabled'' (present only while the condition holds)
branchdata-in-path'' (present only while the condition holds)
branchdata-state'open' | 'closed'
branch-triggerdata-disabled'' (present only while the condition holds)
branch-triggerdata-highlighted'' (present only while the condition holds)
branch-triggerdata-in-path'' (present only while the condition holds)
branch-triggerdata-pressed'' (present only while the condition holds)
branch-triggerdata-state'open' | 'closed'
branch-triggerdata-tonemetaOf(v)?.tone
branch-triggerdata-valueitemValue(el)
branch-triggerdata-xh-collection-context'page'
branch-triggerdata-xh-collection-item''
branch-triggerdata-xh-collection-sizeprops.size
branch-textdata-xh-collection-slot'text'
branch-indicatordata-state'open' | 'closed'
branch-indicatordata-xh-collection-slot'suffix'
branch-contentdata-popout''
branch-contentdata-state'open' | 'closed'
linkdata-current'' (present only while the condition holds)
linkdata-disabled'' (present only while the condition holds)
linkdata-highlighted'' (present only while the condition holds)
linkdata-pressed'' (present only while the condition holds)
linkdata-tonemetaOf(v)?.tone
linkdata-valueitemValue(el)
linkdata-xh-collection-context'page'
linkdata-xh-collection-item''
linkdata-xh-collection-sizeprops.size
link-textdata-xh-collection-slot'text'
popout-positionerdata-hidden'' (present only while the condition holds)
popout-positionerdata-placementplaced?.placement
popout-positionerdata-positioned'' (present only while the condition holds)
popout-positionerdata-sizeprops.size
popout-positionerdata-state'open' | 'closed'
popout-positionerdata-toneprops.tone

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-side-nav-branch-indicator-sizebranch-indicator--xh-icon-size
block-size
inline-size
default--xh-control-indicator-size
--xh-side-nav-collapsed-wrootinline-sizecollapsed--xh-sider-collapsed-w
--xh-side-nav-empty-fgemptycolordefault--xh-fg-muted
--xh-side-nav-empty-font-sizeemptyfont-sizedefault--xh-_side-nav-row-font-size
--xh-side-nav-empty-pxemptypadding-inlinedefault--xh-_side-nav-row-px
--xh-side-nav-empty-pyemptypadding-blockdefault--xh-space-3
--xh-side-nav-fgrootcolordefault--xh-fg-default
--xh-side-nav-gapbranch
branch-content
group
group-list
list
root
gapdefault--xh-space-1
--xh-side-nav-group-label-pxgroup-labelpadding-inlinedefault--xh-_side-nav-row-px
--xh-side-nav-group-label-pygroup-labelpadding-blockdefault--xh-space-1
--xh-side-nav-icon-sizebranch-trigger
link
positioner
root
--xh-icon-sizedefault
is([data-part='root'], [data-part='positioner'])
size=lg
size=sm
--xh-_collection-glyph-size
--xh-glyph-size-lg
--xh-glyph-size-md
--xh-glyph-size-sm
--xh-side-nav-indentbranch-contentpadding-inline-startdefault--xh-space-4
--xh-side-nav-indicator-colorbranch-trigger
link
colorcurrent
disabled
error
highlighted
hover
is(:active, [data-pressed])
is(:focus-visible, [data-highlighted])
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
pressed
xh-collection-context=page
xh-collection-slot=indicator
--xh-fg-brand
--xh-side-nav-input-autofill-bginputbox-shadow-webkit-autofill
autofill
--xh-bg-surface
--xh-side-nav-input-autofill-fginput-webkit-text-fill-color-webkit-autofill
autofill
--xh-fg-default
--xh-side-nav-input-font-sizeinputfont-sizedefault--xh-_side-nav-row-font-size
--xh-side-nav-input-hinputblock-sizedefault--xh-_side-nav-input-h
--xh-side-nav-input-pxinputpadding-inlinedefault--xh-_side-nav-row-px
--xh-side-nav-link-font-sizebranch-trigger
link
font-sizedefault--xh-_side-nav-row-font-size
--xh-side-nav-link-gapbranch-trigger
link
gapdefault--xh-_side-nav-row-gap
--xh-side-nav-link-hbranch-trigger
link
min-block-sizedefault--xh-_side-nav-row-h
--xh-side-nav-link-pxbranch-trigger
link
padding-inlinedefault--xh-_side-nav-row-px
--xh-side-nav-link-radiusbranch-trigger
link
border-radiusdefault--xh-shape-surface
--xh-side-nav-prootpaddingdefault--xh-space-2
--xh-side-nav-placeholder-fginputcolorplaceholder
xh-field-input
--xh-fg-subtle
--xh-side-nav-popout-bgbranch-contentbackgroundpopout--xh-bg-surface
--xh-side-nav-popout-borderbranch-contentborderpopout--xh-border-default
--xh-side-nav-popout-layerpositionerz-indexdefault--xh-_layer
--xh-side-nav-popout-max-hbranch-contentmax-block-sizepopout--xh-overlay-menu-max-h
--xh-side-nav-popout-max-wbranch-contentmax-inline-sizepopout--xh-overlay-max-w
--xh-side-nav-popout-min-wbranch-contentmin-inline-sizepopout--xh-overlay-menu-min-w
--xh-side-nav-popout-pbranch-contentpaddingpopout--xh-space-1
--xh-side-nav-popout-radiusbranch-contentborder-radiuspopout--xh-shape-overlay
--xh-side-nav-popout-shadowbranch-contentbox-shadowpopout--xh-elevation-floating
--xh-side-nav-row-bg-activebranch-trigger
link
background-colorcurrent
disabled
error
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
xh-collection-context=page
--xh-bg-brand-subtle
--xh-side-nav-row-bg-hoverbranch-trigger
link
background-colordisabled
error
highlighted
hover
is(:focus-visible, [data-highlighted])
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
--xh-bg-subtle
--xh-side-nav-row-bg-in-pathbranch-trigger
link
background-colorin-path--xh-bg-subtle
--xh-side-nav-row-bg-pressedbranch-trigger
link
background-colordisabled
error
is(:active, [data-pressed])
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
pressed
--xh-bg-subtle-hover
--xh-side-nav-row-fgbranch-trigger
link
colordefault
disabled
error
highlighted
hover
in-path
is(:active, [data-pressed])
is(:focus-visible, [data-highlighted])
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
pressed
currentColor
--xh-side-nav-row-fg-activebranch-trigger
link
colorcurrent
disabled
error
highlighted
hover
is(:active, [data-pressed])
is(:focus-visible, [data-highlighted])
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
pressed
xh-collection-context=page
--xh-fg-on-brand-subtle
--xh-side-nav-row-fg-in-pathbranch-trigger
link
colorin-path--xh-side-nav-row-fg
--xh-side-nav-row-font-weight-activebranch-trigger
link
font-weightcurrent
disabled
error
highlighted
hover
is(:active, [data-pressed])
is(:focus-visible, [data-highlighted])
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
pressed
xh-collection-context=page
--xh-font-weight-semibold
--xh-side-nav-search-dividerinputborder-block-enddefault--xh-material-solid-separator
--xh-side-nav-wrootinline-sizedefault--xh-sider-w

Released under The MIT License