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

查看生态总览
Skip to content

ScrollArea ​

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="scroll-area": root · viewport · content · scrollbar

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-scroll-area>
Vue componentsXhScrollAreaContent XhScrollAreaCorner XhScrollAreaRoot XhScrollAreaScrollbar XhScrollAreaThumb XhScrollAreaTrack XhScrollAreaViewport
ComposableuseScrollArea
State machineNone: connect computes attributes from props directly
Skin@xihan-ui/styles/scroll-area.css

Props ​

PropTypeRequired
dirDirection
forceVisibleboolean
hideDelaynumber
onReachEnd(details: ScrollAreaScrollDetails) => void
onScrollChange(details: ScrollAreaScrollDetails) => void
orientationScrollAreaOrientation
sizeSize
typeScrollbarType
variantScrollAreaVariant

Events ​

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

EventPayload
scroll-changeScrollAreaScrollDetails
reach-endScrollAreaScrollDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhScrollAreaRootdefaultScrollAreaRootSlotProps

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
XhScrollAreaRootchildrenSlotChildren<ScrollAreaRootSlotProps>
XhScrollAreaScrollbarorientationOrientation

State ​

Public state is written to data-state.

PartValues
scrollbar'visible' | 'hidden'
corner'visible' | 'hidden'

connect API ​

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

MemberType
typeScrollbarType
orientationScrollAreaOrientation
verticalScrollAreaAxisState
horizontalScrollAreaAxisState
draggingAxisOrientation | null
cornerVisibleboolean
scrollTo(options: ScrollAreaScrollToOptions) => void
getRootProps() => T['element']
getViewportProps() => T['element']
getContentProps() => T['element']
getScrollbarProps(props: ScrollAreaScrollbarProps) => T['element']
getTrackProps(props: ScrollAreaScrollbarProps) => T['element']
getThumbProps(props: ScrollAreaScrollbarProps) => T['element']
getCornerProps() => 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
Tab / Shift+Tabscroll-area.kbd.tab
PageUp / PageDownscroll-area.kbd.page
ArrowUp / ArrowDown / ArrowLeft / ArrowRightscroll-area.kbd.arrow
Home / Endscroll-area.kbd.edge
Space / Shift+Spacescroll-area.kbd.space

ARIA ​

These attributes are produced by connect.

PartAttributeValue
scrollbararia-hidden'true'

Style reference ​

Skin ​

@xihan-ui/styles/scroll-area.css is written against [data-scope="scroll-area"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-scroll-area 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-dragging'' (present only while the condition holds)
rootdata-orientationprops.orientation
rootdata-reveal-modeprops.type
rootdata-sizeprops.size
rootdata-variantprops.variant
viewportdata-at-max-horizontal'' (present only while the condition holds)
viewportdata-at-max-vertical'' (present only while the condition holds)
viewportdata-at-min-horizontal'' (present only while the condition holds)
viewportdata-at-min-vertical'' (present only while the condition holds)
viewportdata-lane-horizontal'' (present only while the condition holds)
viewportdata-lane-vertical'' (present only while the condition holds)
viewportdata-native'' (present only while the condition holds)
viewportdata-orientationprops.orientation
viewportdata-sizeprops.size
viewportdata-variantprops.variant
contentdata-orientationprops.orientation
scrollbardata-dragging'' (present only while the condition holds)
scrollbardata-gutter'' (present only while the condition holds)
scrollbardata-native'' (present only while the condition holds)
scrollbardata-orientationaxis
scrollbardata-reveal-modeprops.type
scrollbardata-scrolling'' (present only while the condition holds)
scrollbardata-sizeprops.size
scrollbardata-state'visible' | 'hidden'
cornerdata-state'visible' | 'hidden'

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-scroll-area-fade-sizeviewport-webkit-mask-image
mask-image
at-max-horizontal
at-max-vertical
at-min-horizontal
at-min-vertical
not([data-at-max-horizontal])
not([data-at-max-vertical])
not([data-at-min-horizontal])
not([data-at-min-vertical])
size=lg
size=sm
variant=fade
--xh-space-4
--xh-space-6
--xh-space-8

Released under The MIT License