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

查看生态总览
Skip to content

Toolbar ​

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="toolbar": root · group · item · separator · overflow-trigger

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-toolbar>
Vue componentsXhToolbarGroup XhToolbarItem XhToolbarOverflowTrigger XhToolbarRoot XhToolbarSeparator
ComposableuseToolbar
State machinetoolbarMachine
Skin@xihan-ui/styles/toolbar.css

Props ​

PropTypeRequired
orientationOrientation
dirDirection
loopboolean
disabledboolean
variantControlVariant
sizeSize
translationsPartial<ToolbarTranslations>
itemIconsReadonly<Record<string, IconRecord>>

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhToolbarRootdefaultToolbarRootSlotProps

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
XhToolbarItemvaluestringYes
XhToolbarItemdisabledboolean
XhToolbarItemiconOnlyboolean
XhToolbarItemasElementType
XhToolbarRootchildrenSlotChildren<ToolbarRootSlotProps>

State ​

The following names are internal to the state machine.

States: idle

Events: ITEM.FOCUS · OVERFLOW_TRIGGER.FOCUS · TOOLBAR.BLUR · PRESS.START · PRESS.END · OVERFLOW.SELECT

Guards: canPress

connect API ​

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

MemberType
focusedValuestring | null
orientationOrientation
separatorOrientationOrientation
disabledboolean
overflowItemsreadonly ToolbarOverflowItem[]
getRootProps() => T['element']
getGroupProps() => T['element']
getItemProps(props: ToolbarItemProps) => T['element']
getSeparatorProps() => T['element']
getOverflowTriggerProps() => T['button']

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
Tab / Shift+Tabtoolbar.kbd.tab
ArrowRight / ArrowDowntoolbar.kbd.next
ArrowLeft / ArrowUptoolbar.kbd.prev
Hometoolbar.kbd.first
Endtoolbar.kbd.last
Enter / Spacetoolbar.kbd.press
Enter / Space / ArrowDown / ArrowUptoolbar.kbd.overflow-open
Escapetoolbar.kbd.overflow-close
both arrow keys of the cross axistoolbar.kbd.cross-axis

ARIA ​

These attributes are produced by connect.

PartAttributeValue
rootaria-disabled'true' | 'false'
rootaria-orientationprops.orientation
rootrole'toolbar'
grouprole'group'
itemaria-disabled'true' | 'false'
separatoraria-orientation'vertical' | 'horizontal'
separatorrole'separator'
overflow-triggeraria-disabled'true' | 'false'
overflow-triggeraria-labelresolveTranslations(TOOLBAR_EN_US, prop('translations…

Style reference ​

Skin ​

@xihan-ui/styles/toolbar.css is written against [data-scope="toolbar"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-toolbar 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-disabled'' (present only while the condition holds)
rootdata-orientationprops.orientation
rootdata-sizeprops.size
rootdata-variantprops.variant
groupdata-disabled'' (present only while the condition holds)
groupdata-orientationprops.orientation
itemdata-disabled'' (present only while the condition holds)
itemdata-icon-only'' (present only while the condition holds)
itemdata-pressed'' (present only while the condition holds)
itemdata-xh-action-control''
itemdata-xh-action-display'always'
itemdata-xh-action-profile'icon' | 'text'
itemdata-xh-action-sizeprops.size
itemdata-xh-action-variant'ghost'
separatordata-orientation'vertical' | 'horizontal'
overflow-triggerdata-disabled'' (present only while the condition holds)
overflow-triggerdata-xh-action-control''
overflow-triggerdata-xh-action-display'always'
overflow-triggerdata-xh-action-profile'icon'
overflow-triggerdata-xh-action-sizeprops.size
overflow-triggerdata-xh-action-variant'ghost'

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-toolbar-bgrootbackgrounddefault--xh-_toolbar-root-bg
--xh-toolbar-bg-disabledrootbackgrounddisabled--xh-_toolbar-root-bg-disabled
--xh-toolbar-borderrootborderdefault--xh-_toolbar-root-border
--xh-toolbar-fgrootcolordefault--xh-fg-default
--xh-toolbar-gaprootgapdefault--xh-_toolbar-gap
--xh-toolbar-group-gapgroupgapdefault--xh-space-0
--xh-toolbar-icon-sizeroot--xh-icon-sizedefault
size=lg
size=sm
--xh-glyph-size-lg
--xh-glyph-size-md
--xh-glyph-size-sm
--xh-toolbar-item-bggroup
item
--xh-ink-surface
background-color
default
not([aria-pressed='true'])
xh-ink-surface
--xh-_action-variant-bg-rest
--xh-bg-subtle
--xh-toolbar-item-bg-activeitembackground-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressed
--xh-toolbar-item-bg-disabledgroup
item
--xh-ink-surface
background-color
disabled
not([aria-pressed='true'])
xh-ink-surface
--xh-_action-variant-bg-disabled
--xh-bg-subtle
--xh-toolbar-item-bg-hoveritembackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-toolbar-item-bg-presseditem--xh-ink-surface
background-color
border
border-color
default
disabled
focus-visible
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
xh-ink-surface
--xh-bg-brand
--xh-toolbar-item-bg-pressed-activeitembackground-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-bg-brand-active
--xh-toolbar-item-bg-pressed-disableditem--xh-ink-surface
background-color
disabled
xh-ink-surface
--xh-toolbar-item-bg-pressed
--xh-toolbar-item-bg-pressed-hoveritembackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-bg-brand-hover
--xh-toolbar-item-fgitemcolor@media print
default
disabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-fg-hover
--xh-_action-variant-fg-pressed
--xh-_action-variant-fg-rest
--xh-fg-default
--xh-toolbar-item-fg-presseditemcolordefault
disabled
focus-visible
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-fg-on-brand
--xh-toolbar-item-font-sizeitemfont-sizedefault--xh-_action-profile-font-size
--xh-toolbar-item-font-weightitemfont-weightdefault--xh-text-label-weight
--xh-toolbar-item-gapitemgapdefault--xh-_action-profile-gap
--xh-toolbar-item-hitemblock-size
inline-size
min-inline-size
default
icon-only
orientation=vertical
xh-action-profile=icon
--xh-_action-profile-visual-size
--xh-toolbar-item-pxitempadding-inlinedefault--xh-_action-profile-padding-inline
--xh-toolbar-item-radiusgroup
item
border-end-end-radius
border-end-start-radius
border-radius
border-start-end-radius
border-start-start-radius
default
first-of-type
last-of-type
not(:has(~ [data-scope='toolbar'][data-part='item']:not([hidden])
not([hidden])
orientation=horizontal
orientation=vertical
--xh-_action-profile-radius
--xh-shape-control
--xh-toolbar-pxrootpadding-inlinedefault--xh-_toolbar-root-p
--xh-toolbar-pyrootpadding-blockdefault--xh-_toolbar-root-p
--xh-toolbar-radiusrootborder-radiusdefault
variant=outline
--xh-shape-surface
--xh-toolbar-separator-colorgroup
separator
backgrounddefault--xh-border-default
--xh-fg-default
--xh-toolbar-separator-gapseparatormargin-block
margin-inline
orientation=horizontal
orientation=vertical
--xh-space-3
--xh-toolbar-separator-insetseparatormargin-block
margin-inline
orientation=horizontal
orientation=vertical
--xh-space-0
--xh-toolbar-separator-opacitygroup
separator
opacitydefault--xh-control-separator-opacity
--xh-toolbar-separator-radiusseparatorborder-radiusdefault--xh-shape-pill
--xh-toolbar-separator-thicknessgroup
separator
block-size
inline-size
margin-block
margin-inline
orientation=horizontal
orientation=vertical
--xh-stroke-thin
--xh-toolbar-shadowrootbox-shadowvariant=outlinenone

Released under The MIT License