Skip to content

Toggle ​

A switch with an animated track and handle. Exposes role="switch" and a checked state; a disabled widget ignores activation.

a-sxr-toggle Component ​

Properties ​

PropertyDescriptionDefault Value
onEvent that triggers onclick actionclick
keyTextual shortcut key that activates the widget (e.g. 'e')
key-codeLegacy numeric shortcut key (e.g. 32 for Space)-1
checkedWhether the toggle is onfalse
activeWhether the toggle is enabledtrue
toggleToggle statusfalse
toggle-stateSetting the toggle toggle button on/off statefalse
valueText of the toggle button label''
font-familyFont family for toggle buttonOutfit-Regular.ttf
font-sizeFont size for toggle button0.2
font-colorText color for toggle button label#161618
border-width1
border-colorBorder color of toggle button#1B1B1F
background-colorBackground color of toggle button#F1F5F9
hover-colorBackground color when toggle button is in hover state#0EA5E9
handle-colorColor of the toggle handle#F1F5F9
active-colorBackground color when toggle button is pressed down#2563EB
heightHeight of toggle button1
widthWidth of toggle button1
marginMargin around toggle button0 0 0 0
html
<a-sxr-toggle
	width="2.5" height="0.75"
	onclick="testToggleAction"
	value="toggle label"
	font-family="Outfit-Regular.woff2"
	font-size="0.2"
	margin="0 0 0.05 0"
>
</a-sxr-toggle>

States ​

PropertyMeaning
checkedThe switch is on or off
activeThe switch is enabled; false renders it disabled and ignores activation

aria-checked follows checked, so assistive technology and keyboard users see the current state.

Interaction ​

Click, or focus and press Enter / Space, to flip the state. Disabled (active="false") widgets ignore activation.