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

查看生态总览
Skip to content

Splitter ​

Layout 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="splitter": root · panel · resize-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-splitter>
Vue componentsXhSplitterPanel XhSplitterResizeTrigger XhSplitterRoot
ComposableuseSplitter
State machinesplitterMachine
Skin@xihan-ui/styles/splitter.css

Props ​

PropTypeRequired
sizesnumber[]
defaultSizesnumber[]
panelsSplitterPanelProps[]
orientationOrientation
dirDirection
disabledboolean
stepnumber
largeStepnumber
translationsPartial<SplitterTranslations>
onSizesChange(details: SplitterSizesChangeDetails) => void
onSizesChangeEnd(details: SplitterSizesChangeEndDetails) => void

SplitterPanelProps ​

Elements of panels.

FieldTypeRequired
idstringYes
minnumber
maxnumber
collapsibleboolean
collapsedSizenumber

Events ​

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

EventPayload
sizes-changeSplitterSizesChangeDetails
sizes-change-endSplitterSizesChangeEndDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhSplitterRootdefaultSplitterRootSlotProps

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
XhSplitterPanelindexnumber | string
XhSplitterResizeTriggerindexnumber | string
XhSplitterRootchildrenSlotChildren<SplitterRootSlotProps>

State ​

The following names are internal to the state machine.

States: idle · dragging

Events: SIZES.SET · BOUNDARY.STEP · BOUNDARY.TO_MIN · BOUNDARY.TO_MAX · BOUNDARY.SET · BOUNDARY.FOCUS · PANEL.COLLAPSE · PANEL.EXPAND · DRAG.START · DRAG.MOVE · DRAG.END · DRAG.CANCEL · ANIMATION.END

Guards: canResize

connect API ​

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

MemberType
sizesnumber[]
panelsSplitterPanelState[]
draggingboolean
disabledboolean
setSizes(next: number[]) => void
setPanelSize(index: number, next: number) => void
collapsePanel(index: number) => void
expandPanel(index: number) => void
togglePanel(index: number) => void
getRootProps() => T['element']
getPanelProps(index: number) => T['element']
getResizeTriggerProps(index: number) => 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
ArrowRight / ArrowDownsplitter.kbd.grow
ArrowLeft / ArrowUpsplitter.kbd.shrink
Shift+ArrowRight / Shift+ArrowDownsplitter.kbd.large-grow
Shift+ArrowLeft / Shift+ArrowUpsplitter.kbd.large-shrink
Homesplitter.kbd.min
Endsplitter.kbd.max
Escapesplitter.kbd.cancel
Entersplitter.kbd.toggle

ARIA ​

These attributes are produced by connect.

PartAttributeValue
rootaria-labeltranslations.root
rootrole'group'
resize-triggeraria-controlsid of the panel part
resize-triggeraria-disabled'true' | 'false'
resize-triggeraria-labeltranslations.resizeTrigger(boundary, Math.max(0, last…
resize-triggeraria-orientation'horizontal' | 'vertical'
resize-triggeraria-valuemaxString(panel.max)
resize-triggeraria-valueminString(panel.min)
resize-triggeraria-valuenowString(panel.size)
resize-triggerrole'separator'

Style reference ​

Skin ​

@xihan-ui/styles/splitter.css is written against [data-scope="splitter"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-splitter 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-disabled'' (present only while the condition holds)
rootdata-dragging'' (present only while the condition holds)
rootdata-orientationprops.orientation
paneldata-collapsed'' (present only while the condition holds)
paneldata-disabled'' (present only while the condition holds)
paneldata-dragging'' (present only while the condition holds)
paneldata-indexString(panel.index)
paneldata-orientationprops.orientation
resize-triggerdata-disabled'' (present only while the condition holds)
resize-triggerdata-dragging'' (present only while the condition holds)
resize-triggerdata-indexString(boundary)
resize-triggerdata-orientationprops.orientation

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-splitter-disabled-opacityrootopacitydisabled0.6
--xh-splitter-radiusrootborder-radiusdefault--xh-shape-surface
--xh-splitter-trigger-bgresize-triggerbackgrounddefault--xh-border-default
--xh-splitter-trigger-bg-disabledresize-triggerbackgrounddisabled--xh-border-subtle
--xh-splitter-trigger-bg-draggingresize-triggerbackgrounddragging--xh-bg-brand
--xh-splitter-trigger-bg-hoverresize-triggerbackgroundhover--xh-border-control
--xh-splitter-trigger-thicknessresize-triggerblock-size
inline-size
orientation=horizontal
orientation=vertical
--xh-space-1

Released under The MIT License