Skip to content

Slider ​

A horizontal slider. The value is a percent from 0.0 to 1.0; it responds to clicks at the exact hit point, arrow keys, and Home/End.

a-sxr-slider Component ​

Properties ​

PropertyDescriptionDefault Value
active-colorColor of the active (filled) part of the track#2563EB
background-colorBackground color of the track#F1F5F9
border-colorColor of the inactive part of the track#1B1B1F
handle-colorColor of the handle#F1F5F9
handle-outer-radiusOuter radius of the handle0.17
handle-inner-radiusInner radius of the handle0.13
handle-outer-depthDepth of the outer handle0.04
handle-inner-depthDepth of the inner handle0.02
heightHeight of item1
hover-colorHandle color while hovering#0EA5E9
keyboard-stepPercent added/removed per arrow-key press when focused0.05
keyTextual shortcut key that activates the widget (e.g. 'e')
key-codeLegacy numeric shortcut key (e.g. 13 for Enter)-1
left-right-paddingPadding applied to the track width0.25
marginMargin around item0 0 0 0
onclickJavascript function to execute on click
onhoverJavascript function to execute on hover
percentCurrent slider value, from 0.0 to 1.00.5
slider-bar-depthDepth of the slider track0.03
slider-bar-heightHeight of the slider track0.05
top-bottom-paddingPadding applied to the track height0.125
widthWidth of item1
html
<a-sxr-slider
	width="2.5" height="0.75"
	onclick="slideActionFunction"
	percent="0.29"
	margin="0 0 0.05 0"
>
</a-sxr-slider>

Callback signature ​

The onclick callback receives (event, percent):

js
function slideActionFunction(event, percent) {
  console.log('slider moved to', percent)
}

Keyboard ​

KeyAction
← →Step by keyboard-step (0.05 by default)
↑ ↓Step by keyboard-step
HomeJump to 0
EndJump to 1

aria-valuenow follows percent.

VR controllers ​

Controller click events carry the ray intersection, so a VR laser sets the slider to the exact point the ray hits. See VR controllers.