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

查看生态总览
Skip to content

ColorSlider ​

Data entry 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="color-slider": root · label · control · track · thumb · value-text · hidden-input

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-color-slider>
Vue componentsXhColorSliderControl XhColorSliderHiddenInput XhColorSliderLabel XhColorSliderRoot XhColorSliderThumb XhColorSliderTrack XhColorSliderValueText
ComposableuseColorSlider
State machinecolorSliderMachine
Skin@xihan-ui/styles/color-slider.css

Props ​

PropTypeRequired
labelledboolean
ariaLabelstring
valuestring
defaultValuestring
channelColorChannel
formatColorFormat
hsvaColorHsva
alphaboolean
orientationOrientation
dirDirection
disabledboolean
readOnlyboolean
invalidboolean
sizeSize
namestring
translationsPartial<ColorSliderTranslations>
onValueChange(details: ColorSliderValueChangeDetails) => void
onValueChangeEnd(details: ColorSliderValueChangeDetails) => void

Events ​

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

EventPayload
value-changeColorSliderValueChangeDetails
value-change-endColorSliderValueChangeDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhColorSliderRootdefaultColorSliderRootSlotProps

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
XhColorSliderRootchildrenSlotChildren<ColorSliderRootSlotProps>

State ​

The following names are internal to the state machine.

States: idle

Events: VALUE.SET · CHANNEL.SET · CHANGE.END · FORM.RESET

Guards: canInteract

connect API ​

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

MemberType
valuestring
channelColorChannel
channelValuenumber
percentnumber
minnumber
maxnumber
hsvaColorHsva
rgbaColorRgba
disabledboolean
readOnlyboolean
draggingboolean
setValue(next: string) => void
setChannelValue(next: number) => void
getRootProps() => T['element']
getLabelProps() => T['label']
getControlProps() => T['element']
getTrackProps() => T['element']
getThumbProps() => T['element']
getValueTextProps() => T['element']
getHiddenInputProps() => T['input']

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 / ArrowUpcolor-slider.kbd.increment
ArrowLeft / ArrowDowncolor-slider.kbd.decrement
PageUpcolor-slider.kbd.large-increment
PageDowncolor-slider.kbd.large-decrement
Homecolor-slider.kbd.min
Endcolor-slider.kbd.max

ARIA ​

These attributes are produced by connect.

PartAttributeValue
thumbaria-disabled'true' | 'false'
thumbaria-labelprops.ariaLabel
thumbaria-labelledbyid of the label part | undefined
thumbaria-orientationprops.orientation
thumbaria-valuemaxString(range.max)
thumbaria-valueminString(range.min)
thumbaria-valuenowString(channelValue)
thumbaria-valuetextlabel.valueText(channel, channelValue)
thumbrole'slider'
value-textaria-hidden'true'

Style reference ​

Skin ​

@xihan-ui/styles/color-slider.css is written against [data-scope="color-slider"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-color-slider 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-channelcolorToChannel(prop('channel'))
rootdata-disabled'' (present only while the condition holds)
rootdata-dragging'' (present only while the condition holds)
rootdata-invalid'' (present only while the condition holds)
rootdata-orientationprops.orientation
rootdata-readonly'' (present only while the condition holds)
rootdata-sizeprops.size
rootdata-valuecontext.get('value')
labeldata-channelcolorToChannel(prop('channel'))
labeldata-disabled'' (present only while the condition holds)
labeldata-dragging'' (present only while the condition holds)
labeldata-invalid'' (present only while the condition holds)
labeldata-orientationprops.orientation
labeldata-readonly'' (present only while the condition holds)
controldata-channelcolorToChannel(prop('channel'))
controldata-disabled'' (present only while the condition holds)
controldata-dragging'' (present only while the condition holds)
controldata-invalid'' (present only while the condition holds)
controldata-orientationprops.orientation
controldata-readonly'' (present only while the condition holds)
trackdata-channelcolorToChannel(prop('channel'))
trackdata-disabled'' (present only while the condition holds)
trackdata-dragging'' (present only while the condition holds)
trackdata-invalid'' (present only while the condition holds)
trackdata-orientationprops.orientation
trackdata-readonly'' (present only while the condition holds)
thumbdata-channelcolorToChannel(prop('channel'))
thumbdata-disabled'' (present only while the condition holds)
thumbdata-dragging'' (present only while the condition holds)
thumbdata-invalid'' (present only while the condition holds)
thumbdata-orientationprops.orientation
thumbdata-readonly'' (present only while the condition holds)
value-textdata-channelcolorToChannel(prop('channel'))
value-textdata-disabled'' (present only while the condition holds)
value-textdata-dragging'' (present only while the condition holds)
value-textdata-invalid'' (present only while the condition holds)
value-textdata-orientationprops.orientation
value-textdata-readonly'' (present only while the condition holds)

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-color-slider-checkertrackbackground-imagechannel=alpha--xh-bg-subtle
--xh-color-slider-checker-basetrackbackground-colorchannel=alpha--xh-bg-surface
--xh-color-slider-gaplabel
root
gap
margin-block-end
default--xh-space-1
--xh-color-slider-label-fglabelcolordefault--xh-fg-muted
--xh-color-slider-label-fg-disabledlabelcolordisabled--xh-fg-muted
--xh-color-slider-label-font-sizelabelfont-sizedefault--xh-text-label-size
--xh-color-slider-label-font-weightlabelfont-weightdefault--xh-text-label-weight
--xh-color-slider-label-gaplabelmargin-block-enddefault--xh-space-2
--xh-color-slider-thumb-bgthumbbackgrounddefault--xh-_color-slider-thumb-color
--xh-color-slider-thumb-borderthumbborderdefault--xh-border-default-opaque
--xh-color-slider-thumb-border-invalidthumbborder-colorinvalid--xh-border-invalid
--xh-color-slider-thumb-radiusthumbborder-radiusdefault--xh-shape-circle
--xh-color-slider-thumb-sizecontrol
root
thumb
block-size
inline-size
margin-block-end
margin-block-start
margin-inline-start
default
orientation=horizontal
orientation=vertical
size=lg
size=sm
--xh-space-3
--xh-space-6
--xh-track-thumb-size
--xh-color-slider-track-bordertrackbox-shadowdefault--xh-border-default
--xh-color-slider-track-radiustrackborder-radiusdefault--xh-shape-pill
--xh-color-slider-track-thicknesscontrol
root
track
block-size
inline-size
default
orientation=horizontal
orientation=vertical
size=lg
size=sm
--xh-space-2
--xh-space-3
--xh-space-4
--xh-color-slider-value-text-bgvalue-textbackgrounddefault--xh-bg-brand
--xh-color-slider-value-text-fgvalue-textcolordefault--xh-fg-on-brand
--xh-color-slider-value-text-font-sizevalue-textfont-sizedefault--xh-text-caption-size
--xh-color-slider-value-text-offsetvalue-textmargin-block-end
margin-inline
default
orientation=vertical
--xh-space-2
--xh-color-slider-value-text-pxvalue-textpadding-inlinedefault--xh-space-2
--xh-color-slider-value-text-pyvalue-textpadding-blockdefault--xh-space-0_5
--xh-color-slider-value-text-radiusvalue-textborder-radiusdefault--xh-shape-control
--xh-color-slider-vertical-lengthcontrolblock-sizeorientation=vertical--xh-overlay-menu-min-w

Released under The MIT License